Daily Archives

Articles indexed Monday June 24 2013

Page 17/22 | < Previous Page | 13 14 15 16 17 18 19 20 21 22  | Next Page >

  • Unexpected output using subprocess in Python

    - by Vic
    I am trying to run a shell command from within my Python (version 2.6.5) code, but it is generating different output than the same command run within the shell (bash): bash: ~> ifconfig eth0 | sed -rn 's/inet addr:(([0-9]{1,3}\.){3}[0-9]{1,3}).*/\1/p' | sed 's/^[ \t]*//;s/[ \t]*$//' 192.168.1.10 Python: >>> def get_ip(): ... cmd_string = "ifconfig eth0 | sed -rn \'s/inet addr:(([0-9]{1,3}\.){3}[0-9]{1,3}).*/\1/p' | sed 's/^[ \t]*//;s/[ \t]*$//\'" ... process = subprocess.Popen(cmd_string, shell=True, stdout=subprocess.PIPE) ... out, err = process.communicate() ... return out ... >>> get_ip() '\x01\n' My guess is that I need to escape the quotes somehow when running in python, but I am not sure how to go about this. NOTE: I cannot install additional modules or update python on the machine that this code needs to be run on. It needs to work as-is with Python 2.6.5 and the standard library.

    Read the article

  • How To: Custom HTML / CSS Text Button for "Facebook like" & "Twitter Follow"

    - by 1Line
    So i have had a little hunt online about creating custom Facebook like buttons and custom twitter follow button but not really found a solution so thought i would ask here and see if anyone knows of a solution for this (currently i have coded some jQuery to get Facebook and Twitter counts using JSON which works but want some custom buttons as per below) I have the count working all ok, just need to tackle the like and follow buttons - it is done in jquery at the moment so would like to continue to use that if this has to be done via that. at the moment i use the API for each to get the count, if i can integrate into the current js i have to get the calls / functions i require would be good: // grab from facebook var facebook = $.getJSON('https://graph.facebook.com/'+f_page+'?callback=?', function(data) { fb_count = data['likes'].toString(); fb_count_gt = data['likes'].toString(); fb_count = add_commas(fb_count); $('#fb_count').html(fb_count); }); // grab from twitter var twitter = $.getJSON("https://twitter.com/users/"+t_page+".json?callback=?",function(data) { twit_count = data['followers_count'].toString(); twit_count_gt = data['followers_count'].toString(); twit_count = add_commas(twit_count); $('#twitter_count').html(twit_count); }); Thanks in advance!

    Read the article

  • Combining array values in multilevel array

    - by James Huckabone
    I have an array like so: array( 'a'=>array( 'a'=>3, 'f'=>5, 'sdf'=>0), 't'=>array( 'a'=>1, 'f'=>2, 'sdf'=>5), 'pps'=>array( 'a'=>1, 'f'=>2, 'sdf'=>3) ); Notice how the sub-arrays are the same for each top-level array. If I wanted to, what's the easiest way to combine the sub-arrays so that I'm left with a one-dimensional array like: array( 'a'=>5, 'f'=>9, 'sdf'=>8 );

    Read the article

  • Some ASP.NET and Access

    - by Fazleh
    Good Day all, I have a big problem but i think its minor for you guys in Stackoverflow. I am creating a web application that has two main parts. The Payment part and Requisition part. It backbone is using access and the script is in ASP.NET. I managed to sort out most of the application. But I have been having a few problems. I have pasted the link to the project in http://www.mediafire.com/download/p09fefreifidud3/Inyatsi.rar so it will be easy for someone to see what I am blabbing about. Now for my problems: The AddRequisition.aspx/AddPayment.aspx: both have a reference number. I wanted it to be unique number(but not a primary key). I wanted it to be in the following format: DDMMYY(TransactionNo)(UserID) eg: 24061101PK. I have tried and tried but have not been able to sort it out. The AmountINWords gets the value from Amount. It converts the Amount into words. Thats not all. It picks what currncy was picked in the CurrencyPaidIn and pust the respective currency inside. eg. 123.45 USD becomes One Hundred and twenty three dollars and forty five cents. I tried using queries but as you will see that went all wrong. Those are the only two things that I cant seem to get my head around. I do know that there are some things that are not conventional ASP.NET and some text boxes are not the right size. I was thinking of sorting out those after I get those two fixed because they are simple to do. I really need some help with this application please. If someone can just have a look at the code and add a few things here and there. Thanks in advance. Faz

    Read the article

  • Zend Framework 2 without MVC

    - by Luke
    I'm currently using Zend Framework 2 for all my web tier development using the MVC module that's shipped with the framework. However, I want to implement my business logic in a separate layer, call it the business tier which is a non HTTP layer and expose it through AMQP, and I'd like to reuse my knowledge of PHP for implementing this. Since there is a lot of "stuff" that I need in this business layer such as configuration, a service manager, database access, etc, etc, I'd like to use all the goodies shipped with Zend Framework 2 for this. Are there any examples or tutorials out there on how to build a Zend Framework 2 application that is not build for the web tier and doesn't require the MVC module?

    Read the article

  • Image not loading onto JPanel?

    - by None None
    I have been trying to figure out how to add an image to a JPanel as a background, but still have complete control over the placing of JButtons, JLabels, and etc. This is one method I found, but it is crashing and not loading the image or buttons. Here is the code: import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JButton; import java.awt.BorderLayout; import java.awt.FlowLayout; import java.awt.GridLayout; public class PanelDemo extends JFrame { private static final long serialVersionUID = 1L; private JButton btn1 = new JButton("EASY"); private JButton btn2 = new JButton("MEDIUM"); private JButton btn3 = new JButton("HARD"); private JButton btn4 = new JButton("High Score"); public PanelDemo() { super("Image Panel Demo"); JPanel panel = new ImagePanel( new FlowLayout(FlowLayout.CENTER, 50, 180)); JPanel panelbtn = new JPanel(new GridLayout(4, 1)); btn1.setBackground(new java.awt.Color(0, 0, 0)); btn1.setFont(new java.awt.Font("Showcard Gothic", 1, 24)); btn1.setForeground(new java.awt.Color(0, 255, 102)); btn2.setBackground(new java.awt.Color(0, 0, 0)); btn2.setFont(new java.awt.Font("Showcard Gothic", 1, 24)); btn2.setForeground(new java.awt.Color(0, 255, 102)); btn3.setBackground(new java.awt.Color(0, 0, 0)); btn3.setFont(new java.awt.Font("Showcard Gothic", 1, 24)); btn3.setForeground(new java.awt.Color(0, 255, 102)); btn4.setBackground(new java.awt.Color(0, 0, 0)); btn4.setFont(new java.awt.Font("Showcard Gothic", 1, 24)); btn4.setForeground(new java.awt.Color(0, 255, 102)); panel.add(panelbtn); panelbtn.add(btn1); panelbtn.add(btn2); panelbtn.add(btn3); panelbtn.add(btn4); add(panel, BorderLayout.CENTER); setSize(640, 480); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } public static void main(String... args) { new PanelDemo().setVisible(true); } } ImagePanel.java import java.awt.Graphics; import java.awt.Image; import java.awt.LayoutManager; import javax.swing.ImageIcon; import javax.swing.JPanel; public class ImagePanel extends JPanel { private static final long serialVersionUID = 1L; String imageFile = "/rsc/img/background.jpg"; public ImagePanel() { super(); } public ImagePanel(String image) { super(); this.imageFile = image; } public ImagePanel(LayoutManager layout) { super(layout); } public void paintComponent(Graphics g) { ImageIcon imageicon = new ImageIcon(getClass().getResource(imageFile)); Image image = imageicon.getImage(); super.paintComponent(g); if (image != null) g.drawImage(image, 0, 0, getWidth(), getHeight(), this); } } Error: Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at javax.swing.ImageIcon.<init>(Unknown Source) at ImagePanel.paintComponent(ImagePanel.java:27) at javax.swing.JComponent.paint(Unknown Source) at javax.swing.JComponent.paintChildren(Unknown Source) at javax.swing.JComponent.paint(Unknown Source) at javax.swing.JComponent.paintChildren(Unknown Source) at javax.swing.JComponent.paint(Unknown Source) at javax.swing.JLayeredPane.paint(Unknown Source) at javax.swing.JComponent.paintChildren(Unknown Source) at javax.swing.JComponent.paintToOffscreen(Unknown Source) at javax.swing.RepaintManager$PaintManager.paintDoubleBuffered(Unknown Source) at javax.swing.RepaintManager$PaintManager.paint(Unknown Source) at javax.swing.RepaintManager.paint(Unknown Source) at javax.swing.JComponent.paint(Unknown Source) at java.awt.GraphicsCallback$PaintCallback.run(Unknown Source) at sun.awt.SunGraphicsCallback.runOneComponent(Unknown Source) at sun.awt.SunGraphicsCallback.runComponents(Unknown Source) at java.awt.Container.paint(Unknown Source) at java.awt.Window.paint(Unknown Source) at javax.swing.RepaintManager$3.run(Unknown Source) at javax.swing.RepaintManager$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source) at javax.swing.RepaintManager.paintDirtyRegions(Unknown Source) at javax.swing.RepaintManager.prePaintDirtyRegions(Unknown Source) at javax.swing.RepaintManager.access$1000(Unknown Source) at javax.swing.RepaintManager$ProcessingRunnable.run(Unknown Source) at java.awt.event.InvocationEvent.dispatch(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$200(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source) Also, if anyone knows of a better way to put a background image on a JPanel, pease do tell. Thank you in advance.

    Read the article

  • pylab.savefig() and pylab.show() image difference

    - by Jack1990
    I'm making an script to automatically create plots from .xvg files, but there's a problem when I'm trying to use pylab's savefig() method. Using pylab.show() and saving from there, everything's fine. Using pylab.show() Using pylab.savefig() def producePlot(timestep, energy_values,type_line = 'r', jump = 1,finish = 100): fc = sp.interp1d(timestep[::jump], energy_values[::jump],kind='cubic') xnew = numpy.linspace(0, finish, finish*2) pylab.plot(xnew, fc(xnew),type_line) pylab.xlabel('Time in ps ') pylab.ylabel('kJ/mol') pylab.xlim(xmin=0, xmax=finish) def produceSimplePlot(timestep, energy_values,type_line = 'r', jump = 1,finish = 100): pylab.plot(timestep, energy_values,type_line) pylab.xlabel('Time in ps ') pylab.ylabel('kJ/mol') pylab.xlim(xmin=0, xmax=finish) def linearRegression(timestep, energy_values, type_line = 'g'): #, jump = 1,finish = 100): from scipy import stats import numpy #print 'fuck' timestep = numpy.asarray(timestep) slope, intercept, r_value, p_value, std_err = stats.linregress(timestep,energy_values) line = slope*timestep+intercept pylab.plot(timestep, line, type_line) def plottingTime(Title,file_name, timestep, energy_values ,loc, jump , finish): pylab.title(Title) producePlot(timestep,energy_values, 'b',jump, finish) linearRegression(timestep,energy_values) import numpy Average = numpy.average(energy_values) #print Average pylab.legend(("Average = %.2f" %(Average),'Linear Reg'),loc) #pylab.show() pylab.savefig('%s.jpg' %file_name[:-4], bbox_inches= None, pad_inches=0) #if __name__ == '__main__': #plottingTime(Title,timestep1, energy_values, jump =10, finish = 4800) def specialCase(Title,file_name, timestep, energy_values,loc, jump, finish): #print 'Working here ...?' pylab.title(Title) producePlot(timestep,energy_values, 'b',jump, finish) import numpy from pylab import * Average = numpy.average(energy_values) #print Average pylab.legend(("Average = %.2g" %(Average), Title),loc) locs,labels = yticks() yticks(locs, map(lambda x: "%.3g" % x, locs)) #pylab.show() pylab.savefig('%s.jpg' %file_name[:-4] , bbox_inches= None, pad_inches=0) Thanks in advance, John

    Read the article

  • Will a Response.Redirect exception go to global.asax?

    - by mgmedick
    I'm aware that when you call Response.Redirect it fires a ThreadAbortException. A co-worker has demonstrated calling response.redirect and then it goes to the global.asax. For the life of me I cannot get the ThreadAbortException to go to the global.asax, its like it is being suppressed naturally in the system. The reason I'm asking this is we believe the response.redirect is the cause of some automated error emails, but I'm not convinced this is the case especially if I can't even get it to debug into the global.asax. Any Ideas why I can't get the Response.Redirect to fire the global error handler?

    Read the article

  • MongoDB with OR and Range Indexes

    - by LMH
    I have a query: {"$query"=>{"user_id"=>"512f7960534dcda22b000491", "$or"=>[{"when_tz"=>{"$gte"=>2010-06-24 04:00:00 UTC, "$lt"=>2010-06-25 04:00:00 UTC}}, {"when_tz"=>{"$gte"=>2011-06-24 04:00:00 UTC, "$lt"=>2011-06-25 04:00:00 UTC}}, {"when_tz"=>{"$gte"=>2012-06-24 04:00:00 UTC, "$lt"=>2012-06-25 04:00:00 UTC}}], "_type"=>{"$in"=>["FacebookImageItem", "FoursquareImageItem", "InstagramItem", "TwitterImageItem", "Image"]}}, "$explain"=>true, "$orderby"=>{"when_tz"=>1}} And an index: { user_id: 1, _type: 1, when_tz: 1 } Explain: {"cursor"="BtreeCursor user_id_1__type_1_facebook_id_1 multi", "isMultiKey"=false, "n"=28, "nscannedObjects"=15094, "nscanned"=15098, "nscannedObjectsAllPlans"=181246, "nscannedAllPlans"=241553, "scanAndOrder"=true, "indexOnly"=false, "nYields"=12, "nChunkSkips"=0, "millis"=2869, "indexBounds"={"user_id"=[["512f7960534dcda22b000491", "512f7960534dcda22b000491"]], "_type"=[["FacebookImageItem", "FacebookImageItem"], ["FoursquareImageItem", "FoursquareImageItem"], ["Image", "Image"], ["InstagramItem", "InstagramItem"], ["TwitterImageItem", "TwitterImageItem"]], "facebook_id"=[[{"$minElement"=1}, {"$maxElement"=1}]]}, "allPlans"=[{"cursor"="BtreeCursor user_id_1__type_1_facebook_id_1 multi", "n"=28, "nscannedObjects"=15094, "nscanned"=15098, "indexBounds"={"user_id"=[["512f7960534dcda22b000491", "512f7960534dcda22b000491"]], "_type"=[["FacebookImageItem", "FacebookImageItem"], ["FoursquareImageItem", "FoursquareImageItem"], ["Image", "Image"], ["InstagramItem", "InstagramItem"], ["TwitterImageItem", "TwitterImageItem"]], "facebook_id"=[[{"$minElement"=1}, {"$maxElement"=1}]]}}, {"cursor"="BtreeCursor user_id_1__type_1_twitter_id_1 multi", "n"=28, "nscannedObjects"=15094, "nscanned"=15097, "indexBounds"={"user_id"=[["512f7960534dcda22b000491", "512f7960534dcda22b000491"]], "_type"=[["FacebookImageItem", "FacebookImageItem"], ["FoursquareImageItem", "FoursquareImageItem"], ["Image", "Image"], ["InstagramItem", "InstagramItem"], ["TwitterImageItem", "TwitterImageItem"]], "twitter_id"=[[{"$minElement"=1}, {"$maxElement"=1}]]}}, {"cursor"="BtreeCursor user_id_1__type_1_instagram_id_1 multi", "n"=28, "nscannedObjects"=15094, "nscanned"=15097, "indexBounds"={"user_id"=[["512f7960534dcda22b000491", "512f7960534dcda22b000491"]], "_type"=[["FacebookImageItem", "FacebookImageItem"], ["FoursquareImageItem", "FoursquareImageItem"], ["Image", "Image"], ["InstagramItem", "InstagramItem"], ["TwitterImageItem", "TwitterImageItem"]], "instagram_id"=[[{"$minElement"=1}, {"$maxElement"=1}]]}}, {"cursor"="BtreeCursor user_id_1__type_1_foursquare_id_1 multi", "n"=28, "nscannedObjects"=15094, "nscanned"=15097, "indexBounds"={"user_id"=[["512f7960534dcda22b000491", "512f7960534dcda22b000491"]], "_type"=[["FacebookImageItem", "FacebookImageItem"], ["FoursquareImageItem", "FoursquareImageItem"], ["Image", "Image"], ["InstagramItem", "InstagramItem"], ["TwitterImageItem", "TwitterImageItem"]], "foursquare_id"=[[{"$minElement"=1}, {"$maxElement"=1}]]}}, {"cursor"="BtreeCursor user_id_1_phash_1", "n"=21, "nscannedObjects"=15097, "nscanned"=15097, "indexBounds"={"user_id"=[["512f7960534dcda22b000491", "512f7960534dcda22b000491"]], "phash"=[[{"$minElement"=1}, {"$maxElement"=1}]]}}, {"cursor"="BtreeCursor user_id_1_aperature_1_shutter_speed_1_when_tz_1", "n"=25, "nscannedObjects"=35, "nscanned"=15097, "indexBounds"={"user_id"=[["512f7960534dcda22b000491", "512f7960534dcda22b000491"]], "aperature"=[[{"$minElement"=1}, {"$maxElement"=1}]], "shutter_speed"=[[{"$minElement"=1}, {"$maxElement"=1}]], "when_tz"=[[{"$minElement"=1}, {"$maxElement"=1}]]}}, {"cursor"="BtreeCursor user_id_1_image_hash_1", "n"=22, "nscannedObjects"=15097, "nscanned"=15097, "indexBounds"={"user_id"=[["512f7960534dcda22b000491", "512f7960534dcda22b000491"]], "image_hash"=[[{"$minElement"=1}, {"$maxElement"=1}]]}}, {"cursor"="BtreeCursor user_id_1_time_zone_guessed_1_when_tz_-1", "n"=23, "nscannedObjects"=32, "nscanned"=15097, "indexBounds"={"user_id"=[["512f7960534dcda22b000491", "512f7960534dcda22b000491"]], "time_zone_guessed"=[[{"$minElement"=1}, {"$maxElement"=1}]], "when_tz"=[[{"$maxElement"=1}, {"$minElement"=1}]]}}, {"cursor"="BtreeCursor user_id_1_time_zone_guessed_1_when_tz_1", "n"=24, "nscannedObjects"=33, "nscanned"=15097, "indexBounds"={"user_id"=[["512f7960534dcda22b000491", "512f7960534dcda22b000491"]], "time_zone_guessed"=[[{"$minElement"=1}, {"$maxElement"=1}]], "when_tz"=[[{"$minElement"=1}, {"$maxElement"=1}]]}}, {"cursor"="BtreeCursor user_id_1_time_zone_guessed_1_when_utc_-1", "n"=23, "nscannedObjects"=15097, "nscanned"=15097, "indexBounds"={"user_id"=[["512f7960534dcda22b000491", "512f7960534dcda22b000491"]], "time_zone_guessed"=[[{"$minElement"=1}, {"$maxElement"=1}]], "when_utc"=[[{"$maxElement"=1}, {"$minElement"=1}]]}}, {"cursor"="BtreeCursor user_id_1_time_zone_guessed_1_when_utc_1", "n"=24, "nscannedObjects"=15097, "nscanned"=15097, "indexBounds"={"user_id"=[["512f7960534dcda22b000491", "512f7960534dcda22b000491"]], "time_zone_guessed"=[[{"$minElement"=1}, {"$maxElement"=1}]], "when_utc"=[[{"$minElement"=1}, {"$maxElement"=1}]]}}, {"cursor"="BtreeCursor user_id_1_original_shared_item_id_1", "n"=24, "nscannedObjects"=15097, "nscanned"=15097, "indexBounds"={"user_id"=[["512f7960534dcda22b000491", "512f7960534dcda22b000491"]], "original_shared_item_id"=[[{"$minElement"=1}, {"$maxElement"=1}]]}}, {"cursor"="BtreeCursor user_id_1__type_1_s3_tmp_file_1 multi", "n"=28, "nscannedObjects"=15094, "nscanned"=15097, "indexBounds"={"user_id"=[["512f7960534dcda22b000491", "512f7960534dcda22b000491"]], "_type"=[["FacebookImageItem", "FacebookImageItem"], ["FoursquareImageItem", "FoursquareImageItem"], ["Image", "Image"], ["InstagramItem", "InstagramItem"], ["TwitterImageItem", "TwitterImageItem"]], "s3_tmp_file"=[[{"$minElement"=1}, {"$maxElement"=1}]]}}, {"cursor"="BtreeCursor user_id_1__type_1_processed_-1_uploaded_-1_image_device_1 multi", "n"=28, "nscannedObjects"=15094, "nscanned"=15097, "indexBounds"={"user_id"=[["512f7960534dcda22b000491", "512f7960534dcda22b000491"]], "_type"=[["FacebookImageItem", "FacebookImageItem"], ["FoursquareImageItem", "FoursquareImageItem"], ["Image", "Image"], ["InstagramItem", "InstagramItem"], ["TwitterImageItem", "TwitterImageItem"]], "processed"=[[{"$maxElement"=1}, {"$minElement"=1}]], "uploaded"=[[{"$maxElement"=1}, {"$minElement"=1}]], "image_device"=[[{"$minElement"=1}, {"$maxElement"=1}]]}}, {"cursor"="BtreeCursor user_id_1__type_1_when_tz_1 multi", "n"=28, "nscannedObjects"=28, "nscanned"=15097, "indexBounds"={"user_id"=[["512f7960534dcda22b000491", "512f7960534dcda22b000491"]], "_type"=[["FacebookImageItem", "FacebookImageItem"], ["FoursquareImageItem", "FoursquareImageItem"], ["Image", "Image"], ["InstagramItem", "InstagramItem"], ["TwitterImageItem", "TwitterImageItem"]], "when_tz"=[[{"$minElement"=1}, {"$maxElement"=1}]]}}, {"cursor"="BasicCursor", "n"=0, "nscannedObjects"=15097, "nscanned"=15097, "indexBounds"={}}], "server"=""} Any idea how to get it to hit the indexes?

    Read the article

  • Canceling in Sqlite

    - by Yusuf
    I am trying to use handle database with insert, update, and delete such as notepad. I'm having problems in canceling data .In normal case which presses the confirm button, it will be saved into sqlite and will be displayed on listview. How can I make cancel event through back key or more button event? I want my Button and back key to cancel data but its keep on saving... public static int numTitle = 1; public static String curDate = ""; private EditText mTitleText; private EditText mBodyText; private Long mRowId; private NotesDbAdapter mDbHelper; private TextView mDateText; private boolean isOnBackeyPressed; public SQLiteDatabase db; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mDbHelper = new NotesDbAdapter(this); mDbHelper.open(); setContentView(R.layout.note_edit); setTitle(R.string.edit_note); mTitleText = (EditText) findViewById(R.id.etTitle_NE); mBodyText = (EditText) findViewById(R.id.etBody_NE); mDateText = (TextView) findViewById(R.id.tvDate_NE); long msTime = System.currentTimeMillis(); Date curDateTime = new Date(msTime); SimpleDateFormat formatter = new SimpleDateFormat("d'/'M'/'y"); curDate = formatter.format(curDateTime); mDateText.setText("" + curDate); Button confirmButton = (Button) findViewById(R.id.bSave_NE); Button cancelButton = (Button) findViewById(R.id.bCancel_NE); Button deleteButton = (Button) findViewById(R.id.bDelete_NE); mRowId = (savedInstanceState == null) ? null : (Long) savedInstanceState .getSerializable(NotesDbAdapter.KEY_ROWID); if (mRowId == null) { Bundle extras = getIntent().getExtras(); mRowId = extras != null ? extras.getLong(NotesDbAdapter.KEY_ROWID) : null; } populateFields(); confirmButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { setResult(RESULT_OK); Toast.makeText(NoteEdit.this, "Saved", Toast.LENGTH_SHORT) .show(); finish(); } }); deleteButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub mDbHelper.deleteNote(mRowId); Toast.makeText(NoteEdit.this, "Deleted", Toast.LENGTH_SHORT) .show(); finish(); } }); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // TODO Auto-generated method stub boolean diditwork = true; try { db.beginTransaction(); populateFields(); db.setTransactionSuccessful(); } catch (SQLException e) { diditwork = false; } finally { db.endTransaction(); if (diditwork) { Toast.makeText(NoteEdit.this, "Canceled", Toast.LENGTH_SHORT).show(); } } } }); } private void populateFields() { if (mRowId != null) { Cursor note = mDbHelper.fetchNote(mRowId); startManagingCursor(note); mTitleText.setText(note.getString(note .getColumnIndexOrThrow(NotesDbAdapter.KEY_TITLE))); mBodyText.setText(note.getString(note .getColumnIndexOrThrow(NotesDbAdapter.KEY_BODY))); } } @Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); saveState(); outState.putSerializable(NotesDbAdapter.KEY_ROWID, mRowId); } public void onBackPressed() { super.onBackPressed(); isOnBackeyPressed = true; finish(); } @Override protected void onPause() { super.onPause(); if (!isOnBackeyPressed) saveState(); } @Override protected void onResume() { super.onResume(); populateFields(); } private void saveState() { String title = mTitleText.getText().toString(); String body = mBodyText.getText().toString(); if (mRowId == null) { long id = mDbHelper.createNote(title, body, curDate); if (id > 0) { mRowId = id; } } else { mDbHelper.updateNote(mRowId, title, body, curDate); } }`enter code here`

    Read the article

  • XSLT Stylesheet works with a vbs script, but not Perl

    - by user2472274
    I have a program that is essentially a search application, and it exists in both VBScript and Perl form (I'm trying to make an executable with a GUI). Currently the search application outputs an HTML file, and if a section of text in the HTML is longer than twelve lines then it hides anything after that and includes a clickable More... tag. This is done in XSLT and works with VBScript. I literally copied and pasted the stylesheet into the Perl program that I'm using and it does everything right except for the More... tag. Is there any reason why it would be working with the VBScript but not Perl? I'm using XML::LibXSLT in the Perl script, and here is the template that is supposed to be creating the More... tag <xsl:template name="more"> <xsl:param name="text"/> <xsl:param name="row-id"/> <xsl:param name="cycle" select="1"/> <xsl:choose> <xsl:when test="($cycle &gt; 12) and contains($text,'&#13;')"> <span class="show" onclick="showID('SHOW{$row-id}');style.display = 'none';">More...</span> <span class="hidden" id="SHOW{$row-id}"> <xsl:call-template name="highlight"> <xsl:with-param name="text" select="$text"/> </xsl:call-template> </span> </xsl:when> <xsl:when test="contains($text,'&#13;')"> <xsl:call-template name="highlight"> <xsl:with-param name="text" select="substring-before($text,'&#13;')"/> </xsl:call-template> <xsl:text>&#13;</xsl:text> <xsl:call-template name="more"> <xsl:with-param name="text" select="substring-after($text,'&#13;')"/> <xsl:with-param name="row-id" select="$row-id"/> <xsl:with-param name="cycle" select="$cycle + 1"/> </xsl:call-template> </xsl:when> <xsl:otherwise> <xsl:call-template name="highlight"> <xsl:with-param name="text" select="$text"/> </xsl:call-template> </xsl:otherwise> </xsl:choose> </xsl:template>

    Read the article

  • Blocking error in celery

    - by dmitry
    I have no idea what's this. Python 2.7 + django-1.5.1 + httpd + rabbitmq + django-celery==3.0.17 Tasks are not executed because of some error. Below is celery's log. Maybe someone has faced it before. [2013-06-24 17:10:03,792: CRITICAL/MainProcess] Can't decode message body: AttributeError("'JoinInfo' object has no attribute '__dict__'",) (type:u'application/x-python-serialize' encoding:u'binary' raw:'\'\\x80\\x02}q\\x01(U\\x07expiresq\\x02NU\\x03utcq\\x03\\x88U\\x04argsq\\x04cdjango.contrib.auth.models\\nUser\\nq\\x05)\\x81q\\x06}q\\x07(U\\x08usernameq\\x08X\\x19\\x00\\x00\\[email protected]\\nfirst_nameq\\tX\\x05\\x00\\x00\\x00BibbyU\\tlast_nameq\\nX\\x08\\x00\\x00\\x00OffshoreU\\r_client_cacheq\\x0bccopy_reg\\n_reconstructor\\nq\\x0ccbongoregistration.models\\nClient\\nq\\rc__builtin__\\nobject\\nq\\x0eN\\x87Rq\\x0f}q\\x10(h\\nX\\x08\\x00\\x00\\x00OffshoreU\\x1bpurchase_confirmation_emailq\\x11X\\x1f\\x00\\x00\\[email protected]\\x1dpurchase_confirmation_email_1q\\x12X!\\x00\\x00\\[email protected]\\x06_stateq\\x13cdjango.db.models.base\\nModelState\\nq\\x14)\\x81q\\x15}q\\x16(U\\x06addingq\\x17\\x89U\\x02dbq\\x18U\\x07defaultq\\x19ubU\\x0buser_ptr_idq\\x1aJ\\xb4\\xa2\\x03\\x00U\\x08is_staffq\\x1b\\x89U\\x08postcodeq\\x1cX\\x08\\x00\\x00\\x00AB11 5BSU\\x0cdegree_limitq\\x1dK\\x06U\\x07messageq\\x1eX\\xd1E\\x00\\x00<table id="container" style="margin: 0px; padding: 0px; width: 100%; background-color: #ffffff;" cellspacing="0" cellpadding="0"... (22911b)'') Traceback (most recent call last): File "/opt/www/MyProject-main/eggs/kombu-2.5.10-py2.7.egg/kombu/messaging.py", line 556, in _receive_callback decoded = None if on_m else message.decode() File "/opt/www/MyProject-main/eggs/kombu-2.5.10-py2.7.egg/kombu/transport/base.py", line 147, in decode self.content_encoding, accept=self.accept) File "/opt/www/MyProject-main/eggs/kombu-2.5.10-py2.7.egg/kombu/serialization.py", line 187, in decode return decode(data) File "/opt/www/MyProject-main/eggs/kombu-2.5.10-py2.7.egg/kombu/serialization.py", line 74, in pickle_loads return load(BytesIO(s)) AttributeError: 'JoinInfo' object has no attribute '__dict__'

    Read the article

  • Ext JS 4.2.1 loading controller - best practice

    - by Hown_
    I am currently developing a Ext JS application with many views/controlers/... I am wondering myself what the best practice is for loading the JS controllers/views/and so on... currently i have my application defined like this: // enable javascript cache for debugging, otherwise Chrome breakpoints are lost Ext.Loader.setConfig({ disableCaching: false }); Ext.require('Ext.util.History'); Ext.require('app.Sitemap'); Ext.require('app.Error'); Ext.define('app.Application', { name: 'app', extend: 'Ext.app.Application', views: [ // TODO: add views here 'app.view.Viewport', 'app.view.BaseMain', 'app.view.Main', 'app.view.ApplicationHeader', //administration 'app.view.administration.User' ... ], controllers: [ 'app.controller.Viewport', 'app.controller.Main', 'app.controller.ApplicationHeader', //administration 'app.controller.administration.User', ... ], stores: [ // stores in there.. ] }); somehow this forces the client to load all my views and controllers at startup and is calling all init methods of all controllers of course.. i need to load data everytime i chnage my view.. and now i cant load it in my controllers init function. I would have to do something like this i assume: init: function () { this.control({ '#administration_User': { afterrender: this.onAfterRender } }); }, Is there a better way to do this? Or just an other event? Though the main thing i am questioning myself is if it is the best practice to load all the javascript at startup. Wouldnt it be better to only load the controllers/views/... which the client does need right now? Or should i load all the JS at startup? If i do want to load the controllers dynamicly how could i do this? I assume a would have to remove them from my application arrays (views, controllers, stores) and create an instance if i do need it and mby set the view in the controllers init?! What's best practice??

    Read the article

  • AJAX URL request doesn't work from desktop

    - by Aaron
    Running this simple AJAX with WAMP localhost I can pull JSON from a web address. $(document).ready(function(){ $.ajax({ url: 'http://time.jsontest.com/', dataType: 'jsonp', success: function(json) { console.log(json); } }); }); However I cannot connect if I try running normally through a browser, why is that? Google CDN: <src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js">

    Read the article

  • Is there any way to output the actual array in c++

    - by user2511129
    So, I'm beginning C++, with a semi-adequate background of python. In python, you make a list/array like this: x = [1, 2, 3, 4, 5, 6, 7, 8, 9] Then, to print the list, with the square brackets included, all you do is: print x That would display this: [1, 2, 3, 4, 5, 6, 7, 8, 9] How would I do the exact same thing in c++, print the brackets and the elements, in an elegant/clean fashion? NOTE I don't want just the elements of the array, I want the whole array, like this: {1, 2, 3, 4, 5, 6, 7, 8, 9} When I use this code to try to print the array, this happens: input: #include <iostream> using namespace std; int main() { int anArray[9] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; cout << anArray << endl; } The output is where in memory the array is stored in (I think this is so, correct me if I'm wrong): 0x28fedc As a sidenote, I don't know how to create an array with many different data types, such as integers, strings, and so on, so if someone can enlighten me, that'd be great! Thanks for answering my painstakingly obvious/noobish questions!

    Read the article

  • How do I work around this problem creating a virtualenv environment with a custom-build Python?

    - by Daryl Spitzer
    I need to run some code on a Linux machine with Python 2.3.4 pre-installed. I'm not on the sudoers list for that machine, so I built Python 2.6.4 into (a subdirectory in) my home directory. Then I attempted to use virtualenv (for the first time), but got: $ Python-2.6.4/python virtualenv/virtualenv.py ENV New python executable in ENV/bin/python Could not find platform dependent libraries <exec_prefix> Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] Installing setuptools......... Complete output from command /apps/users/dspitzer/ENV/bin/python -c "#!python \"\"\"Bootstrap setuptoo... " /apps/users/dspitzer/virtualen...6.egg: Could not find platform dependent libraries <exec_prefix> Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] 'import site' failed; use -v for traceback Traceback (most recent call last): File "<string>", line 67, in <module> ImportError: No module named md5 ---------------------------------------- ...Installing setuptools...done. Traceback (most recent call last): File "virtualenv/virtualenv.py", line 1488, in <module> main() File "virtualenv/virtualenv.py", line 529, in main use_distribute=options.use_distribute) File "virtualenv/virtualenv.py", line 619, in create_environment install_setuptools(py_executable, unzip=unzip_setuptools) File "virtualenv/virtualenv.py", line 361, in install_setuptools _install_req(py_executable, unzip) File "virtualenv/virtualenv.py", line 337, in _install_req cwd=cwd) File "virtualenv/virtualenv.py", line 590, in call_subprocess % (cmd_desc, proc.returncode)) OSError: Command /apps/users/dspitzer/ENV/bin/python -c "#!python \"\"\"Bootstrap setuptoo... " /apps/users/dspitzer/virtualen...6.egg failed with error code 1 Should I be setting PYTHONHOME to some value? (I intentionally named my ENV "ENV" for lack of a better name.) Not knowing if I can ignore those errors, I tried installing nose (0.11.1) into my ENV: $ cd nose-0.11.1/ $ ls AUTHORS doc/ lgpl.txt nose.egg-info/ selftest.py* bin/ examples/ MANIFEST.in nosetests.1 setup.cfg build/ functional_tests/ NEWS PKG-INFO setup.py CHANGELOG install-rpm.sh* nose/ README.txt unit_tests/ $ ~/ENV/bin/python setup.py install Could not find platform dependent libraries <exec_prefix> Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] Traceback (most recent call last): File "setup.py", line 1, in <module> from nose import __version__ as VERSION File "/apps/users/dspitzer/nose-0.11.1/nose/__init__.py", line 1, in <module> from nose.core import collector, main, run, run_exit, runmodule File "/apps/users/dspitzer/nose-0.11.1/nose/core.py", line 3, in <module> from __future__ import generators ImportError: No module named __future__ Any advice?

    Read the article

  • "Could not establish secure channel for SSL/TLS" in .NET CF application on smart phone

    - by Stefan Mohr
    I have a stubborn communications issue with an application running on the .NET Compact Framework 3.5 on Windows Mobile smartphones. I am constructing a web request using this code: UTF8Encoding encoding = new System.Text.UTF8Encoding(); byte[] Data = encoding.GetBytes(HttpUtility.ConstructQueryString(parameters)); httpRequest = WebRequest.Create((domain)) as HttpWebRequest; httpRequest.Timeout = 10000000; httpRequest.ReadWriteTimeout = 10000000; httpRequest.Credentials = CredentialCache.DefaultCredentials; httpRequest.Method = "POST"; httpRequest.ContentType = "application/x-www-form-urlencoded"; httpRequest.ContentLength = Data.Length; Stream SendReq = httpRequest.GetRequestStream(); SendReq.Write(Data, 0, Data.Length); SendReq.Close(); HttpWebResponse httpResponse = (HttpWebResponse)httpRequest.GetResponse(); return httpResponse.GetResponseStream(); The web service functions by receiving a JSON-encoded document as part of the URL (eg. https://site.com/ws/sync??document={"version":"1.0.0","items":[{"item_1":"item1"}]}&user=usr&password=pw), and as a response receives another JSON document as response data. This code runs fine on all emulators and PDAs running WM 5 and 6. We have seen an issue with a couple of customers running Treo smartphones (and only on the Sprint network). We have tested the code on an identical device on the AT&T network (via DeviceAnywhere) and once again the code worked as we expected. This has to be some sort of security policy on the phone, but we've been unable to determine a workaround or diagnose it thoroughly as we cannot reproduce it in house and have had to resort to getting users to assist with running test drivers for us. When this code executes, the user's device throws the following exception: System.Net.WebException Could not establish secure channel for SSL/TLS Stack trace: at System.Net.HttpWebRequest.finishGetRequestStream() at System.Net.HttpWebRequest.GetRequestStream() at OurApp.GetResponseStream(String domain, Hashtable parameters) inner exception: System.IO.IOException Authentication failed because the remote party has closed the transport stream. Stack trace: at System.Net.SslConnectionState.ClientSideHandshake() at System.Net.SslConnectionState.PerformClientHandShake() at System.Net.Connection.connect(Object ignored) at System.Threading.ThreadPool.WorkItem.doWork(Object o) at System.Threading.Timer.ring() Examining the server Apache logs shows no hits from the user's IP - I don't think the device is even attempting to send a packet before failing. If relevant, the server is running Apache on Linux and is written using the TurboGears Python framework. The server certificate is issued by a CA and is still valid. The test driver where this error was copied from was not code signed, however the same error (without the error messages) is signed with a GeoTrust certificate so we don't believe this is a code signing issue. The application installs and launches without issue on all phones - it's just establishing this SSL connection that is breaking for these users. One significant issue in troubleshooting is that there is a substantial inconvenience each time we try out a solution (need to find a "volunteer" customer), so we're really looking for a silver bullet or a better understanding of the handshaking process so we can be reasonably confident we only need to ask the user to test it one or two more times. One final mention: we have tried the sync both over ActiveSync and also over GPRS with identical results. Any thoughts would be greatly appreciated!

    Read the article

  • Office 365 new public sites

    - by DigiMortal
    As I got my Office365 developers benefit activated I decided to try out if public sites on SharePoint are ready for real use or not. The progress is markable and although Microsoft is extremely careful with activating functionalities on public sites there’s still lot of work done and I think it’s worth to take a look at new version of public sites. Here is my first quick overview. Read more from my new blog @ gunnarpeipman.com

    Read the article

  • Windows Azure: Major Updates for Mobile Backend Development

    - by ScottGu
    This week we released some great updates to Windows Azure that make it significantly easier to develop mobile applications that use the cloud. These new capabilities include: Mobile Services: Custom API support Mobile Services: Git Source Control support Mobile Services: Node.js NPM Module support Mobile Services: A .NET API via NuGet Mobile Services and Web Sites: Free 20MB SQL Database Option for Mobile Services and Web Sites Mobile Notification Hubs: Android Broadcast Push Notification Support All of these improvements are now available to use immediately (note: some are still in preview).  Below are more details about them. Mobile Services: Custom APIs, Git Source Control, and NuGet Windows Azure Mobile Services provides the ability to easily stand up a mobile backend that can be used to support your Windows 8, Windows Phone, iOS, Android and HTML5 client applications.  Starting with the first preview we supported the ability to easily extend your data backend logic with server side scripting that executes as part of client-side CRUD operations against your cloud back data tables. With today’s update we are extending this support even further and introducing the ability for you to also create and expose Custom APIs from your Mobile Service backend, and easily publish them to your Mobile clients without having to associate them with a data table. This capability enables a whole set of new scenarios – including the ability to work with data sources other than SQL Databases (for example: Table Services or MongoDB), broker calls to 3rd party APIs, integrate with Windows Azure Queues or Service Bus, work with custom non-JSON payloads (e.g. Windows Periodic Notifications), route client requests to services back on-premises (e.g. with the new Windows Azure BizTalk Services), or simply implement functionality that doesn’t correspond to a database operation.  The custom APIs can be written in server-side JavaScript (using Node.js) and can use Node’s NPM packages.  We will also be adding support for custom APIs written using .NET in the future as well. Creating a Custom API Adding a custom API to an existing Mobile Service is super easy.  Using the Windows Azure Management Portal you can now simply click the new “API” tab with your Mobile Service, and then click the “Create a Custom API” button to create a new Custom API within it: Give the API whatever name you want to expose, and then choose the security permissions you’d like to apply to the HTTP methods you expose within it.  You can easily lock down the HTTP verbs to your Custom API to be available to anyone, only those who have a valid application key, only authenticated users, or administrators.  Mobile Services will then enforce these permissions without you having to write any code: When you click the ok button you’ll see the new API show up in the API list.  Selecting it will enable you to edit the default script that contains some placeholder functionality: Today’s release enables Custom APIs to be written using Node.js (we will support writing Custom APIs in .NET as well in a future release), and the Custom API programming model follows the Node.js convention for modules, which is to export functions to handle HTTP requests. The default script above exposes functionality for an HTTP POST request. To support a GET, simply change the export statement accordingly.  Below is an example of some code for reading and returning data from Windows Azure Table Storage using the Azure Node API: After saving the changes, you can now call this API from any Mobile Service client application (including Windows 8, Windows Phone, iOS, Android or HTML5 with CORS). Below is the code for how you could invoke the API asynchronously from a Windows Store application using .NET and the new InvokeApiAsync method, and data-bind the results to control within your XAML:     private async void RefreshTodoItems() {         var results = await App.MobileService.InvokeApiAsync<List<TodoItem>>("todos", HttpMethod.Get, parameters: null);         ListItems.ItemsSource = new ObservableCollection<TodoItem>(results);     }    Integrating authentication and authorization with Custom APIs is really easy with Mobile Services. Just like with data requests, custom API requests enjoy the same built-in authentication and authorization support of Mobile Services (including integration with Microsoft ID, Google, Facebook and Twitter authentication providers), and it also enables you to easily integrate your Custom API code with other Mobile Service capabilities like push notifications, logging, SQL, etc. Check out our new tutorials to learn more about to use new Custom API support, and starting adding them to your app today. Mobile Services: Git Source Control Support Today’s Mobile Services update also enables source control integration with Git.  The new source control support provides a Git repository as part your Mobile Service, and it includes all of your existing Mobile Service scripts and permissions. You can clone that git repository on your local machine, make changes to any of your scripts, and then easily deploy the mobile service to production using Git. This enables a really great developer workflow that works on any developer machine (Windows, Mac and Linux). To use the new support, navigate to the dashboard for your mobile service and select the Set up source control link: If this is your first time enabling Git within Windows Azure, you will be prompted to enter the credentials you want to use to access the repository: Once you configure this, you can switch to the configure tab of your Mobile Service and you will see a Git URL you can use to use your repository: You can use this URL to clone the repository locally from your favorite command line: > git clone https://scottgutodo.scm.azure-mobile.net/ScottGuToDo.git Below is the directory structure of the repository: As you can see, the repository contains a service folder with several subfolders. Custom API scripts and associated permissions appear under the api folder as .js and .json files respectively (the .json files persist a JSON representation of the security settings for your endpoints). Similarly, table scripts and table permissions appear as .js and .json files, but since table scripts are separate per CRUD operation, they follow the naming convention of <tablename>.<operationname>.js. Finally, scheduled job scripts appear in the scheduler folder, and the shared folder is provided as a convenient location for you to store code shared by multiple scripts and a few miscellaneous things such as the APNS feedback script. Lets modify the table script todos.js file so that we have slightly better error handling when an exception occurs when we query our Table service: todos.js tableService.queryEntities(query, function(error, todoItems){     if (error) {         console.error("Error querying table: " + error);         response.send(500);     } else {         response.send(200, todoItems);     }        }); Save these changes, and now back in the command line prompt commit the changes and push them to the Mobile Services: > git add . > git commit –m "better error handling in todos.js" > git push Once deployment of the changes is complete, they will take effect immediately, and you will also see the changes be reflected in the portal: With the new Source Control feature, we’re making it really easy for you to edit your mobile service locally and push changes in an atomic fashion without sacrificing ease of use in the Windows Azure Portal. Mobile Services: NPM Module Support The new Mobile Services source control support also allows you to add any Node.js module you need in the scripts beyond the fixed set provided by Mobile Services. For example, you can easily switch to use Mongo instead of Windows Azure table in our example above. Set up Mongo DB by either purchasing a MongoLab subscription (which provides MongoDB as a Service) via the Windows Azure Store or set it up yourself on a Virtual Machine (either Windows or Linux). Then go the service folder of your local git repository and run the following command: > npm install mongoose This will add the Mongoose module to your Mobile Service scripts.  After that you can use and reference the Mongoose module in your custom API scripts to access your Mongo database: var mongoose = require('mongoose'); var schema = mongoose.Schema({ text: String, completed: Boolean });   exports.get = function (request, response) {     mongoose.connect('<your Mongo connection string> ');     TodoItemModel = mongoose.model('todoitem', schema);     TodoItemModel.find(function (err, items) {         if (err) {             console.log('error:' + err);             return response.send(500);         }         response.send(200, items);     }); }; Don’t forget to push your changes to your mobile service once you are done > git add . > git commit –m "Switched to use Mongo Labs" > git push Now our Mobile Service app is using Mongo DB! Note, with today’s update usage of custom Node.js modules is limited to Custom API scripts only. We will enable it in all scripts (including data and custom CRON tasks) shortly. New Mobile Services NuGet package, including .NET 4.5 support A few months ago we announced a new pre-release version of the Mobile Services client SDK based on portable class libraries (PCL). Today, we are excited to announce that this new library is now a stable .NET client SDK for mobile services and is no longer a pre-release package. Today’s update includes full support for Windows Store, Windows Phone 7.x, and .NET 4.5, which allows developers to use Mobile Services from ASP.NET or WPF applications. You can install and use this package today via NuGet. Mobile Services and Web Sites: Free 20MB Database for Mobile Services and Web Sites Starting today, every customer of Windows Azure gets one Free 20MB database to use for 12 months free (for both dev/test and production) with Web Sites and Mobile Services. When creating a Mobile Service or a Web Site, simply chose the new “Create a new Free 20MB database” option to take advantage of it: You can use this free SQL Database together with the 10 free Web Sites and 10 free Mobile Services you get with your Windows Azure subscription, or from any other Windows Azure VM or Cloud Service. Notification Hubs: Android Broadcast Push Notification Support Earlier this year, we introduced a new capability in Windows Azure for sending broadcast push notifications at high scale: Notification Hubs. In the initial preview of Notification Hubs you could use this support with both iOS and Windows devices.  Today we’re excited to announce new Notification Hubs support for sending push notifications to Android devices as well. Push notifications are a vital component of mobile applications.  They are critical not only in consumer apps, where they are used to increase app engagement and usage, but also in enterprise apps where up-to-date information increases employee responsiveness to business events.  You can use Notification Hubs to send push notifications to devices from any type of app (a Mobile Service, Web Site, Cloud Service or Virtual Machine). Notification Hubs provide you with the following capabilities: Cross-platform Push Notifications Support. Notification Hubs provide a common API to send push notifications to iOS, Android, or Windows Store at once.  Your app can send notifications in platform specific formats or in a platform-independent way.  Efficient Multicast. Notification Hubs are optimized to enable push notification broadcast to thousands or millions of devices with low latency.  Your server back-end can fire one message into a Notification Hub, and millions of push notifications can automatically be delivered to your users.  Devices and apps can specify a number of per-user tags when registering with a Notification Hub. These tags do not need to be pre-provisioned or disposed, and provide a very easy way to send filtered notifications to an infinite number of users/devices with a single API call.   Extreme Scale. Notification Hubs enable you to reach millions of devices without you having to re-architect or shard your application.  The pub/sub routing mechanism allows you to broadcast notifications in a super-efficient way.  This makes it incredibly easy to route and deliver notification messages to millions of users without having to build your own routing infrastructure. Usable from any Backend App. Notification Hubs can be easily integrated into any back-end server app, whether it is a Mobile Service, a Web Site, a Cloud Service or an IAAS VM. It is easy to configure Notification Hubs to send push notifications to Android. Create a new Notification Hub within the Windows Azure Management Portal (New->App Services->Service Bus->Notification Hub): Then register for Google Cloud Messaging using https://code.google.com/apis/console and obtain your API key, then simply paste that key on the Configure tab of your Notification Hub management page under the Google Cloud Messaging Settings: Then just add code to the OnCreate method of your Android app’s MainActivity class to register the device with Notification Hubs: gcm = GoogleCloudMessaging.getInstance(this); String connectionString = "<your listen access connection string>"; hub = new NotificationHub("<your notification hub name>", connectionString, this); String regid = gcm.register(SENDER_ID); hub.register(regid, "myTag"); Now you can broadcast notification from your .NET backend (or Node, Java, or PHP) to any Windows Store, Android, or iOS device registered for “myTag” tag via a single API call (you can literally broadcast messages to millions of clients you have registered with just one API call): var hubClient = NotificationHubClient.CreateClientFromConnectionString(                   “<your connection string with full access>”,                   "<your notification hub name>"); hubClient.SendGcmNativeNotification("{ 'data' : {'msg' : 'Hello from Windows Azure!' } }", "myTag”); Notification Hubs provide an extremely scalable, cross-platform, push notification infrastructure that enables you to efficiently route push notification messages to millions of mobile users and devices.  It will make enabling your push notification logic significantly simpler and more scalable, and allow you to build even better apps with it. Learn more about Notification Hubs here on MSDN . Summary The above features are now live and available to start using immediately (note: some of the services are still in preview).  If you don’t already have a Windows Azure account, you can sign-up for a free trial and start using them today.  Visit the Windows Azure Developer Center to learn more about how to build apps with it. Hope this helps, Scott P.S. In addition to blogging, I am also now using Twitter for quick updates and to share links. Follow me at: twitter.com/scottgu

    Read the article

  • ASP.Net 4.5 Garbage Collection Improvement

    - by Aligned
    Originally posted on: http://geekswithblogs.net/Aligned/archive/2013/06/24/asp.net-4.5-garbage-collection-improvement.aspxI just read Five Great .NET Framework 4.5 Features on CodeProject by Shivprasad koirala. Feature 5 in his article mentions the GC background cleanup and has a good explanation of the work the GC has to do for ASP.Net on the server. “Garbage collector is one real heavy task in a .NET application. And it becomes heavier when it is an ASP.NET application. ASP.NET applications run on the server and a lot of clients send requests to the server thus creating loads of objects, making the GC really work hard for cleaning up unwanted objects.” “To overcome the above problem, server GC was introduced. In server GC there is one more thread created which runs in the background. This thread works in the background and keeps cleaning…objects thus minimizing the load on the main GC thread. Due to double GC threads running, the main application threads are less suspended, thus increasing application throughput. To enable server GC, we need to use the gcServer XML tag and enable it to true.” <configuration> <runtime> <gcServer enabled="true"/> </runtime> </configuration> This is not done by default. The MSDN information page says “There are only two garbage collection options, workstation or server. For single-processor computers, the default workstation garbage collection should be the fastest option. Either workstation or server can be used for two-processor computers. Server garbage collection should be the fastest option for more than two processors. Use the GCSettingsIsServerGC property to determine if server garbage collection is enabled.” “In the .NET Framework 4 and earlier versions, concurrent garbage collection is not available when server garbage collection is enabled. Starting with the .NET Framework 4.5, server garbage collection is concurrent. To use non-concurrent server garbage collection, set the <gcServer> element to true and the <gcConcurrent> element to false. “ So if you’re using ASP.Net 4.5 and have a multi-core server, you should try turning on the Server Garbage Collection and do some profiling to see if it improves the performance of your site.

    Read the article

  • apache domain names are case sensitive

    - by neubert
    The following HTTP request results in a "See the error log for more details; Invalid Value Found For Domain" error: GET / HTTP/1.0 Host: www.MyWebsite.com If I make the hostname all lowercase, however, it works just fine. How can I make Apache case insensitive? Here's my httpd.conf file: <VirtualHost *:80> ServerName mywebsite.com ServerAlias www.mywebsite.com ... </VirtualHost> I tried adding ServerAlias www.MyWebsite.com to that but that didn't help. And in any event, it seems like that's a poor approach anyway since the case can be mixed up in a ton of different ways and trying to account for all of them would result in a huge *.conf file. Any ideas? Thanks!

    Read the article

  • Encrypting peer-to-peer application with iptables and stunnel

    - by Jonathan Oliver
    I'm running legacy applications in which I do not have access to the source code. These components talk to each other using plaintext on a particular port. I would like to be able to secure the communications between the two or more nodes using something like stunnel to facilitate peer-to-peer communication rather than using a more traditional (and centralized) VPN package like OpenVPN, etc. Ideally, the traffic flow would go like this: app@hostA:1234 tries to open a TCP connection to app@hostB:1234. iptables captures and redirects the traffic on port 1234 to stunnel running on hostA at port 5678. stunnel@hostA negotiates and establishes a connection with stunnel@hostB:4567. stunnel@hostB forwards any decrypted traffic to app@hostB:1234. In essence, I'm trying to set this up to where any outbound traffic (generated on the local machine) to port N forwards through stunnel to port N+1, and the receiving side receives on port N+1, decrypts, and forwards to the local application at port N. I'm not particularly concerned about losing the hostA origin IP address/machine identity when stunnel@hostB forwards to app@hostB because the communications payload contains identifying information. The other trick in this is that normally with stunnel you have a client/server architecture. But this application is much more P2P because nodes can come and go dynamically and hard-coding some kind of "connection = hostN:port" in the stunnel configuration won't work.

    Read the article

  • What CPU hardware performance counter tool do you guys use?

    - by Hao Shen
    I just want to know the popular tool that I can use. Originally, I used Perfmon2. However, recently, I installed the lastest Ubuntu 12 on my Ivy Bridge i7 machine. Then there is some compilation error for the Pfmon. :< From here http://comments.gmane.org/gmane.comp.linux.perfmon2.devel/3255 , it seems that the Perfmon2 will not work after the kernel 2.6.30. So it suggests to use perf tool. I just want to confirm is there any popular application level performance counter monitor tool which can be used for the later kernel version?

    Read the article

  • Practical way of keeping up-to-date backup servers?

    - by ftkg
    What is the approach generally used when you want to have backup physical servers? Currently I have a Linux server running a database, a samba share, a webapp and some scripts; and a Windows Server, running some third-party software. What I would like was to be able to have a ready backup server to enter in production in case of failure, but how to keep them up-to-date? I've seen some expensive solutions for Windows; for Linux I've wondered if I really have to build an array of scripts.

    Read the article

  • What are the specific uses of these hardware? [closed]

    - by vincentbelkin
    So I'm trying to learn more about databases and information systems. However I need more explanation on the specific purpose of these hardware. I'm not sure if they are servers or what. HP AlphaServer ES47 Tower Tru64 Unix Intel-Based B, Proliant ML350GA Two Intel-Based A Proliant ML570T03 Intel-Based X236 Intel Quad Core Xeon Category B X3500 Poweredge 1400 SC Btw I'm just a college student who wants to know more about these hardware

    Read the article

< Previous Page | 13 14 15 16 17 18 19 20 21 22  | Next Page >