Daily Archives

Articles indexed Saturday January 1 2011

Page 10/25 | < Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >

  • Are there any serialization frameworks for java

    - by Grofit
    I know there is simple, which seems to be a decent enough XML serializer and i know there is Jaxb which seems to do the job as well. However im after something a bit more generic, so I could serialize my model to Xml, Json, Binary etc. So the models are just dumb objects that just get thrown into some sort of serialization factory and then the relevant output is spat out... I dont see any reason why you couldn't do this with reflection, so for a REALLY simple solution get the relevent public properties, cut off the get or set and make that the element name... i.e getPersonName() would become <PersonName>xxxx</PersonName> or PersonName:XXXXX

    Read the article

  • Why is Chrome miscalculating jQuery submenu dimensions?

    - by chunkymonkey
    I'm trying to implement this dropdown menu with flyouts: http://jsfiddle.net/chunkymonkey/fr6x4/ In Chrome certain categories can be expanded to show their subcategories while others show nothing when opened up. For example: Alternative Rock can be expanded to show its multiple subcategories . . . BUT . . . World Music, which has as many subcategories, shows no subcategories when expanded. (SCREENSHOT: http://i.imgur.com/0WorR.jpg) I thought I had tracked this problem down to a problem with they way the dimensions of the dropdown elements are calculated in the original code: First change: - var newLeftVal = - ($('.fg-menu-current').parents('ul').size() - 1) * 180; + var newLeftVal = - ($('.fg-menu-current').parents('ul').size() - 1) * container.width(); Second change: Remove: var checkMenuHeight = function(el) { if (el.height() > options.maxHeight) { el.addClass('fg-menu-scroll') }; el.css({ height: options.maxHeight }); }; Add: var checkMenuHeight = function(el) { var max_height = options.maxHeight - breadcrumb.getTotalHeight(); if (el.height() > max_height) { el.addClass('fg-menu-scroll'); el.height(max_height); topList.height(max_height); } else { if (topList.height() < el.height()) { topList.height(el.height()); } } }; But it's still not working only on Chrome (version 8, Windows & Mac) (not sure why Chrome is different).

    Read the article

  • Ubuntu Server - Power failure leads to boot failure

    - by Ali Nadalizadeh
    I have installed Ubuntu Server 10.04.1 LTS on an ext4 partition. Whenever my system looses power suddenly, It doesn't boot into the normal procedure to fix the problems automatically, but switches to the busy box shell (where it says Kernel Panic : No init found) So I guess kernel is refusing to mount the filesystem when it is not clean, since when I boot up using a Live CD and fsck it, it boots up correctly. How can I force kernel to mount the filesystem, even if it is not clean ?, so that automated fsck on system startup fixes the problems... (or it's a grub problem ?) K-V : 2.6.32-26-generic-pae #48-Ubuntu SMP

    Read the article

  • Linux: set up media server to stream video via the Internet?

    - by Hassan
    How do I set up a media server in Linux which streams video over the internet? Is it easy to do this? I want a server that will actually encode video in real time to allow it to stream over sometimes slow or unreliable networks. Basically, I want a server that works on the internet. I have a directory with a bunch of video files, and want to make this accessible to myself remotely. For other situations, I found great and useful software (such as the PS3 media server). I'd like to find something equally as useful for streaming video over the internet.

    Read the article

  • GNU screen - Unable to reattach to screen after lost connection

    - by subhashish
    I was using irssi in screen but lost connection. After I ssh'd back in to the server, I can no longer attach to that screen. screen -ls shows that the screen is already attached. I tried screen -D to force detach it, and it said detach but screen -ls still says it's attached. I tried screen -x and it just hangs there. [sub@server ~]$ screen -ls There are screens on: 4033.poe (Detached) 7728.irssi (Attached) 2 Sockets in /var/run/screen/S-sub. What can I do now?

    Read the article

  • Who wants to keep developing?

    - by wcm
    I'm a bit older than most of my peers, having come into programming in my mid 30's. The thing is, I love what I do. Most of my project managers and bosses are my age or younger. I'm really OK with that. I, however, have no desire to climb the company ladder. While I regularly take on the responsibility of making sure that projects get done and my peers often look to me for programming and architectural guidance, I just like writing code and want to keep doing it for as long as possible. Honestly, my only real goal is grow into being a crusty old tech lead until I retire. IF I retire. I would so much rather learn the latest and greatest new technology than PMP my resume. Are there others out there who feel like this because I often feel rather alone in my pathology? EDIT Something I didn't make clear is that I really like helping and mentoring other developers. It makes me feel good and useful and (to be brutaly honest) important.

    Read the article

  • ajax tabcontainer with button postback problem

    - by yousof
    I have a dropdownlist in my web page and two command buttons and a tabcontainer. The tabcontainer does not appear after the load of page according to my code. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack Then TabContainer1.Visible = False If CtvAct.GetRecords("Fill_RequestTypeTb") = True Then ReqTypeCmbo.DataSource = CtvAct.MainDataset.Tables("tbOLRequestType").DefaultView ReqTypeCmbo.DataTextField = "RequestTypeName" ReqTypeCmbo.DataValueField = "RequestTypeId" ReqTypeCmbo.DataBind() Dim itm As New ListItem itm.Text = "-- ??? ??? ????? --" itm.Value = "-1" itm.Selected = True ReqTypeCmbo.Items.Insert(0, itm) ReqTypeCmbo.SelectedIndex = 0 End If End If End Sub Protected Sub PrntCmd_Click(ByVal sender As Object, ByVal e As EventArgs) Handles PrntCmd.Click TextBox6.Text = "gggg" End Sub Protected Sub ReqTypeCmbo_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs) Handles ReqTypeCmbo.SelectedIndexChanged If ReqTypeCmbo.SelectedItem.Text = "????" Then TabContainer1.Visible = True TabContainer1.ActiveTabIndex = 0 OwnerDataPnl.Enabled = True AttornyDataPnl.Enabled = True BaseDataPnl.Enabled = True RenwDataPnl.Visible = False NewOwnerDataPnl0.Visible = False AddActivtyPnl.Visible = False SubstitPnl.Visible = False FinishLicePnl.Visible = False CancelActivityPnl.Visible = False LocTransPnl.Visible = False ' Panel1.Visible = False '?????? ?????? ??????? ???????? REstOfficeAddrTxt.Enabled = True REstOffIdeIssuedPlaceTxt.Enabled = True REstOffIdentityNameTxt.Enabled = True REstOffIdentityNumberTxt.Enabled = True REstOffIdentityStartDateTxt.Enabled = True REstOffMobileTxt.Enabled = True REstOffNameTxt.Enabled = True REstOffPhoneTxt.Enabled = True OwnerShipNumberTxt.Enabled = True OwnerShipDateTxt.Enabled = True OwnerShipIssuedPlaceTxt.Enabled = True SerailTxt.Enabled = True RequestIdTxt.Enabled = True RequestDateTxt.Enabled = True RenwDataPnl.Visible = True '''' If CtvAct.GetRecords("Fill_NationalityTb") = True Then OwnrNationCmbo.DataSource = CtvAct.MainDataset.Tables("tbOLNationality").DefaultView OwnrNationCmbo.DataTextField = "NationName" OwnrNationCmbo.DataValueField = "NationId" OwnrNationCmbo.DataBind() Dim itm As New ListItem itm.Text = "-- ??? ??????? --" itm.Value = "-1" itm.Selected = True OwnrNationCmbo.Items.Insert(0, itm) OwnrNationCmbo.SelectedIndex = 0 End If If CtvAct.GetRecords("Fill_ActivityTb") = True Then AcivityCombo.DataSource = CtvAct.MainDataset.Tables("tbOLActivity").DefaultView AcivityCombo.DataTextField = "ActivityName" AcivityCombo.DataValueField = "ActivityId" AcivityCombo.DataBind() AcivityCombo.SelectedIndex = -1 Dim itm As New ListItem itm.Text = "-- ??? ?????? --" itm.Value = "-1" itm.Selected = True AcivityCombo.Items.Insert(0, itm) AcivityCombo.SelectedIndex = 0 End If 'If CtvAct.GetRecords("Fill_ActivityTb") = True Then ' DropDownList2.DataSource = CtvAct.MainDataset.Tables("tbOLActivity").DefaultView ' DropDownList2.DataTextField = "ActivityName" ' DropDownList2.DataValueField = "ActivityId" ' DropDownList2.DataBind() 'AcivityCombo.Visible = True ' LbCon.Text = CtvAct.Prt 'End If AttronayNationCmbo.SelectedIndex = -1 If CtvAct.GetRecords("Fill_NationalityTb") = True Then AttronayNationCmbo.DataSource = CtvAct.MainDataset.Tables("tbOLNationality").DefaultView AttronayNationCmbo.DataTextField = "NationName" AttronayNationCmbo.DataValueField = "NationId" AttronayNationCmbo.DataBind() Dim itm As New ListItem itm.Text = "-- ??? ??????? --" itm.Value = "-1" itm.Selected = True AttronayNationCmbo.Items.Insert(0, itm) AttronayNationCmbo.SelectedIndex = 0 ' LbCon.Text = CtvAct.Prt End If If CtvAct.GetRecords("Fill_LocationTb") = True Then LocationIdCmbo.DataSource = CtvAct.MainDataset.Tables("tbOLLocation").DefaultView LocationIdCmbo.DataTextField = "LocationName" LocationIdCmbo.DataValueField = "LocationId" LocationIdCmbo.DataBind() Dim itm As New ListItem itm.Text = "-- ??? ?????? --" itm.Value = "-1" itm.Selected = True LocationIdCmbo.Items.Insert(0, itm) LocationIdCmbo.SelectedIndex = 0 ' LbCon.Text = CtvAct.Prt End If '''''''''''''''''''''''''''''''' con = New SqlConnection(CtvAct.Connection_String()) CmdActivty = con.CreateCommand CmdActivty.CommandText = "SELECT ActivityId FROM tbOLStoreActivty" DaActivity.SelectCommand = CmdActivty DaActivity.Fill(DsActivity, "tbOLStoreActivty") ActivityGV.DataSource = DaActivity ActivityGV.DataMember = "tbOLStoreActivty" AcivityCombo.DataSource = ds.Tables(0) AcivityCombo.DataTextField = "ename" AcivityCombo.DataValueField = "eid" AcivityCombo.DataBind() ''''''''''''''''''''''''''''' LbCon.Text = CtvAct.Prt ElseIf ReqTypeCmbo.SelectedItem.Text = "?????" Then TabContainer1.Visible = True TabContainer1.ActiveTabIndex = 1 OwnerDataPnl.Enabled = False AttornyDataPnl.Enabled = False BaseDataPnl.Enabled = True AddActivtyPnl.Visible = False SubstitPnl.Visible = False FinishLicePnl.Visible = False RenwDataPnl.Visible = True AddActivtyPnl.Visible = False NewOwnerDataPnl0.Visible = False CancelActivityPnl.Visible = False LocTransPnl.Visible = False '?????? ?????? ??????? ???????? REstOfficeAddrTxt.Enabled = False REstOffIdeIssuedPlaceTxt.Enabled = False REstOffIdentityNameTxt.Enabled = False REstOffIdentityNumberTxt.Enabled = False REstOffIdentityStartDateTxt.Enabled = False REstOffMobileTxt.Enabled = False REstOffNameTxt.Enabled = False REstOffPhoneTxt.Enabled = False OwnerShipNumberTxt.Enabled = False OwnerShipDateTxt.Enabled = False OwnerShipIssuedPlaceTxt.Enabled = False SerailTxt.Enabled = True RequestIdTxt.Enabled = True RequestDateTxt.Enabled = True ''''''''' ElseIf ReqTypeCmbo.SelectedItem.Text = "??? ?????" Then TabContainer1.Visible = True TabContainer1.ActiveTabIndex = 1 OwnerDataPnl.Enabled = False AttornyDataPnl.Enabled = False BaseDataPnl.Enabled = False RenwDataPnl.Visible = False NewOwnerDataPnl0.Visible = True AddActivtyPnl.Visible = False SubstitPnl.Visible = False FinishLicePnl.Visible = False CancelActivityPnl.Visible = False LocTransPnl.Visible = False ElseIf ReqTypeCmbo.SelectedItem.Text = "????? ????" Then TabContainer1.Visible = True TabContainer1.ActiveTabIndex = 1 OwnerDataPnl.Enabled = False AttornyDataPnl.Enabled = False BaseDataPnl.Enabled = False RenwDataPnl.Visible = False NewOwnerDataPnl0.Visible = False AddActivtyPnl.Visible = False SubstitPnl.Visible = False FinishLicePnl.Visible = False CancelActivityPnl.Visible = True LocTransPnl.Visible = False ElseIf ReqTypeCmbo.SelectedItem.Text = "????? ????" Then TabContainer1.Visible = True TabContainer1.ActiveTabIndex = 1 OwnerDataPnl.Enabled = False AttornyDataPnl.Enabled = False BaseDataPnl.Enabled = False RenwDataPnl.Visible = False NewOwnerDataPnl0.Visible = False AddActivtyPnl.Visible = False SubstitPnl.Visible = False FinishLicePnl.Visible = True LocTransPnl.Visible = False ElseIf ReqTypeCmbo.SelectedItem.Text = "??? ???? / ????" Then TabContainer1.Visible = True TabContainer1.ActiveTabIndex = 1 OwnerDataPnl.Enabled = False AttornyDataPnl.Enabled = False BaseDataPnl.Enabled = False RenwDataPnl.Visible = False NewOwnerDataPnl0.Visible = False AddActivtyPnl.Visible = False SubstitPnl.Visible = True FinishLicePnl.Visible = False LocTransPnl.Visible = False ElseIf ReqTypeCmbo.SelectedItem.Text = "??? ????" Then TabContainer1.Visible = True TabContainer1.ActiveTabIndex = 0 OwnerDataPnl.Enabled = True AttornyDataPnl.Enabled = True BaseDataPnl.Enabled = True RenwDataPnl.Visible = False NewOwnerDataPnl0.Visible = False AddActivtyPnl.Visible = False SubstitPnl.Visible = False FinishLicePnl.Visible = False CancelActivityPnl.Visible = False LocTransPnl.Visible = True End If End Sub If I press any button after page load the button work very selecting any item from dropdownlist make the tabcontainer appear but after the tabcontainer appear, the buttons does not work (postback) how can I solve these problems

    Read the article

  • templete class c++

    - by inna karpasas
    hi! i try to design a templete for my universty project. i wrote the follwing cod: #ifndef _LinkedList_H_ #define _LinkedList_H_ #include "Link.h" #include <ostream> template <class L>//error one class LinkedList { private: Link<L> *pm_head; Link<L> * pm_tail; int m_numOfElements; Link<L>* FindLink(L * dataToFind); public: LinkedList(); ~LinkedList(); int GetNumOfElements(){return m_numOfElements;} bool Add( L * data); L *FindData(L * data); template <class L> friend ostream & operator<<(ostream& os,const LinkedList<L> listToprint);//error two L* GetDataOnTop(); bool RemoveFromHead(); L* Remove(L * toRemove); this templete uses the link class templete #ifndef _Link_H_ #define _Link_H_ template <class T>//error 3 class Link { private: T* m_data; Link* m_next; Link* m_prev; public: Link(T* data); ~Link(void); bool Link::operator ==(const Link& other)const; /*getters*/ Link* GetNext()const {return m_next;} Link* GetPrev()const {return m_prev;} T* GetData()const {return m_data;} //setters void SetNext(Link* next) {m_next = next;} void SetPrev(Link* prev) {m_prev = prev;} void SetData(T* data) {m_data = data;} }; error one: shadows template parm class L' error two:declaration ofclass L' error three: shadows template parm `class T' i dont understand what is the problem. i can relly usr your help thank you :)

    Read the article

  • if the hide() jquery animate function set after animate(),it doesn't work?

    - by hh54188
    First I have a animate a iframe which id is "test" <iframe id="test" src=""></iframe> then I want animate it and hide it ,make a close effect like in MacOS: $('#test').animate({ 'width':0, 'height':0, 'top':$('input').offset().top, 'left':$('input').offset().left },function(){ //$(this).hide(); }).hide(); but it seems the iframe can not be hide.However,if I write it in the callback function that in animate,which is the annotated code above.It could work again. Here is online case So I wonder why the hide() after animate() doesn't work?Do I miss something ?

    Read the article

  • arbitrary vire connection / search and replace

    - by fatai
    input :["vire_connection",[1, 2, [ 3, [ 4, "connect"]]], ["connect", [3 , 5] ] ] output:["vire_connection",[ 1, 2, [ 3, [ 4, [ 3, 5 ] ] ] ] ], [ [ 3 , 5] ] ] after connection ( simply copying [3,5] to other wanted position ) , remove connect word input :["vire_connection", [ [ [ ["connect", [ 3, 4 ] ] ] ] ], [ 2, "connect"]] output :["vire_connection",[[[[[3,4]]]]], [ 2, [ 3 , 4 ]]] after connection ( simply copying [3,4] to other wanted position ) , remove connect word how can I do ?

    Read the article

  • putting <%=yield %> in a partial for ajax jquery calls

    - by odpogn
    I'm trying to make the "home" link in my <%= render 'layouts/header' %> do an ajax/jquery call to change the <%= yield %> in a partial inside my content div. all i get are blanks in the view.. <%= yield %> works fine when put in a partial without ajax, but it doesn't display anything when using ajax... can yield not be used this way? all I'm really looking for is the ability to click on my sites navigation links without having to reload the entire page... my application.html.erb file looks like so: <head> $(function() { $("#home").live("click", function() { $.get(this.href, null, null, "script"); return false; }); }); </head> <body> <div id="container"> <%= render 'layouts/header' %> <div id="content"> <%= render 'layouts/content' %> </div> <%= render 'layouts/footer' %> </div> </body> my <%= render 'layouts/header' %> contains: <%= link_to "Home", root_path, :id => "home" %> my <%= render 'layouts/content' %> only contains: <%= yield %> home.js.erb $("#content").html("<%= escape_javascript(render("layouts/content")) %>");

    Read the article

  • Threading and pcap issues.

    - by cftmon
    I have a GUI program that allows a user a scan a network, the issue is that when the pcap_loop function is called, my GUI program becomes unresponsive.(the pcap_loop blocks the current thread). When i try to use pthreads, i got a SIGSEGV fault at the pcap_loop function.Why?It's as if the thread can't see the procPacket function itself. void procPacket(u_char *arg, const struct pcap_pkthdr *pkthdr, const u_char *packet) { //show packets here } void* pcapLooper(void* param) { pcap_t* handler = (pcap_t*) param; pcap_loop(handler, 900 ,procPacket, NULL ); } //some function that runs when a button is pressed //handler has been opened through pcap_open_live pthread_t scanner; int t = pthread_create(&scanner,NULL,&pcapLooper, &handler ); if(t) { std::cout << "failed" << std::endl; } pthread_join(scanner,NULL); //do other stuff.

    Read the article

  • diffuculty in appending images dynamically in an Custom List View

    - by ganesh
    Hi I have written an custom List view which binds images according to the result from a feed @Override public View getView(int position, View convertView, ViewGroup parent) { ViewHolder holder; if (convertView == null) { convertView = mInflater.inflate(R.layout.row_for_stopnames, null); holder = new ViewHolder(); holder.name = (TextView)convertView.findViewById(R.id.stop_name); holder.dis = (TextView)convertView.findViewById(R.id.distance); holder.route_one=(ImageView)convertView.findViewById(R.id.one); holder.route_two=(ImageView)convertView.findViewById(R.id.two); holder.route_three=(ImageView)convertView.findViewById(R.id.three); convertView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.name.setText(elements.get(position).get("stop_name")); holder.dis.setText(elements.get(position).get("distance")); String[] route_txt=elements.get(position).get("route_name").split(","); for(int i=0;i<route_txt.length;i++) { if(i==0) { holder.route_one.setBackgroundResource(Utils.getRouteImage().get(stop_txt[0])); } else if(i==1) { holder.route_two.setBackgroundResource(Utils.getRouteImage().get(stop_txt[1])); } else if(i==2) { holder.route_three.setBackgroundResource(Utils.getRouteImage().get(stop_txt[2])); } } convertView.setOnClickListener(new OnItemClickListener(position,elements)); return convertView; } class ViewHolder { TextView name; TextView dis; ImageView route_one; ImageView route_two; ImageView route_three; } for every stop name there may be route_names, maximum of three routes.I have to bind images according to the number of route names.This is what I tried to do by the above code .This works fine until I start scrolling up and down .When I do so the route images gets displayed where it does not want to be,this behaviour is unpredictable.I will be glad if someone explain me why this happens,and the best way to do this.The getRouteImage method of Utils class returns HashMap with key String and value a drawable

    Read the article

  • RTF template coding, XSLT coding

    - by sujith
    I have the below requirement <data> <dataset1> <number>1</number> <name>red</name> <number>2</number> <name>Yellow</name> <number>3</number> <name>black</name> <number>4</number> <name>Violet</name> </dataset1> <dataset2> <index>1</index> <index>2</index> <index>3</index> <index>4</index> </dataset2> </data> I need to loop through dataset2 take the index value, compare it with the value of number tag in dataset1. If a match occurs then display value of corresponding name tag. I need to get the output in rtf format. Please give BI tags or relevent xslt code to do the same. Thanks in advance.

    Read the article

  • Closing a hook that captures global input events

    - by Margus
    Intro Here is an example to illustrate the problem. Consider I am tracking and displaying mouse global current position and last click button and position to the user. Here is an image: To archive capturing click events on windows box, that would and will be sent to the other programs event messaging queue, I create a hook using winapi namely user32.dll library. This is outside JDK sandbox, so I use JNA to call the native library. This all works perfectly, but it does not close as I expect it to. My question is - How do I properly close following example program? Example source Code below is not fully written by Me, but taken from this question in Oracle forum and partly fixed. import java.awt.AWTException; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.GridLayout; import java.awt.MouseInfo; import java.awt.Point; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.JFrame; import javax.swing.JLabel; import com.sun.jna.Native; import com.sun.jna.NativeLong; import com.sun.jna.Platform; import com.sun.jna.Structure; import com.sun.jna.platform.win32.BaseTSD.ULONG_PTR; import com.sun.jna.platform.win32.Kernel32; import com.sun.jna.platform.win32.User32; import com.sun.jna.platform.win32.WinDef.HWND; import com.sun.jna.platform.win32.WinDef.LRESULT; import com.sun.jna.platform.win32.WinDef.WPARAM; import com.sun.jna.platform.win32.WinUser.HHOOK; import com.sun.jna.platform.win32.WinUser.HOOKPROC; import com.sun.jna.platform.win32.WinUser.MSG; import com.sun.jna.platform.win32.WinUser.POINT; public class MouseExample { final JFrame jf; final JLabel jl1, jl2; final CWMouseHook mh; final Ticker jt; public class Ticker extends Thread { public boolean update = true; public void done() { update = false; } public void run() { try { Point p, l = MouseInfo.getPointerInfo().getLocation(); int i = 0; while (update == true) { try { p = MouseInfo.getPointerInfo().getLocation(); if (!p.equals(l)) { l = p; jl1.setText(new GlobalMouseClick(p.x, p.y) .toString()); } Thread.sleep(35); } catch (InterruptedException e) { e.printStackTrace(); return; } } } catch (Exception e) { update = false; } } } public MouseExample() throws AWTException, UnsupportedOperationException { this.jl1 = new JLabel("{}"); this.jl2 = new JLabel("{}"); this.jf = new JFrame(); this.jt = new Ticker(); this.jt.start(); this.mh = new CWMouseHook() { @Override public void globalClickEvent(GlobalMouseClick m) { jl2.setText(m.toString()); } }; mh.setMouseHook(); jf.setLayout(new GridLayout(2, 2)); jf.add(new JLabel("Position")); jf.add(jl1); jf.add(new JLabel("Last click")); jf.add(jl2); jf.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent we) { mh.dispose(); jt.done(); jf.dispose(); } }); jf.setLocation(new Point(0, 0)); jf.setPreferredSize(new Dimension(200, 90)); jf.pack(); jf.setVisible(true); } public static class GlobalMouseClick { private char c; private int x, y; public GlobalMouseClick(char c, int x, int y) { super(); this.c = c; this.x = x; this.y = y; } public GlobalMouseClick(int x, int y) { super(); this.x = x; this.y = y; } public char getC() { return c; } public void setC(char c) { this.c = c; } public int getX() { return x; } public void setX(int x) { this.x = x; } public int getY() { return y; } public void setY(int y) { this.y = y; } @Override public String toString() { return (c != 0 ? c : "") + " [" + x + "," + y + "]"; } } public static class CWMouseHook { public User32 USER32INST; public CWMouseHook() throws UnsupportedOperationException { if (!Platform.isWindows()) { throw new UnsupportedOperationException( "Not supported on this platform."); } USER32INST = User32.INSTANCE; mouseHook = hookTheMouse(); Native.setProtected(true); } private static LowLevelMouseProc mouseHook; private HHOOK hhk; private boolean isHooked = false; public static final int WM_LBUTTONDOWN = 513; public static final int WM_LBUTTONUP = 514; public static final int WM_RBUTTONDOWN = 516; public static final int WM_RBUTTONUP = 517; public static final int WM_MBUTTONDOWN = 519; public static final int WM_MBUTTONUP = 520; public void dispose() { unsetMouseHook(); mousehook_thread = null; mouseHook = null; hhk = null; USER32INST = null; } public void unsetMouseHook() { isHooked = false; USER32INST.UnhookWindowsHookEx(hhk); System.out.println("Mouse hook is unset."); } public boolean isIsHooked() { return isHooked; } public void globalClickEvent(GlobalMouseClick m) { System.out.println(m); } private Thread mousehook_thread; public void setMouseHook() { mousehook_thread = new Thread(new Runnable() { @Override public void run() { try { if (!isHooked) { hhk = USER32INST.SetWindowsHookEx(14, mouseHook, Kernel32.INSTANCE.GetModuleHandle(null), 0); isHooked = true; System.out .println("Mouse hook is set. Click anywhere."); // message dispatch loop (message pump) MSG msg = new MSG(); while ((USER32INST.GetMessage(msg, null, 0, 0)) != 0) { USER32INST.TranslateMessage(msg); USER32INST.DispatchMessage(msg); if (!isHooked) break; } } else System.out .println("The Hook is already installed."); } catch (Exception e) { System.err.println("Caught exception in MouseHook!"); } } }); mousehook_thread.start(); } private interface LowLevelMouseProc extends HOOKPROC { LRESULT callback(int nCode, WPARAM wParam, MOUSEHOOKSTRUCT lParam); } private LowLevelMouseProc hookTheMouse() { return new LowLevelMouseProc() { @Override public LRESULT callback(int nCode, WPARAM wParam, MOUSEHOOKSTRUCT info) { if (nCode >= 0) { switch (wParam.intValue()) { case CWMouseHook.WM_LBUTTONDOWN: globalClickEvent(new GlobalMouseClick('L', info.pt.x, info.pt.y)); break; case CWMouseHook.WM_RBUTTONDOWN: globalClickEvent(new GlobalMouseClick('R', info.pt.x, info.pt.y)); break; case CWMouseHook.WM_MBUTTONDOWN: globalClickEvent(new GlobalMouseClick('M', info.pt.x, info.pt.y)); break; default: break; } } return USER32INST.CallNextHookEx(hhk, nCode, wParam, info.getPointer()); } }; } public class Point extends Structure { public class ByReference extends Point implements Structure.ByReference { }; public NativeLong x; public NativeLong y; } public static class MOUSEHOOKSTRUCT extends Structure { public static class ByReference extends MOUSEHOOKSTRUCT implements Structure.ByReference { }; public POINT pt; public HWND hwnd; public int wHitTestCode; public ULONG_PTR dwExtraInfo; } } public static void main(String[] args) { EventQueue.invokeLater(new Runnable() { @Override public void run() { try { new MouseExample(); } catch (AWTException e) { e.printStackTrace(); } } }); } }

    Read the article

  • A map and set which uses contiguous memory and has a reserve function

    - by edA-qa mort-ora-y
    I use several maps and sets. The lack of contiguous memory, and high number of (de)allocations, is a performance bottleneck. I need a mainly STL-compatbile map and set class which can use a contiguous block of memory for internal objects (or multiple blocks). It also needs to have a reserve function so that I can preallocate for expected sizes. Before I write my own I'd like to check what is available first. Is there something in Boost which does this? Does somebody know of an available implementation elsewhere? Intrusive collection types are not usable here as the same objects need to exist in several collections. As far as I know STL memory pools are per-type, not per instance. These global pools are not efficient with respect to memory locality in mutli-cpu/core processing. Object pools don't work as the types will be shared between instance but their pool should not. In many cases a hash map may be an option in some cases.

    Read the article

  • help me improve my sse yuv to rgb ssse3 code

    - by David McPaul
    Hello, I am looking to optimise some sse code I wrote for converting yuv to rgb (both planar and packed yuv functions). i am using SSSE3 at the moment but if there are useful functions from later sse versions thats ok. I am mainly interested in how I would work out processor stalls and the like. Anyone know of any tools that do static analysis of sse code? ; ; Copyright (C) 2009-2010 David McPaul ; ; All rights reserved. Distributed under the terms of the MIT License. ; ; A rather unoptimised set of ssse3 yuv to rgb converters ; does 8 pixels per loop ; inputer: ; reads 128 bits of yuv 8 bit data and puts ; the y values converted to 16 bit in xmm0 ; the u values converted to 16 bit and duplicated into xmm1 ; the v values converted to 16 bit and duplicated into xmm2 ; conversion: ; does the yuv to rgb conversion using 16 bit integer and the ; results are placed into the following registers as 8 bit clamped values ; r values in xmm3 ; g values in xmm4 ; b values in xmm5 ; outputer: ; writes out the rgba pixels as 8 bit values with 0 for alpha ; xmm6 used for scratch ; xmm7 used for scratch %macro cglobal 1 global _%1 %define %1 _%1 align 16 %1: %endmacro ; conversion code %macro yuv2rgbsse2 0 ; u = u - 128 ; v = v - 128 ; r = y + v + v >> 2 + v >> 3 + v >> 5 ; g = y - (u >> 2 + u >> 4 + u >> 5) - (v >> 1 + v >> 3 + v >> 4 + v >> 5) ; b = y + u + u >> 1 + u >> 2 + u >> 6 ; subtract 16 from y movdqa xmm7, [Const16] ; loads a constant using data cache (slower on first fetch but then cached) psubsw xmm0,xmm7 ; y = y - 16 ; subtract 128 from u and v movdqa xmm7, [Const128] ; loads a constant using data cache (slower on first fetch but then cached) psubsw xmm1,xmm7 ; u = u - 128 psubsw xmm2,xmm7 ; v = v - 128 ; load r,b with y movdqa xmm3,xmm0 ; r = y pshufd xmm5,xmm0, 0xE4 ; b = y ; r = y + v + v >> 2 + v >> 3 + v >> 5 paddsw xmm3, xmm2 ; add v to r movdqa xmm7, xmm1 ; move u to scratch pshufd xmm6, xmm2, 0xE4 ; move v to scratch psraw xmm6,2 ; divide v by 4 paddsw xmm3, xmm6 ; and add to r psraw xmm6,1 ; divide v by 2 paddsw xmm3, xmm6 ; and add to r psraw xmm6,2 ; divide v by 4 paddsw xmm3, xmm6 ; and add to r ; b = y + u + u >> 1 + u >> 2 + u >> 6 paddsw xmm5, xmm1 ; add u to b psraw xmm7,1 ; divide u by 2 paddsw xmm5, xmm7 ; and add to b psraw xmm7,1 ; divide u by 2 paddsw xmm5, xmm7 ; and add to b psraw xmm7,4 ; divide u by 32 paddsw xmm5, xmm7 ; and add to b ; g = y - u >> 2 - u >> 4 - u >> 5 - v >> 1 - v >> 3 - v >> 4 - v >> 5 movdqa xmm7,xmm2 ; move v to scratch pshufd xmm6,xmm1, 0xE4 ; move u to scratch movdqa xmm4,xmm0 ; g = y psraw xmm6,2 ; divide u by 4 psubsw xmm4,xmm6 ; subtract from g psraw xmm6,2 ; divide u by 4 psubsw xmm4,xmm6 ; subtract from g psraw xmm6,1 ; divide u by 2 psubsw xmm4,xmm6 ; subtract from g psraw xmm7,1 ; divide v by 2 psubsw xmm4,xmm7 ; subtract from g psraw xmm7,2 ; divide v by 4 psubsw xmm4,xmm7 ; subtract from g psraw xmm7,1 ; divide v by 2 psubsw xmm4,xmm7 ; subtract from g psraw xmm7,1 ; divide v by 2 psubsw xmm4,xmm7 ; subtract from g %endmacro ; outputer %macro rgba32sse2output 0 ; clamp values pxor xmm7,xmm7 packuswb xmm3,xmm7 ; clamp to 0,255 and pack R to 8 bit per pixel packuswb xmm4,xmm7 ; clamp to 0,255 and pack G to 8 bit per pixel packuswb xmm5,xmm7 ; clamp to 0,255 and pack B to 8 bit per pixel ; convert to bgra32 packed punpcklbw xmm5,xmm4 ; bgbgbgbgbgbgbgbg movdqa xmm0, xmm5 ; save bg values punpcklbw xmm3,xmm7 ; r0r0r0r0r0r0r0r0 punpcklwd xmm5,xmm3 ; lower half bgr0bgr0bgr0bgr0 punpckhwd xmm0,xmm3 ; upper half bgr0bgr0bgr0bgr0 ; write to output ptr movntdq [edi], xmm5 ; output first 4 pixels bypassing cache movntdq [edi+16], xmm0 ; output second 4 pixels bypassing cache %endmacro SECTION .data align=16 Const16 dw 16 dw 16 dw 16 dw 16 dw 16 dw 16 dw 16 dw 16 Const128 dw 128 dw 128 dw 128 dw 128 dw 128 dw 128 dw 128 dw 128 UMask db 0x01 db 0x80 db 0x01 db 0x80 db 0x05 db 0x80 db 0x05 db 0x80 db 0x09 db 0x80 db 0x09 db 0x80 db 0x0d db 0x80 db 0x0d db 0x80 VMask db 0x03 db 0x80 db 0x03 db 0x80 db 0x07 db 0x80 db 0x07 db 0x80 db 0x0b db 0x80 db 0x0b db 0x80 db 0x0f db 0x80 db 0x0f db 0x80 YMask db 0x00 db 0x80 db 0x02 db 0x80 db 0x04 db 0x80 db 0x06 db 0x80 db 0x08 db 0x80 db 0x0a db 0x80 db 0x0c db 0x80 db 0x0e db 0x80 ; void Convert_YUV422_RGBA32_SSSE3(void *fromPtr, void *toPtr, int width) width equ ebp+16 toPtr equ ebp+12 fromPtr equ ebp+8 ; void Convert_YUV420P_RGBA32_SSSE3(void *fromYPtr, void *fromUPtr, void *fromVPtr, void *toPtr, int width) width1 equ ebp+24 toPtr1 equ ebp+20 fromVPtr equ ebp+16 fromUPtr equ ebp+12 fromYPtr equ ebp+8 SECTION .text align=16 cglobal Convert_YUV422_RGBA32_SSSE3 ; reserve variables push ebp mov ebp, esp push edi push esi push ecx mov esi, [fromPtr] mov edi, [toPtr] mov ecx, [width] ; loop width / 8 times shr ecx,3 test ecx,ecx jng ENDLOOP REPEATLOOP: ; loop over width / 8 ; YUV422 packed inputer movdqa xmm0, [esi] ; should have yuyv yuyv yuyv yuyv pshufd xmm1, xmm0, 0xE4 ; copy to xmm1 movdqa xmm2, xmm0 ; copy to xmm2 ; extract both y giving y0y0 pshufb xmm0, [YMask] ; extract u and duplicate so each u in yuyv becomes u0u0 pshufb xmm1, [UMask] ; extract v and duplicate so each v in yuyv becomes v0v0 pshufb xmm2, [VMask] yuv2rgbsse2 rgba32sse2output ; endloop add edi,32 add esi,16 sub ecx, 1 ; apparently sub is better than dec jnz REPEATLOOP ENDLOOP: ; Cleanup pop ecx pop esi pop edi mov esp, ebp pop ebp ret cglobal Convert_YUV420P_RGBA32_SSSE3 ; reserve variables push ebp mov ebp, esp push edi push esi push ecx push eax push ebx mov esi, [fromYPtr] mov eax, [fromUPtr] mov ebx, [fromVPtr] mov edi, [toPtr1] mov ecx, [width1] ; loop width / 8 times shr ecx,3 test ecx,ecx jng ENDLOOP1 REPEATLOOP1: ; loop over width / 8 ; YUV420 Planar inputer movq xmm0, [esi] ; fetch 8 y values (8 bit) yyyyyyyy00000000 movd xmm1, [eax] ; fetch 4 u values (8 bit) uuuu000000000000 movd xmm2, [ebx] ; fetch 4 v values (8 bit) vvvv000000000000 ; extract y pxor xmm7,xmm7 ; 00000000000000000000000000000000 punpcklbw xmm0,xmm7 ; interleave xmm7 into xmm0 y0y0y0y0y0y0y0y0 ; extract u and duplicate so each becomes 0u0u punpcklbw xmm1,xmm7 ; interleave xmm7 into xmm1 u0u0u0u000000000 punpcklwd xmm1,xmm7 ; interleave again u000u000u000u000 pshuflw xmm1,xmm1, 0xA0 ; copy u values pshufhw xmm1,xmm1, 0xA0 ; to get u0u0 ; extract v punpcklbw xmm2,xmm7 ; interleave xmm7 into xmm1 v0v0v0v000000000 punpcklwd xmm2,xmm7 ; interleave again v000v000v000v000 pshuflw xmm2,xmm2, 0xA0 ; copy v values pshufhw xmm2,xmm2, 0xA0 ; to get v0v0 yuv2rgbsse2 rgba32sse2output ; endloop add edi,32 add esi,8 add eax,4 add ebx,4 sub ecx, 1 ; apparently sub is better than dec jnz REPEATLOOP1 ENDLOOP1: ; Cleanup pop ebx pop eax pop ecx pop esi pop edi mov esp, ebp pop ebp ret SECTION .note.GNU-stack noalloc noexec nowrite progbits

    Read the article

  • C++, function pointer to the template function pointer

    - by Ian
    I am having a pointer to the common static method class MyClass { private: static double ( *pfunction ) ( const Object *, const Object *); ... }; pointing to the static method class SomeClass { public: static double getA ( const Object *o1, const Object *o2); ... }; Initialization: double ( *MyClass::pfunction ) ( const Object *o1, const Object *o2 ) = &SomeClass::getA; I would like to convert this pointer to the static template function pointer: template <class T> static T ( *pfunction ) ( const Object <T> *, const Object <T> *); //Compile error where: class SomeClass { public: template <class T> static double getA ( const Object <T> *o1, const Object <T> *o2); ... }; But there is some error... Thanks for your help...

    Read the article

  • How to use a rewrite rule to force calls for "domain.tld/subdir/file.html" to show as "subdir.domain.tld/file.html"?

    - by Wion
    Hi! First time poster. Very new to mod_rewrite. I'm on a shared server and the context of this problem is with a virtual directory under my root account. The domain (domain.tld) will have subdirectories representing annual mini-sites of static .html files. Subdirectory names (yyyy) will be the 4-digit year (e.g., "2010"). I want any call to domain.tld/yyyy/file.html to appear as yyyy.domain.tld/file.html in the browser address bar, and (of course) for the page to load properly. I already force dropping “www” by using… RewriteCond %{HTTP_HOST} ^www\.domain\.tld [NC] RewriteRule (.*) http://domain.tld/$1 [R=301,L] So far so good. But no matter what I try after that, I can’t get the subdomain to force to the front of the domain. Here’s one of the more complicated examples I’ve tried (no doubt wrong)… RewriteCond %{HTTP_HOST} ^domain\.tld/([0-9]+)/([a-z-]+)\.html [NC] RewriteRule (.*) %1.domain.tld/%2.html [NC] This doesn’t break anything (that I can tell), but it doesn’t do what I want either. I.e., if I type yyyy.domain.tld, I’ll see yyyy.domain.tld in the address bar, and navigating around will give me yyyy.domain.tld/file.html, etc. Fine. But if also type domain.tld/yyyy I’ll see domain.tld/yyyy, etc, which is not how I want people to see it. It doesn’t redirect or mask or alias or whatever you call it. Is it even possible to force one look over the other like that? Should I be handling this with DNS instead? Thanks in advance!

    Read the article

  • -webkit-transition-property for translation

    - by sexyprout
    Hai. What is the transition property for translations in CSS3? I'm currently using all but I got a bug in iOS so I want to test another property. -webkit-transform: translate(-320px, 0);   -webkit-transition: ??? .5 ease-in-out; See the bug with an iOS device here (swipe horizontally), there's a kind of flash. Update: to anyone interested, I found a way to fix it thanks to Duopixel: E { -webkit-transition: all .5s ease-in-out; -webkit-transform: translate3d(0, 0, 0); // perform an "invisible" translation } // Then you can translate with translate3d(), no bug! document.querySelector('E').webkitTransform = 'translate3d(-320px, 0, 0)'

    Read the article

  • Randomly sorting an array

    - by Cam
    Does there exist an algorithm which, given an ordered list of symbols {a1, a2, a3, ..., ak}, produces in O(n) time a new list of the same symbols in a random order without bias? "Without bias" means the probability that any symbol s will end up in some position p in the list is 1/k. Assume it is possible to generate a non-biased integer from 1-k inclusive in O(1) time. Also assume that O(1) element access/mutation is possible, and that it is possible to create a new list of size k in O(k) time. In particular, I would be interested in a 'generative' algorithm. That is, I would be interested in an algorithm that has O(1) initial overhead, and then produces a new element for each slot in the list, taking O(1) time per slot. If no solution exists to the problem as described, I would still like to know about solutions that do not meet my constraints in one or more of the following ways (and/or in other ways if necessary): the time complexity is worse than O(n). the algorithm is biased with regards to the final positions of the symbols. the algorithm is not generative. I should add that this problem appears to be the same as the problem of randomly sorting the integers from 1-k, since we can sort the list of integers from 1-k and then for each integer i in the new list, we can produce the symbol ai.

    Read the article

  • [Three20] How to adjust width of TTStyledTextLabel ?

    - by Chi Zhang
    Hi I am implementing an IM app on iOS. I found that three20 library has a TTStyledTextLabel which provides cool features like showing images and url links. However I want to embed the TTStyledTextLabel in a message bubble (just like the sms app shipped with iphone does), where I need the label to adjust its size according to the text length. I found that TTStyledTextLabel can adjust its height according to its width, but I don't know how to make it shrink horizontally when the text is very short and can't fill up a whole line. Any suggestions?

    Read the article

  • Browser loading strategy, <head>...<body>

    - by Bin Chen
    I am inspecting some interesting behaviors of browser, I don't know it's in standard or not. If I put everythin inside <head></head>, the browser will only begin to render the page after all the resouces in head is retrieved. So I am thinking that put as little as possible things into head is one of the important website optimization techniques, is it right? My question is: If I put script/css in body or other parts of the html, how can I know that script has been loaded successfully so that I will not be calling a undefined function?

    Read the article

  • Perl LWP::UserAgent mishandling UTF-8 response

    - by RedGrittyBrick
    When I use LWP::UserAgent to retrieve content encoded in UTF-8 it seems LWP::UserAgent doesn't handle the encoding correctly. Here's the output after setting the Command Prompt window to Unicode by the command chcp 65001 Note that this initially gives the appearance that all is well, but I think it's just the shell reassembling bytes and decoding UTF-8, From the other output you can see that perl itself is not handling wide characters correctly. C:\perl getutf8.pl ====================================================================== HTTP/1.1 200 OK Connection: close Date: Fri, 31 Dec 2010 19:24:04 GMT Accept-Ranges: bytes Server: Apache/2.2.8 (Win32) PHP/5.2.6 Content-Length: 75 Content-Type: application/xml; charset=utf-8 Last-Modified: Fri, 31 Dec 2010 19:20:18 GMT Client-Date: Fri, 31 Dec 2010 19:24:04 GMT Client-Peer: 127.0.0.1:80 Client-Response-Num: 1 <?xml version="1.0" encoding="UTF-8"? <nameBudejovický Budvar</name ====================================================================== response content length is 33 ....v....1....v....2....v....3....v....4 <nameBudejovický Budvar</name . . . . v . . . . 1 . . . . v . . . . 2 . . . . v . . . . 3 . . . . 3c6e616d653e427564c49b6a6f7669636bc3bd204275647661723c2f6e616d653e < n a m e B u d ? ? j o v i c k ? ? B u d v a r < / n a m e Above you can see the payload length is 31 characters but Perl thinks it is 33. For confirmation, in the hex, we can see that the UTF-8 sequences c49b and c3bd are being interpreted as four separate characters and not as two Unicode characters. Here's the code #!perl use strict; use warnings; use LWP::UserAgent; my $ua = LWP::UserAgent-new(); my $response = $ua-get('http://localhost/Bud.xml'); if (! $response-is_success) { die $response-status_line; } print '='x70,"\n",$response-as_string(), '='x70,"\n"; my $r = $response-decoded_content((charset = 'UTF-8')); $/ = "\x0d\x0a"; # seems to be \x0a otherwise! chomp($r); # Remove any xml prologue $r =~ s/^<\?.*\?\x0d\x0a//; print "Response content length is ", length($r), "\n\n"; print "....v....1....v....2....v....3....v....4\n"; print $r,"\n"; print ". . . . v . . . . 1 . . . . v . . . . 2 . . . . v . . . . 3 . . . . \n"; print unpack("H*", $r), "\n"; print join(" ", split("", $r)), "\n"; Note that Bud.xml is UTF-8 encoded without a BOM. How can I persuade LWP::UserAgent to do the right thing? P.S. Ultimately I want to translate the Unicode data into an ASCII encoding, even if it means replacing each non-ASCII character with one question mark or other marker. I have accepted Ysth's "upgrade" answer - because I know it is the right thing to do when possible. However I am going to use a work-around (which may depress Tom further): $r = encode("cp437", decode("utf8", $r));

    Read the article

  • Win XP error 0x80041003 using GetObject/winmgmts

    - by John Lewis
    My computer is called "neil" and I want to set some values using WMI in vbScript. I adapetd the script below from one supplied by Microsoft. When I run it in my browser I get Error Type: (0x80041003) /dressage/30/pdf2.asp, line 8 I suspect it is some registry/security setting. Any advice? John Lewis FULL SCRIPT call Print_HTML_Page("http://neil/dressage/ascii.asp", "ascii") Sub SetPDFFile(strPDFFile) Const HKEY_LOCAL_MACHINE = &H80000002 strKeyPath = "SOFTWARE\Dane Prairie Systems\Win2PDF" strComputer = "." Set objReg=GetObject( _ "winmgmts:{impersonationLevel=impersonate}!\\" & _ strComputer & "\root\default:StdRegProv") strValueName = "PDFFileName" objReg.SetExpandedStringValue HKEY_LOCAL_MACHINE,_ strKeyPath,strValueName,strPDFFile End Sub Sub Print_HTML_Page(strPathToPage, strPDFFile) SetPDFFile( strPDFFile ) Set objIE = CreateObject("InternetExplorer.Application") 'From http://www.tek-tips.com/viewthread.cfm?qid=1092473&page=5 On Error Resume Next strPrintStatus = objIE.QueryStatusWB(6) If Err.Number 0 Then MsgBox "Cannot find a printer. Operation aborted." objIE.Quit Set objIE = Nothing Exit Sub End If With objIE .visible=0 .left=200 .top=200 .height=400 .width=400 .menubar=0 .toolbar=1 .statusBar=0 .navigate strPathToPage End With 'Wait until IE has finished loading Do while objIE.busy WScript.Sleep 100 Loop On Error Goto 0 objIE.ExecWB 6,2 'Wait until IE has finished printing WScript.Sleep 2000 objIE.Quit Set objIE = Nothing End Sub

    Read the article

< Previous Page | 6 7 8 9 10 11 12 13 14 15 16 17  | Next Page >