Posts

Showing posts from April, 2013

java - How can I utilize SimpleDateFormat with Calendar? -

i've got gregoriancalendar instances , need use simpledateformat (or maybe can used calendar provides required #fromat() feature) needed output. please, suggest work arounds permanent solutions. try this: calendar cal = new gregoriancalendar(); simpledateformat dateformat = new simpledateformat("dd-mm-yyyy"); dateformat.settimezone(cal.gettimezone()); system.out.println(dateformat.format(cal.gettime()));

cocoa touch - how to integrate myspace into my iPhone App -

possible duplicate: implementation of myspace , linkedin in iphone i new iphone technology i using api in json. need integrate myspace app how can done? try this: http://code.google.com/p/myspaceid-iphone-sdk/

php - Check if a field/propertry exists in a variable of type object -

i using zend_search_lucene, index website. site indexes not entirely similar. have, few fields, , have many fields. trying create similar index through different types of table, that's why encountering kind of error. now, when display result. call fields, not present in result generates error. tried check isset seems totally skips row. foreach ($hits $hit) { $content .= '<div class="searchresult">'; $content .= '<h2>'; $title = array(); if(isset($hit -> name)) $title[] = $hit -> name; if(isset($hit -> title)) $title[] = $hit -> title; // part fatal error. $content .= implode(" &raquo; ",$title); $content .= '</h2>'; $content .= '<p>'.$this->content.'</p>'; $content .= '</div>'; } how check if there such $hit -> name present in $hit the problem experiencing v...

vb.net - Joining two tables in the dataset -

i having data set in vb.net 2 tables 1 table filled using oracle databse , 1 sql 2005. how can join these 2 tables in dataset is looking for: how join 2 datatables using c#

javascript - how to create pc calculator script in php -

i have 2 tables 1 category , 1 products. want pc calculator. i have fields generated dynamically based on database. how can write script make this. <table align=center width=100% border=1 cellspacing=1 cellpadding=3> <tr> <th>category name</th> <th>product name</th> <th>price</th> </tr> <tr class="odd"> <td>speaker</td> <td> <select name="1" size="1" id="1"> <option value="1200.00">intex</option> <option value="2100.00">creative</option> <option value="1400.00">intex 2.1</option> <option value="2000.00">intex 2.1 woofer</option> </select> </td> <td><div id="t1" class="pr...

form mysql query in php -

i've got following queries need execute in php. problem need set queries before execution of main query. set queries set @center = geomfromtext('point(33.3666667 35.1666667)'); set @radius = 1; set @bbox = concat('polygon((', x(@center) - @radius, ' ', y(@center) - @radius, ',', x(@center) + @radius, ' ', y(@center) - @radius, ',', x(@center) + @radius, ' ', y(@center) + @radius, ',', x(@center) - @radius, ' ', y(@center) + @radius, ',', x(@center) - @radius, ' ', y(@center) - @radius, '))' ); and main query select users_profile.id, glength(linestring(users_profile.location,geomfromtext('point(33.3666667 35.1666667)'))) * 100 distance users_profile intersects( users_profile.location, geomfromtext(@bbox)) , (glength(linestring(users_profile.location,geomfromtext('point(33.3666667 35.1666667)'))) * 100) < 10 order distance ho...

ghc - How to execute a command right after a fetch or pull command in git? -

i cloned ghc (glasgow haskell compiler) repository. in order build compiler, need several libraries, of them available git repositories too. in order ease ones live, ghc hackers included script sync-all that, when executed, updates dependent repositories. now question: how can make git execute ./sync-all pull after did git pull automatically? heard using hooks, don't know, have do. a post-receive or post-update hook used kind of task, executed after each push. difference between post-receive , post-update hooks in arguments: post-receive both old , new values of refs in addition names. the missing piece is: where hook executes itself? the blog post " missing git hooks documentation " (a great) contributor mark longair sheds light on this: the current working directory git directory . so, if bare repository called “ /src/git/test.git/ ”, current working directory – if non-bare repository , top level of working tree “ /home/ma...

c# - Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation error in prod server -

i getting errors in production box not getting in our local testing. not using modal dialogue popuups or not window message popups in entire popups. causing because of response.redirect? here server eventlog. can tell me causing issue? log name: application source: asp.net 2.0.50727.0 date: 4/11/2011 8:44:42 event id: 1309 task category: web event level: warning keywords: classic user: n/a computer: pacdcpccoma01.cable.comcast.com description: event code: 3005 event message: unhandled exception has occurred. event time: 4/11/2011 8:44:42 event time (utc): 4/11/2011 12:44:42 pm event id: a66a8c24117e49d4979975e947bfe021 event sequence: 49560 event occurrence: 8 event detail code: 0 application information: application domain: /lm/w3svc/1/root-1-129469890006189836 trust level: full application virtual path: / application path: c:\inetpub\wwwroot\om\ machine name: pacdcpccoma01 process informat...

jquery - Google maps page loading, but not showing the map -

<script type="text/javascript"> $(document).ready(function() { $('#tab_menu a').click(function(){ $('html, body').animate({scrolltop: '201px'}, 400); $("#ajax").empty().html('<div style="text-align:center;width:950px;height:100px;background:url(/images/white.gif) repeat-y;"><table align="center" border="0"><tr><td width="950" align="center"><img src=/images/loading.gif align=absmiddle /><br/>loading map...</td></tr></table></div>'); $('#ajax').slidedown('slow', function() { $('#ajax').load('/inmap.php?=<?=$h?>'); }); }); }); </script> when inmap.php called individually renders map fine. code above, map not show. i can call other page want without problem. whats wrong code ? note: still not show when <?=$h?...

How Do I Write Data To A SQLite Database Using Adobe Air? -

i'm absolutely struggling this. building application using adobe air allow vote on calls receive (such call sales call, complaint, or query product) , save these votes viewing later on. i've built interface radio buttons, , has compiled successfully, far i've managed get. don't know if loading database have provided , if knew don't know how write data database. i've used google , lot of websites lists don't go on how insert , retrieve data using adobe air sqlite (even though i'm lead believe database adobe have packaged it). any on grateful for. cheers have on following: https://stackoverflow.com/questions/2883989/basic-crud-in-adobe-air-flex http://www.12robots.com/index.cfm/2009/7/14/using-sqlite-databases-with-air--series-introduction http://devworks.thinkdigit.com/features/using-an-sqlite-database-in-an-air_6471.html

c# - What programming language should i learn? -

i work manufacturing company in configuration dept see alot of process related data control stuff passing me everyday. in past have developed excel vbscript programmes manage lot of data items through gui , using excel backend store results, there's far can take that. i learn how create proper databases guis, multiple user logins , workflows approval etc, have no idea start.........any advise on desktop applications or web based applications allow system used on internet when working abroad, appreciated. thanks. fergie c# , .net place start. c# easy learn , visual studios offers great development environment it. java way can go. java multiplatform , has great functionality integrating web environment.

testing - multiple user logins in jmeter -

i using jmeter test php application. need create different thread unique session each user. because in application can have 1 login per user @ time putting 100 times same user not conclusion. have created 40 users user0,user1....user39 same password there way automatically create simultaneous threads each of them? thanks you can use csv data set config. control allow use external source of variables. add -> config element -> csv data set config must set variable names, like: variable names (comma-delimited): username,password then can use variables in http requests parameters like: ${username} , ${password}

c# - Editor control that manipulates XElement objects rather than XML text -

i have program configures xml file, whenever configuration changes have re-read xml file , re-build program's state scratch. however, write subscribe each xelement.changed event, configuration can changed @ runtime without forcing me ditch state , re-create again. is there xml editor control (for wpf or mono, preferably) manipulates instances of xelement rather treating , manipulating document 1 big string? there's missing in logic. if whole configuration file important ? if - solution right - should reload whole xml file if (3d party app ?) changed xml - how know ? may same program can kick event , notice changes ? for xml using: best method using xpath , extract xmlelement or collection of elements whole xml. don't think there's method know if part of xml changed or event it. know changed should check original copy of document - understand app changing so....

qt - How to style the checkbox in a QListView so that the label is under the checkbox? -

i have horizontal qlistview , want customize checkbox , label inside stylesheet put label under checkbox, not @ right side. how can done? i'm not sure if work in case came looking similar thing (for qtreewidget checkboxes) , found works: tree_widget.setstylesheet("qtreeview::indicator:checked { background:red; }"); i imagine qlistview have indicator , can't test right now. try this: qlistview::indicator { subcontrol-position: top center; }

C# Sending multiple objects over same Socket -

i'm trying send multiple different objects (well, same object types, different values) 1 socket another. can send 1 object fine using following code: client: var buffer = new byte[1024]; var binformatter = new binaryformatter(); using (var ms = new memorystream()) { int bytesread; while ((bytesread = _clientreceive.receive(buffer)) > 0); { ms.write(buffer, 0, bytesread); } ms.position = 0; message = (message)binformatter.deserialize(ms); } server: var gm = new message { message = "objecttype", object = data }; using (var mem = new memorystream()) { var binformatter = new binaryformatter(); binformatter.serialize(mem, gm); var gmdata = mem.toarray(); client.send(gmdata, gmdata.length, socketflags.none); client.close(); } but if want send multiple messages (put full client code in loop , not call client.close() ) how able determine when full object has been received client? putting client code in loo...

security - Android Java SFTP / SSH -

i'm making small android app 1 of secure servers (which has random root password generated every 5 mins first few characters known user, random part of password stored in .txt file on server under user 1 can view random part of password.) need android app connect secret user on sftp or ssh (secure) retrive random password display user able login system. this own cheap version of 2 factor authentication. i'm new android development can't find sftp libraries connection. can help? thanks dave https://github.com/kruton/connectbot/tree/master/src/com/trilead/ssh2 can use link further information may :)

asp.net mvc 3 - A question regarding DB Images - -

a clarification, if have table has following fields.... productcategoryid, categoryname, image1, image2, image3, image4 , image5 have data types varbinary(max) , imagemimetype has data type varchar(50). difference if have 2 tables following... (for simplicity sake) table 1 - productcategoryid, categoryname table 2 - productcategoryid, imageid, image1, image2, image3, image4 image5 imagemimetype i read somewhere images should placed in separate table performance & corruption prevention. or doesn't matter? there pro's & cons? using asp.net mvc3 c#, sql server 2008r2. thanks if images large, consider configuring database store files using filestream. may make big difference. having image columns in different tables won't matter then, because they'll stored in different filegroup. said, should normalize see fit. info on filestream: http://msdn.microsoft.com/en-us/library/cc949109(v=sql.100).aspx http://www.aghausman.net/sql_se...

c# - Convert string into MongoDB BsonDocument -

i have long string in json format, , want convert bsondocument insertion mongodb database. how do conversion? i'm using official c# driver. the answer is: string json = "{ 'foo' : 'bar' }"; mongodb.bson.bsondocument document = mongodb.bson.serialization.bsonserializer.deserialize<bsondocument>(json);

android - Porting a portrait-only app to work for both screen orientations -

this general query. beginning port portrait-only app work both landscape , portrait screen orientations. there document addresses process specifically? using native views - not expecting issues resources files such drawables, etc have 1 screen in application plays video clips - fear how make video keep playing while orientation changes. also, wondering if have save activity states/variables while orientation occurs. so, these of concerns , wondering if there thumbrules or documentation read on before plunging porting. thanks in advance. you should read application fundamentals , happens while orienting application. http://developer.android.com/guide/topics/fundamentals.html if want faster orientation change can read document http://developer.android.com/resources/articles/faster-screen-orientation-change.html if keep variables static in activity can them in method want automatically.

save - android using media scanner for SD card -

hi im trying save image sdcard , im having problem using media scanner scan new saved file available the errors in following lines new string[] { file.tostring() }, null, // error: file cannot resolved new mediascannerconnection.onscancompletedlistener() { // error: mediascannerconnection.onscancompletedlistener cannot resolved type this code: public void savetosdcard(bitmap bitmap, string name) { boolean mexternalstorageavailable = false; boolean mexternalstoragewriteable = false; string state = environment.getexternalstoragestate(); if (environment.media_mounted.equals(state)) { mexternalstorageavailable = mexternalstoragewriteable = true; log.v(tag, "sd card available read , write " + mexternalstorageavailable + mexternalstoragewriteable); savefile(bitmap, name); } else if (environment.media_mounted_read_only.equals(state)) { mexternalstorageavailable ...

java - show data from jTable in jFrame -

i have jframe2 contains jtable 4 columns (the jtable taking data table in database contain 20 columns) have jframe1 have used fill database. want when select row in jtable , click jbutton, must open jframe1 showing data row. clear want in points *i want open jframe1 jframe2 via jbutton(this task done , code) public void actionperformed(actionevent e) { if(e.getsource()==jbutton2){ jframe2 regface =new jframe2(); regface.setvisible(true); }} *once jframe1 opened jbutton in jframe2 must show in fields data of selected row in jframe2>>this point mean ........-sql query executed once jfram1 opened jbutton in jframe2 .........-showing data in jtextfield taking database query mentioned in line above (this task done , code not completed) try { dbconnect = new mydbconnection(); resultset resultset =null; resultset = dbconnect.excutequery("select id, area,location, status1 pledges id='17'"); while (r...

php - Why am I getting this error with socket_read()? -

i have following code: http://pastebin.com/u9qysmet when try telnet server , port with telnet localhost 6667 i following error: php warning: socket_read(): unable read socket [107]: transport endpoint not connected in /var/www/php-irc/proxy.php on line 91 anyone have ideas why i'm getting error? code: <?php if(!defined('socket_address')) { define('socket_address', '127.0.0.1'); } if(!defined('socket_port')) { define('socket_port', '6667'); } if(!defined('max_clients')) { define('max_clients', '10'); } set_time_limit(0); $socket = socket_create(af_inet, sock_stream, sol_tcp); socket_set_option($socket, sol_socket, so_reuseaddr, 1); socket_bind($socket, socket_address, socket_port) or die('could not bind address ' . socket_address . ' on port ' . socket_port . "!\n"); socket_listen($socket, max_clients) or die ("could not setup socket liste...

Trying to launch a Visual Studio C# program from inside another one -

i having great difficulty getting windows program, written in vs 2008 c#, launch type program. i've put main program offer ability launch other vs 2008 c# programs. when 1 of them selected following code intended launch: system.diagnostics.process.start(@"c:\documents , settings\rat\my documents\visual studio 2008\projects\pv_002_082708\pv_001\pv_001\bin\debug\pv.exe"); it works, each user have different path. path shown computer. code have know each persons program installed! in past, call program in c:\program files location because that's ms package & deployment program put programs. vs 2008/2010 doesn't put them there! i'm sure not knowledgeable visual studio 2008/2010 know if there way around this, appreciated. system.diagnostics.process.start(system.io.path.combine(system.windows.forms.application.startuppath, "pv.exe")); assuming program in launched application's path. or... system.diagnostics.process.star...

wpf - Redundant converter calls when using Triggers to determine value -

i noticed xaml markup wasting resources doing conversions not supposed do. e.g. have following style acts switch: <style targettype="{x:type image}"> <style.triggers> <datatrigger binding="{binding isdownloaded}" value="true"> <setter property="source" value="{binding data, converter={staticresource bytearraytobitmapimageconv}}"/> </datatrigger> <datatrigger binding="{binding isdownloaded}" value="false"> <setter property="source" value="{binding url, converter={staticresource urltobitmapimageconv}}"/> </datatrigger> </style.triggers> </style> obviously should either download image if has not been cached or turn raw data bitmapimage. problem both cases have taken place @ least once both converters called when datacontext changes...

Android RelativeLayout alignParentRight does not properly align Imagview -

i trying place imageview in bottom right corner of display. image expand dynamically different size displays. the image aligns when smaller , not set expand, when set fill_parent image moved left , no longer lines flush right side of display. <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" > <surfaceview android:id="@+id/surface1" android:layout_width="wrap_content" android:layout_height="wrap_content" ></surfaceview> <imageview android:src="@+drawable/image_1_patched" android:layout_height="fill_parent" android:id="@+id/imageview1" android:layout_width="fill_parent...

javascript events - How does the Notice Area on Facebook works? -

how notification area on facebook works? i'm taking automatically red box appears if have message/something new on wall. believe in stackexchange, javascript interval? please see thread how 1 realtime updates of web page?

php - Cannot modify header information -

possible duplicate: headers sent php i getting following error following code, , not entirely sure why. if tell me how fix it, great. in advanced. warning: cannot modify header information - headers sent (output started at...) on line 45. <?php // initialization $conn = mysql_connect(db_host,db_user,db_password); mysql_select_db(db_name, $conn); // error checking if(!$conn) { die('could not connect ' . mysql_error()); } // localize variables $ref = isset($_get['ref']) ? $_get['ref'] : ""; // protect against sql injections // insert score $retval = mysql_query("insert $table( site ) values ( '$ref' )",$conn); if($retval) { echo "successfull"; } else { echo "unsuccessfull " . mysql_error(); } mysql_close($conn); ?> <?php $url = $_get['url']; $loc...

vsx - How do I get the output directories from the last build? -

let's i've got solution 1 or more projects, , i've kicked off build using following method: _dte.solution.solutionbuild.build(true); // envdte.dte how can output paths each project built? example... c:\mysolution\project1\bin\x86\release\ c:\mysolution\project2\bin\debug please don't tell me way... // dte wrapper; dte.dte envdte.dte var ctxs = dte.dte.solution.solutionbuild.activeconfiguration .solutioncontexts.oftype<solutioncontext>() .where(x => x.shouldbuild == true); var temp = new list<string>(); // output filenames // oh shi foreach (var ctx in ctxs) { // sorry, you'll have oftype<project>() on projects (dte wrapper) // find project build context based on name. vomit. var project = dte.projects.first(x => x.fullname.endswith(ctx.projectname)); // combine project's path (fullname == path???) // outputpath of active configuration of project ...

ruby on rails - RSpec: How to test a helper method that calls a private helper method from the controller? -

here's have: an application helper method calls controller helper method (private) it. code: applicationhelper: def ordenar(coluna, titulo = nil) titulo ||= coluna.titleize css_class = (coluna == **coluna_ordenacao**) ? "#{**direcao_ordenacao**}" : "ordenavel" direcao = (coluna == **coluna_ordenacao** , **direcao_ordenacao** == "asc") ? :desc : :asc link_to titulo, {:sort => coluna, :direction => direcao}, {:class => css_class} end applicationcontroller: helper_method :coluna_ordenacao, :direcao_ordenacao private def coluna_ordenacao return params[:sort] if params[:sort] , params[:sort].split(' ').size == 1 return :created_at end def direcao_ordenacao return %w[asc desc].include?(params[:direction]) ? params[:direction] : :desc end and here problem: coluna_ordenacao , direcao_ordenacao methods can't called rspec, gives me following error: undefined loc...

php - What is a cleaner / better way of parsing data received by an ajax success function? -

i using ajax function receive data. based on data, if results not found receive string "no matches found" html formatting. if there results, data formatted table , "div" section underneath section hidden. now issue having is, when find no results, not want "div" table disappear.but check if there no results, have compare whole string received searchcustomer.php (which large). is there easier way of doing this? my ajax call: $('#search').click(function(e){ $.ajax({ type : 'get', url : 'searchcustomer.php', datatype :'html', data:{ lastname : $('#search_ln').val(), firstname : $('#search_fn').val(), phone : $('#search_pn').val() }, success : function(data){ if (data.error == true){ alert("there error in post layer"); ...

Use PHP to pass the contents of a form into a new xml file with download prompt -

i'm new programming guidance great, i'm trying achieve follows: have simple html form fields (text areas , text fields) when submiting form open dialog choose location save file, file name should default set forms first text area. save file , add contents of form specific xml tags for instace i want capture content of text area name "articlebody" , have saved on file under tag can point me right tutorials? or upload snippet? time. going off top of head: form: <form action="" method="post"> 1. filename: <input type="text" name="filename" /><br /> 2. field 1: <input type="text" name="field1" /><br /> 3. field 2: <input type="text" name="field2" /><br /> </form> script: $filename = $_post['filename']; $field1 = $_post['field1']; $field2 = $_post['field2']; $field1 = htmlspecialchars($fie...

Android edit text showing weird text -

i new android. created simple application using aynctask. basically, uses asynctask iterate through loop , show iteration number in text box. created both edittext , textview , bot shows weird text. try creating toast, , toast shows same text correctly. here source code: package com.jeannius.me; import android.app.activity; import android.os.asynctask; import android.os.bundle; import android.os.systemclock; import android.text.inputtype; import android.view.view; import android.widget.button; import android.widget.edittext; import android.widget.textview; import android.widget.toast; public class main extends activity { /** called when activity first created. */ int[] color1 = {0xffe48701, 0xffa5bc4e, 0xff1b95d9, 0xffcaca9e, 0xff6693b0, 0xfff05e27, 0xff86d1e4, 0xffe4f9a0, 0xffffd512, 0xff75b000, 0xff0662b0, 0xffede8c6, 0xffcc3300, 0xffd1dfe7, 0xff52d4ca, 0xffc5e05d, 0xffe7c174, 0xfffff797, 0xffc5f68f, 0xffbdf1e6, 0xff9e987d, 0xffeb98...

android - Activity isn't picking up new intent -

for various reasons, app creates entries in notification bar. when user clicks on notification, want display custom activity presents entry in format. intent intent = new intent(applicationcontext, textmessagevieweractivity.class); intent.putextra("text_message", sometext); pendingintent contentintent = pendingintent.getactivity(applicationcontext, 0, intent, 0); // create notification , post it. no fancy flags it boils down sending string via intent extra, , displaying in activity. happens first intent gets delivered activity gets "stuck" somehow, , further intents delivered display first intent's extra. public class textmessagevieweractivity extends activity { @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.text_viewer); } @override public void onresume() { super.onresume(); intent startingintent = getintent(); ...

c# - Is retrieving HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography\MachineGuid only achievable by reading the registry? -

is retrieving hkey_local_machine\software\microsoft\cryptography\machineguid only achievable reading registry? is perhaps stored or exposed in static class exposed .net library provided microsoft? i think so, retrieving such information achievable reading registry.

iphone - TTNavigator keeps going to the wildcard page. Any idea what happens? -

my iphone ttnavigator keeps loading wildcard page though url (i.e. 'tt://root') valid @synthesize navigator; // - (bool)application:(uiapplication *)application didfinishlaunchingwithoptions:(nsdictionary *)launchoptions { navigator = [ttnavigator navigator]; [navigator setwindow:window]; // routing table tturlmap *map = navigator.urlmap; [map from:@"*" toviewcontroller:[ttwebcontroller class]]; [map from:@"tt://root" toviewcontroller:[maintabbarcontroller class]]; [map from:@"tt://newsfeed" toviewcontroller:[newsfeedviewcontroller class]]; // first stop if (![navigator restoreviewcontrollers]) { [navigator openurlaction:[tturlaction actionwithurlpath:@"tt://root"]]; } } when comment out wildcard section redirects webview, load "tt://root" when app starts. any idea i'm missing out? cheers, mickey the restoreviewcontrollers message restores cached view c...

lisp lambda function -

(repeat-transformation #'(lambda (x) (* 2 x)) 4 1) this lisp lambda function , don't understand last "1" ? thanks. definition: repeat-transformation (f n x) repeat applying function f on object x n times. you're defining lambda function called repeat-transformation 4 times on integer 1. hope explains it.

vba - Trace all Excel Functions called -

i have excel sheet has many functions split across many modules , classes. know functions / subroutines being used , can eliminate. there way can produce sort of log tell me ? (i told mz tools may able provide unable find it). thanks. not sure if answer, have looked @ http://www.mztools.com/index.aspx make sure download right version, though. by way, i've been using mztools (free) while, , can guarantee it's piece of software price.

javascript - Initiation of an object inside another -

i have piece of js software structured so obj = new object[id](); function wrapperfunction (e) { var pos = findpos(this); e._x = e.pagex - pos.x; e._y = e.pagey - pos.y; var func = obj[e.type]; if (func) { func(e); } } __ obj.line = function () { this.started = false; this.mousedown = function (e) { } this.mousemove = function (e) { if (this.started) { } } this.mouseup = function (e) { if (this.started) { } } } the above code block duplicated multiple shapes there obj.square obj.circle etc... i have shape object follows. function shape (type, color, height, width, radius, x, y) { this.type = type; this.color = color; this.h = height; this.w = width; this.r = radius; this.points = ["x","y"]; this.points["x"] = [x]; this.points["y"] = [y]; }; i initiate shape object on mousedown each...

javascript - The correct way to use PHP's mysql_connect functionality? -

i creating registration form using jquerys ajax feature, sending data form php script. below js code sends data script , attaches feedback div, means page doesn't have refreshed: $.ajax( { url: "public/includes/usercreate.php", type: "post", data: { username: user_username, forename: user_forename, surname: user_surname, email: user_email01, password: user_password01 }, success: function(html) { $('#web_content').html(html); } }); i can use following code attaches echo contents web_content div: <?php $new_username = $_post['username']; $new_forename = $_post['forename']; $new_surname = $_post['surname']; $new_email = $_post['email']; $new_password = $_post['password']; echo "username is: " . $new_username; echo "forename is: " . $new_forename; ...

objective c - reading and separating file using byte comparison -

i have read file in .dat format , separate data based on 2 first consecutive 0 byte comes. first half json data , other half binary data. how should go it? i tried using nsdata datawithcontentsoffile method , read , convert in byte array , compare bytes. somehow, not working. you can use same kind of procedure use read file lines. here , here earlier answers on regarding reading file line-by-line. change \n byte sequence applicable.

.net - Most accepted method of turning a table into a string -

i have table of chars. acceptable method of turning array string. ex: array: ['a']['b']['c'] -> abc thanks, thoughts appreciated! you can either use string.join() or if character array, pass parameter new string constructor below. // a. 15 character array. char[] c = new char[15]; c[0] = 'o'; c[1] = 'n'; c[2] = 'l'; c[3] = 'y'; c[4] = ' '; c[5] = 't'; c[6] = 'h'; c[7] = 'e'; c[8] = ' '; c[9] = 'l'; c[10] = 'o'; c[11] = 'n'; c[12] = 'e'; c[13] = 'l'; c[14] = 'y'; // b. 15 character string. string s = new string(c);

Passing virtual attribute values through to form elements in Rails 3 -

i have following in model: before_validation :update_temp attr_accessor :temp_int, :temp_dec def update_temp self.temp = temp_int.to_f + (temp_dec.to_f / 10) end and have following in view: <%= f.select(:temp_int, ["97", "98"], { :include_blank => true })%> . <%= f.select(:temp_dec, ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"], { :include_blank => true })%> this works great saving temperature values. however, there's 1 issue. on edit screen, select helper have existing values pre-selected. using virtual attributes isn't happening. how make sure temp_int , temp_dec values passed view? the view should have no problem accessing attributes, have attributes been initialized within view's action? looks like, if you've loaded instance of model, attributes still nil, regardless of value of #temp . not...

php - preg_match assistance needed -

hi need assistance changing preg_match check 2-16chars a-z 0-9 -_ , space. right checking url i'd need remove protocol, add space , 2-16 min/max chr. public function checkurl($string) { if(empty($string) || preg_match("#^(http|https|ftp)://([a-z0-9][a-z0-9_-]*(?:.[a-z0-9][a-z0-9_-]*)+):?(d+)?/?#i", $string)) { return true; } else { if( isset($this) ) { $this->adderror("input error"); } return false; } } i'm not sure part want change, but... [need match] 2-16 chars a-z 0-9 -_ , space. [\w- ]{2,16} \w matches a-z , a-z , 0-9 , _ . - match literal - in character class outside of valid range. ' ' match space (ignore quotes, stack overflow needed them display). match whitespace character, use \s . {2,16} quantify match between 2 , 16 times inclusively. you change (http|https|ftp) (?:https?|ftp) , won't capture group, aren't using re...

How to select a certain element that is closest to the end of a given div with jQuery? -

let's have div called the_div . in div there multiple submit buttons. submit buttons added dynamically on page. <div id="the_div"> ...other stuff <input type='submit' value='add'> ...other stuff <input type='submit' value='add'> ...other stuff <input type='submit' value='add'> -need select 1 </div> is there way can use jquery selector select submit button closest end of div? in example above third submit button. use last . $('#the_div :submit:last')...

android - Difference between ColorDrawable and PaintDrawable -

by looking @ android developers documentation of paintdrawable , colordrawable, can not distinguish difference between two. hope can enlighten me one... thanks, artsylar a colordrawable simple kind of drawable fills canvas color. can set colorfilter on colordrawable, ignored. paintdrawable more complex; draws color, operation can modified colorfilter, paint object. colordrawable cheaper use more limited in can use for.

javascript - In Chrome, can't access any variables or functions of a child iframe, or of an iframe's parent -

this similar this question , although bit broader. i'm opening these pages locally, , sit in same folder. index.html: <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html lang="en"> <head> <title>testindex</title> <script type="text/javascript"> function init() { alert("child.childvar: " + child.childvar); //works in ff, ie, not chrome alert("frames['child'].childvar: " + frames['child'].childvar); //works in ff, ie, not chrome alert("document.getelementbyid('child').contentwindow['childvar']: " + document.getelementbyid('child').contentwindow['childvar']); //works in ff, ie, not chrome child.childfunc(); //works in ff, ie, not chrome frames[...

java.util.scanner - Detected a new line within a series of numbers in Java -

let's have series of numbers like... 1 2 3 4 5 6 7 8 9 0 how step through each int, stop when reach new line? i'm using nextint() , know nextline() detect new line, i'm not sure how piece together. best take entire line, , parse string separate ints? or there more fluid method of doing this? for example, want program store 1 2 3 4 , 5 6 7 8 , 9 0 in own separate array. for more clarification, i'm using java.util.scanner , i'm reading text file. if want use scanner , read entire line string, , construct scanner on string.

java - Hadoop gzip compressed files -

i new hadoop , trying process wikipedia dump. it's 6.7 gb gzip compressed xml file. read hadoop supports gzip compressed files can processed mapper on single job 1 mapper can decompress it. seems put limitation on processing. there alternative? decompressing , splitting xml file multiple chunks , recompressing them gzip. i read hadoop gzip http://researchcomputing.blogspot.com/2008/04/hadoop-and-compressed-files.html thanks help. a file compressed gzip codec cannot split because of way codec works. single split in hadoop can processed single mapper; single gzip file can processed single mapper. there atleast 3 ways of going around limitation: as preprocessing step: uncompress file , recompress using splittable codec (lzo) as preprocessing step: uncompress file, split smaller sets , recompress. ( see this ) use patch hadoop (which wrote) allows way around this: splittable gzip hth

pattern matching - Soundex to match common SMS or IM short forms -

i doing bit of experimentation apache commons soundex. and, found works quite strings. looking api or way can match words or strings in sms or usual im formats formats soundex. following examples, "4" match "four" or "for" "@" match "at" so on , forth... is there api existing already? or way tweak existing soundex api this? appreciate time , help. thanks, abi

Image gets clipped while changing orientation using Qt -

hi all, i wnt develop imageviewer using qt. m trying resize big images scaling them. problem , when change screen orientation part of image gets clipped , if open image in landscape mode, default size of image remains small when change portrait mode. doin wrong? please me out. heres code dat hv written imageviewer::imageviewer() { setattribute(qt::wa_deleteonclose); qaction *back = new qaction(this); back->settext(qstring("back")); connect(back,signal(triggered()),this,slot(close())); back->setsoftkeyrole(qaction::positivesoftkey); addaction(back); imagelabel = new qlabel(); imagelabel->setsizepolicy(qsizepolicy::expanding,qsizepolicy::expanding); imagelabel->setalignment(/*qt::alignleft|*/qt::aligncenter); qwidget *widget = new qwidget; layout=new qstackedlayout(); layout->addwidget(imagelabel); widget->setlayout(layout); setcentralwidget(widget); } void imageviewer::showimage(qstring filepath) { qimagereader re...

eclipse - Blackberry Error "Attempt to access secure API" -

when install application in device, error “attempt access secure api ” i have signed application using signing authority tool. have found many solutions via searching on google have not found proper solution yet. is there other way sign application , install in device ?

ruby on rails - how to maintain model properties -

i new ror, setup enviroment ruby 1.9.2 rails 3.0.6 just notice 1 thing. after create model.. propeties has been add database couldn`t see class.. , work me. looks rails scan database schema before launching application.. but have question it: if add or remove columns... how know properties have if not define in class? can manually add properties acticerecord class(es) ?? class user < activerecord::base has_one :contact validates_confirmation_of :password end class createusers < activerecord::migration def self.up create_table :users |t| t.string :username t.string :password t.timestamps end end def self.down drop_table :users end end i;m not sure understand question, can view schema.rb any migration make update schema

iphone - Sorting of Date String using sortUsingDescriptors? -

i have number of arrays of dictionary points = 200; startdate = "jun 04, 2011, 13:15 pm"; points = 200; startdate = "may 01, 2011, 11:15 pm"; , ------- i have sorting on basis of startdate. i have used number of sorting's earlier numerical.. alphabetical sorting etc via method: -(nsmutablearray*)sorteventsarray:(nsmutablearray*)arraytosort :(nsstring*)sortexpression { nssortdescriptor *mysorter = [[nssortdescriptor alloc] initwithkey:sortexpression ascending:yes]; [arraytosort sortusingdescriptors:[nsmutablearray arraywithobject:mysorter]]; return arraytosort; } but not working date string. please help chekout this this 1 also both you.

Memory leak from NSTimer? -

i'm developing app , , running well. not enough, though. when running "leaks" instrument, i'm seeing lot of leaks nstimer. the nstimer started , stopped uiswitch. memory leak occurs each time switch flipped "off" //playview.h @interface playview : uiviewcontroller { nstimer *autotimer; // other things } @property (nonatomic, retain) nstimer *autotimer; // etc... //playview.m #import "playview.h" @implementation playview @synthesize autotimer; - (ibaction) toggleenabledforswitch1: (id) sender { if (switch1.on) { self.autotimer = [nstimer scheduledtimerwithtimeinterval:0.5 target:self selector:@selector(updatecounter:) userinfo:nil repeats:yes]; } else { restart = 1; [self.autotimer invalidate]; self.autotimer = nil; [self.autotimer release]; } } - (void)updatecounter:(nstimer *)thetimer { // bunch o...

html - Stretching images when using as background image -

i trying set image background image django application. when set it, getting displayed tiled image. ie without stretching image, same image tiled , shown 4 times. can tell me how stretch image , set background image. paste code here. sure attribute must there setting this, couldnt find on googling. <body bgcolor=" #408080" background="/static/paper.jpg" background-size: 100%; > you can stretch background 100% width , height putting image in <img> tag , give z-index of -1 acts background , behind else. works in browsers. <img src="..." /> img{ position:absolute; z-index:-1; width:100%; height:100%; } if not want break aspect ratio, set either width or height , not both. check working example @ http://jsfiddle.net/uxbrm/1/

c# - Limit number of web service calls within timeframe -

i have asmx web service takes few simple types input, calls oracle stored procedure gets response , passes response caller. i take inputs service , assuming valid , required operation completed successfully, i'd store inputs somehow (in efficient way, not hitting database example) agreed timespan, refuse attempts call service same data until after timespan has expired. hope that's clear. so way of pseudo code... [webmethod] public response dothings(int someint, string somestring, datetime somedatetime) { if(!stored(someint, somestring, somedatetime)) { var response = new oraclerepository().callstoredprocedure(someint, somestring, somedatetime); storeinputs(someint, somestring, somedatetime); return response; } else return response.trylater; } private void storeinputs(int someint, string somestring, datetime, somedatetime) { store(int someint, string somestring, datetime, somedatetime); } private bool stored(int someint, ...