Posts

Showing posts from March, 2010

php - What is wrong with this MySQL insert statement? -

i beginning php/mysql developer, , have written statement insert username , password database make account. reason getting error though; what's wrong? mysql_query("insert signup (username, password, email) values ($username, $password, $email)") or die ("cnnot run query"); put quotes around $username, $password , $email. you should use prepared statements. such usage prone sql injections

php - Group and sort an array of objects based on 2 parameters -

i have array of objects want sort based on 1 property, , kind of 'group together' based on property. in example below, them sorted based on $sequence , , grouped based on $artist . // stripped down version of class : <?php class myclass { public $sequence; public $artist; function __construct($sequence,$artist) { $this->sequence=$sequence; $this->artist=$artist; } static function cmp_myclass_sequence($a, $b) { $a_seq = $a->sequence; $b_seq = $b->sequence; if ($a_seq == $b_seq) { return 0; } return ($a_seq > $b_seq) ? +1 : -1; } static function cmp_myclass_artist($a, $b) { $a_art = strtolower($a->artist); $b_art = strtolower($b->artist); if ($a_art == $b_art) { return 0; } return ($a_art > $b_art) ? +1 : -1; } } //some objects of class using testing : $myobj1 = new myclass(1,...

hibernate - @GeneratedValue(strategy = GenerationType.AUTO) not working as thought -

i'm trying persist object database. keep getting 'column id cannot accept null value error'. object looks this: @entity public class testtable { @id @generatedvalue(strategy = generationtype.auto) private integer id = 0; @column(nullable=false, length=256) private string data = ""; public integer getid() { return id; } public void setid(integer id) { this.id = id; } public string getdata() { return data; } public void setdata(string data) { this.data = data; } } my persist function: public static synchronized boolean persistobject(object obj){ boolean success = true; entitymanager em = null; entitytransaction tx = null; try{ em = getemf().createentitymanager(); tx = em.gettransaction(); tx.begin(); em.persist(obj); tx.commit(); } catch (exception e){ ...

c# - Select subset of elements by comparing them with each other in LINQ -

i trying construct linq query take list of elements, , based on comparison between elements in list, select ones meet criteria. this: var subset = set.somelinqquery((e1,e2) => e1 == e2); subset contains e1 of set e1 == e2 . ideas? thought of having nested loop, realized there must have been way in linq. you need method generate unique pairs of items original set. here’s implementation of that: /// <summary> /// returns enumeration of tuples containing unique pairs of distinct /// elements source collection. example, input sequence /// { 1, 2, 3 } yields pairs [1,2], [1,3] , [2,3] only. /// </summary> public static ienumerable<tuple<t, t>> uniquepairs<t>(this ienumerable<t> source) { if (source == null) throw new argumentnullexception("source"); return uniquepairsiterator(source); } private static ienumerable<tuple<t, t>> uniquepairsiterator<t>(ienumerable<t> source) { // ...

dependencies - Maven - System Jar provoded by Websphere Library -

i have 2 questions regarding dependencies: q1: have j2ee.jar on unix box (provided websphere library). how refer in ant: <path id="was.lib"> <fileset dir="${was.home}/lib"> <include name="**/j2ee.jar" /> </fileset> </path> <property name="was.lib" refid="was.lib" /> <path id="myproj.lib"> <!-- path project's jar's --> </path> <property name="myproj.lib" refid="myproj.lib" /> <path id="myproj.classpath"> <path refid="myproj.lib" /> <path refid="was.lib" /> </path> i not sure, how define dependency in maven refers system path? q2: have jar castor-1.3.1.jar , castor-1.3.1-core.jar in project. when define dependency both of them, maven picks one, since version different. want both of them included. how have defined them: <dependency> <groupid>org.codeha...

ckeditor - Why can't I HtmlDecode in ASP.NET MVC 3 -

here scenario. want use ckeditor rich text field on form, whatever reason cannot contents textarea server , page without encoding problems. here little sample program wrote try , figure out going on. first, view model: homeviewmodel.cs namespace ckeditortest.models { public class homeviewmodel { [required] [datatype(datatype.html)] [display(name = "note")] public string note { get; set; } } } now controller: homecontroller.cs using system.web.mvc; using ckeditortest.models; namespace ckeditortest.controllers { public class homecontroller : controller { public actionresult index() { return view(new homeviewmodel()); } [httppost] [validateinput(false)] public actionresult index(homeviewmodel model) { return view(model); } } } and finally, view: index.cshtml @model ckeditortest.models.homeviewmodel @{ viewbag.t...

c++ - Declaring using statement after namespace declaration -

i writing utility library made of several "packages". classes in each package contained in various namespaces. have idea how can simplify situation automatically declaring using statements @ end of class declarations (see below), avoid having programmer in cpp file. namespace utility { class string { // class implementation }; } using utility::string; my understanding if user includes header string.h , string in utility programmer want use string. bad if there outside classes chain including bunch of files dirty namespace thought how making #define instead. namespace utility { class string { // class implementation }; } #ifdef auto_declare_namespace using utility::string; #endif that way, programmers want extended functionality can it. would idea or there i'm overlooking? there no point in using namespaces if going add using declaration each , every name declared in namespace. let users of header files...

firefox addon - how to get the coordinates of Browser? -

i have created firefox extension using xpcom . want coordinates of client area of browser? how coordinates of client area of browser using xpcom? please me. thanks, nandkuamar if have window variable content area in question, use screenx / screeny properties. if have window variable browser in question, use content property access current tab's window, , follow step 1. if don't have variable yet, can ask window mediator one.

c# - ASP.NET MVC Custom Routing in Sub Folder -

Image
i have searched on google (may wrong keyword) , visited tutorials of asp.net/mvc website. didn't understand routing of mvc properly. have scenario of following figure. want display index.cshtml when website lunched. i have changed registerroutes method of global.asax.cs file in various ways. latest code (not working) below routes.maproute( "app", // route name "app/{controller}/{action}/{id}", // url parameters new { controller = "home", action = "index", id = urlparameter.optional } // parameter defaults ); i happy if explains maproute method different example along answering problem. i don't think problem routes, believe caused moving view , controller folders app folder. mvc use "convention on configuration" stuff folders located, i'm guessing can't find views/controllers in new folders? from here : these folders included in empty asp.net mvc a...

java - Provider recursion question -

so, have class bar should contains factory of bars. class bar { collection<bar> children; bar(barfactory factory, foo1 foo, foo2 foo2){ } addchild(foo1 foo1){ children.add(factory.create(foo1)); } } class barfactory { bar create(foo1 foo1); } the problem in describing barfactory. there specific logic dependencies other objects. i've tried use @provides mechanism, like @provides barfactory providelogicelementpresenterfactory(dependence d){ final barfactory f = new barfactory(){ @override public bar create(foo1 foo1) { foo2 foo2 = null;//some logic return new bar(/*how pass factory here?*/f, foo1, foo2); } }; return f; } how describe such recursive structure or there alternative solution issue? use this instead of f in when invoking bar constructor.

compiler construction - Can't compile C++ project (macro "max" passed 3 arguments, but takes just 2) -

sorry generic title, no pro when comes c++ compiling , can't seem find error here. i checking out official project, know thing should compile fine. doesn't. if wants checkout code themselves, here go: cvs -d :pserver:jvtuser:jvt.amd.2@garcon.ient.rwth-aachen.de:/cvs/jvt login cvs -d :pserver:jvtuser@garcon.ient.rwth-aachen.de:/cvs/jvt checkout jmvc cd jmvc/jmvc/h264extension/build/linux make when call make , receive: make -c lib/h264avcvideoiolib release make[1]: entering directory `/home/user/jmvc/jmvc/jmvc/h264extension/build/linux/lib/h264avcvideoiolib' g++ -c -mmd -mf ./objects/h264avcvideoiolib.r.d -mt ./objects/h264avcvideoiolib.r.o -fpic -dmsys_linux -d_largefile64_source -d_file_offset_bits=64 -dmsys_unix_largefile -i/home/user/jmvc/jmvc/jmvc/h264extension/build/linux/lib/h264avcvideoiolib/../../../../include -i../../../../src/lib/h264avcvideoiolib -dmerl_view -wall -wshadow -wno-reorder -wno-sign-compare -o3 -ffloat-store -dndebug -wuninitialized -o ...

windows phone 7 - NonLinearNavigationService and Toolkit Page Transitions -

i'm using nonlinearnavigationservice class , toolkit page transitions in project, noticed bug when using nonlinearnagivationservice, transition effect won't play , i'm looking solution issue. i've read in wp7 developers blog they're working support page transitions in next version of nonlinearnavigationservice still no updates. hope has found workaround issue. you'll see behavior if you're doing this: public mainpage() { initializecomponent(); } protected override void onnavigatedto(navigationeventargs e) { base.onnavigatedto(e); // update page } one way address hook begintransition event on navigationintransition: public mainpage() { initializecomponent(); transitionservice.getnavigationintransition(this).begintransition += new system.windows.routedeventhandler(mainpage_begintransition); } void mainpage_begintransition(object sender, system.windows.routede...

asp.net - Using LINQ to surround all "group" elements with the new element "groups" in C# -

i'm new linq , c# have xml file generated database table. within xml document element called "group", wrap group elements element called "groups". an extract of xml document is: <members> - <user> <fullname>john smith</fullname> <username>smitha</username> <email>john.smith@test.com/email> <distinguishedname>xxx</distinguishedname> <group>london</group> </user> - <user> <fullname>sue jones</fullname> <username>joness</username> <email>sue.jones@test.com/email> <distinguishedname>xxx</distinguishedname> <group>london</group> </user> </members> the end result struggling code in c# asp.net is: <members> - <user> <fullname>john smith</fullname> <username>smitha</username> <email>john.smith@test.com/email> <distinguish...

flex - How can I user getRepeaterItem to set the progress of a progress bar? -

i have progress bar inside repeater , therefore need use getrepeateritem set it's progress suggested in this question. how can such value of progress may taken repmonitor.currentitem.threatlevel? <mx:accordion id="monaccordian" includein="monitoring" x="10" y="10" width="554" height="242" change="monaccordianchange()" > <mx:repeater id="repmonitor" dataprovider="{monitoringarray}"> <mx:canvas width="100%" height="100%" label="{repmonitor.currentitem.firstname+' '+ repmonitor.currentitem.lastname}" > <mx:image x="10" y="10" source="{repmonitor.currentitem.imagename}" width="175" height="118"/> <s:label x="200" y="14" text="threat level:"/> <mx:progressbar x="200" y="30" mode=...

Django model: How to access "join table"? -

class person(models.model): name = models.charfield(max_length=128) def __unicode__(self): return self.name class group(models.model): name = models.charfield(max_length=128) members = models.manytomanyfield(person, through='membership') def __unicode__(self): return self.name class membership(models.model): person = models.foreignkey(person) group = models.foreignkey(group) date_joined = models.datefield() invite_reason = models.charfield(max_length=64 so want here access person/group/data_joined/invite_reason group object, how write such code? thanks~ it's standard reverse foreignkey relationship: my_group.membership_set.all()

sql - Oracle Trigger on Insert or Delete or Update -

trying create oracle trigger runs after table updated in way. i've been googling morning , came this: create or replace trigger gb_qty_change after update or insert or delete on f_item_store each row declare v_qty v_ad_on_hand%rowtype; v_isbn td_item_description.td_identifier%type; begin delete gb_transaction gb_tide = :new.itst_item_tide_code; select td_identifier v_isbn td_item_description td_tide = :new.itst_item_tide_code; select * v_qty v_ad_on_hand itst_item_tide_code = :new.itst_item_tide_code; insert gb_transaction(gb_tide, gb_isbn, gb_used_on_hand, gb_new_on_hand) values(:new.itst_item_tide_code, v_isbn, v_qty.used_on_hand, v_qty.new_on_hand); end; / i'm trying keep single record per tide_code in new table. v_ad_on_hand view pulls inventory count. gb_transaction new table i'm logging these events comparing other peoples code looks should run i'm getting "warning: trigger created compilation errors." the ...

PHP Parsing Conundrum - "Missing Symbols Listed" -

i trying access yahoo site getting stock quotes: http://de.finance.yahoo.com/d/quotes.csv?s=^dji&f=nsl1op&e=.csv and doesn't seem downloading data. "missing symbols listed.". weird b/c used work! <?php function market_value($s) { $records= fopen ("http://quote.yahoo.com/d/quotes.csv?s=$s&f=nsl1&e=.csv"); $contents = fread ($records); fclose ($records); $data = str_replace ("\"", "", $data); $data = explode (",", $data); $trade= $data[2]; return (".$trade.")"; } ^dji can not queried yahoo, seems. you should use indu . try downloading http://finance.yahoo.com/d/quotes.csv?s=indu,goog,msft&f=nsl1op&e=.csv this should return like "dow jones industr","^dji",12069.94,12057.34,12058.02 "google inc.","goog",601.74,600.06,600.76 "microsoft corpora","msft",26.13,26.10,26.16 ...

c++ cli - Casting from double to int - Warning in Visual C++/CLI -

i have property that's double in c++/cli need cast integer, compiler gives me warning (c4244) when so. example: //"value" double int newvalue = (int)(control->value); //c4244 i understand compiler isn't happy because double might larger int can hold, particular control guaranteed value 1 10, i know okay. can eliminate warning somehow? the compiler warning not might out of range, might lose information (it needs round number somehow, , afraid own). use floor() tell know you're doing: int newvalue = floor(control->value); or cast explicitly tell compiler there's nothing implicit going on, , know you're doing: int newvalue = (int)(float)(control->value);

c# - How to manage multiple display setting in Windows 7 programatically? -

i need change resolution, position, , select 1 main display, preferably in .net. i think can using user32.dll api functions via p/invoke. see avaiable functions . sample code: [dllimport("user32.dll")] static extern long changedisplaysettings(ref devicemode lpdevmode, int dwflags); [dllimport("user32.dll")] static extern int enumdisplaysettings(string lpszdevicename, int imodenum, ref devicemode lpdevmode); [dllimport("user32.dll")] static extern int enumdisplaydevices(string lpdevice, int idevnum, ref displaydevice lpdisplaydevice, int dwflags); code changing screen resolution: //displaydevice wrapper ... can find [here](http://pinvoke.net/default.aspx/structures/display_device.html) list<displaydevice> devices = new list<displaydevice>(); bool error = false; //here listing displaydevices (monitors) (int devid = 0; !error; devid++) { try { displaydevice device = new displaydevice(); device.cb = ...

javascript - jQuery/JS - How to compare two date/time stamps? -

i have 2 date/time stamps: d1 = 2011-03-02t15:30:18-08:00 d2 = 2011-03-02t15:36:05-08:00 i want above compare two: if (new date(d1) < new date(d2)) {alert('newer')} but not appear working correctly. there way compare not dates times well.? thanks update: console.log(d1 + ' ' + d2); console.log(new date(d1) > new date(d2)) 2011-03-02t15:30:18-08:00 2011-03-02t15:36:05-08:00 false 2011-03-02t15:30:18-08:00 2011-03-02t15:30:18-08:00 false 2011-03-02t15:30:18-08:00 2011-03-02t14:15:04-08:00 false your timestamps should strings. var d1 = "2011-03-02t15:30:18-08:00"; var d2 = "2011-03-02t15:36:05-08:00"; if (new date(d1) < new date(d2)) {alert('newer')} example: http://jsfiddle.net/hkpkf/

xaml - How do I set the text opacity different from the background opacity in a Silverlight textbox -

my xaml contains in part <textbox text="projected" textalignment="center" fontsize="11" fontweight="bold" foreground="white" background="#ff3376b8" opacity="0.65" /> however, causes text 65% opaque; how set text 100% opaque allow background 65%? do adjusting alpha channel of background property. for example: <textbox text="projected" textalignment="center" fontsize="11" fontweight="bold" foreground="white" background="#883376b8" />

javascript - What's wrong with my extension? -

backg.html <script type="text/javascript"> var domurl = "http://www.xxxxxx.xxxx/id"; var txt; var txt2; var id1; var id2; var imgarres = []; var imgarr = []; var imgels = []; var anchors = []; var anc = []; function getdata() { if (id1){cleartimeout(id1);} if (id2){cleartimeout(id2);} geturl(); var xurl = null; xurl = localstorage['url']; var xhr = new xmlhttprequest(); xhr.open('get',xurl, true); xhr.setrequestheader('cache-control', 'no-cache'); xhr.setrequestheader('pragma', 'no-cache'); xhr.onreadystatechange = function() { if (xhr.readystate == 4) { txt = xhr.responsetext; var r = txt.indexof('<b class="fl_r">online</b>'); var el = document.createelement("div"); el.innerhtml = txt; var n = imgprocess(el,xurl); var nam = el.getelementsbytagname("tit...

php - UTF 8 and Doctrine Full text search -

after try include searchable in schema in symfony. notice generator automatic generate indextable. but inside indextable, see keywords being held without utf8 character ex. nghĩa -> ngha could affect search method doctrine? there way fix this? have set encoding in databases.yml file? there encoding parameter: encoding: utf8 maybe solve problem... also in schema.yml file have option charset.

OSX Lion AppleScript : How to get current space # from mission control? -

i'm trying figure out how current space # mission control. source helpful, more helpful info on how figure out myself. i've written few applescripts, more not seems time need new (that can't find dictionary documentation for) falls under category of "tell specific app (e.g. "system events") specific thing" , i've no clue how figure out. specifically trying do: i hate new mission control in osx 10.7. want spaces "grid" since used time. used navigate between spaces using arrow keys (e.g. alt + ↑ ) every few seconds. i'm stuck clunky 1x9 array of spaces instead of elegant 3x3 grid. i've re-mapped spaces use number pad, partially takes care of problem (since 3x3 grid), when have external keyboard attached. basically, want able use alt + ↑ , ↓ again, need detect current space # can switch space 5-->2, example. dave's answer below, although far more detailed expected, requires writing app (plus still doesn...

jquery - jEditable - Edit data with drop down -

i using datatables + jeditable display data db , allow user edit each cell directly. currently able implement inline edit , save updated value database text field , datepicker, however, met problem data need allow edit drop down. the value need edit retrieve db table foreign key relationship. <td id="type@(item.foodid)" class="dropdown"> @html.displayfor(modelitem => item.foodtypes.foodtypename) </td> i follow guide http://gunbladeiv.blogspot.com/2011/06/part-2-mvc-3-and-datatables-with-inline.html using action return list of selection json: function getfoodtypeslist() { var list; $.post('getfoodtypes', {}, function (data) { list = validatejson(data); }, 'json/javascript' ); return list; } function validatejson(x) { var orig = x; var stgify = json.stringify(orig); var splitchar = ['\\"', '\',\'', '[', ']'...

Android:Where can I get the latest version SDK's open source project site? -

i want know "open source project" web site of latest sdk version sdk13,is there me?? in advance! they have no release source code yet, if did on http://source.android.com/ external reference, although can google lot more ... http://www.linuxfordevices.com/c/a/news/google-io-show-and-android-31/ "there apparently no word on when android 3.0 or 3.1 released open source code, event google said delayed indefinitely in march."

sql - Set Values in column B based on values in Column A in SQL2005? -

i'm trying take existing column , parse each row words in string, i.e. sheet, page, card, , based on word (only 1 instance of 1 of these words in row) populate new column in same table value. if did not find of words, leave column b blank. i.e. column contains word "sheet", populate column b letter "s" so table like: column column b sheet s page p card c any appreciated! update yourtable set columnb = case when columna '%sheet%' 's' when columna '%page%' 'p' when columna '%card%' 'c' else null /* or '' if prefer */ end

javascript - animate element dynamically on creation -

i want dynamically create divs, append them body , set jquery animation. this elements created: function drawspot() { var myh1 = document.createelement("div"); myh1.style.position = "absolute"; myh1.style.top = getrandom(0,100)+"%"; myh1.style.left = getrandom(0,100)+"%"; myh1.style.width="40px"; myh1.style.height="40px"; $("body").append(myh1); } and time on appended body, want start animation. if using jquery, should way: $('<div>', { css: { position: 'absolute', top: getrandom(0,100)+'%', left: getrandom(0,100)+'%', width: '40px', height: '40px' } }).appendto( document.body ).animate({ left: '100%' // instance }, 2000); by using .appendto() still have reference original object , able chain methods on it. ref.: jquery constructor , .appendto() ...

java - Grails framework method addTo throws exception on multiple invoke -

i want add subscriptions user class, invoking "addto" method, here code: if (params.jobs == "on") { user.addtosubscriptions(category.findwhere(id: 1l)) } else { user.removefromsubscriptions(category.findwhere(id: 1l)) } the "params" come checkboxes, user can subscribe category setting checkboxes. code above invoked when form submitted. doesn't work when user changes more 1 categories, think of same code above different params.x, this if (params.offers == "on") { category cat = category.get(2) if (!user.subscriptions.contains(cat)) user.addtosubscriptions(category.findwhere(id: 2l))//needs long variable } else { user.removefromsubscriptions(category.findwhere(id: 2l)) } what happens category wich first in code gets added , removed, other throw following exception: org.hibernate.exception.genericjdbcexception: not execute jdbc batch update edit: line in wich ex...

Android HttpURLConnection not working with cgi-bin? -

i have simple code : url url; bufferedreader in = null; httpurlconnection connection; inputstream = null; inputstreamreader br = null; setprogresstitle(progress, context.getstring(r.string.loading)); setprogressmessage(progress, context.getstring(r.string.loading_from_internet)); try { url = new url(urlstr); connection = (httpurlconnection) url.openconnection(); connection.setconnecttimeout(const.timeout); = connection.getinputstream(); ... if have urlstr = "http://samlib.ru/w/waliduda_a_a/molochnischituran1.shtml" - work fine. if use urls urlstr = "http://samlib.ru/cgi-bin/areader?q=jlist" - got error in connection.getinputstream(); ** 03-04 15:37:52.459: error/datareader::loaddatafrominet(17281): failed loading http://samlib.ru/cgi-bin/areader?q=jlist 03-04 15:37:52.459: error/datareader::loaddatafrominet(17281): java.io.filenotfoundexception: http://samlib.ru/cgi-bin/areader?q=jlist 03-04 15:37:52.459: error/datareader::loaddatafr...

ruby on rails - Access level / security roles design choice: individual roles or inheritance -

please consider scenario: web app has 4 levels of access: admin > manager > representative > customer > no role (public access pages) with current app setup can allow access in 2 ways: i can write code, assume role precedence, i.e. if user a manager - app automatically assume he/she has right access areas customer & representative can, not admin. i can assign each role individually in table. instance user have 3 roles assigned them. app not assume role precedence / inheritance. can either let admin assign users roles, or right code automatically assign roles user if higher access level granted. which of 2 approaches better standpoint of maintainability? p.s. i don't think matters i'm using rails 3 cancan & devise. setup relationship between roles , users following: role <=> (habtm) <=> user i have similar role requirement , i've chosen approach 1. it's natural assume higher role hierarchy go, more access have...

debugging - Android OpenGL Debug: Posting Custom Message Strings -

in android, when using> glsurfaceview.setdebugflags(glsurfaceview.debug_log_gl_calls); opengl posts number of useful error messages these> 07-21 20:48:47.910: verbose/glsurfaceview(5052): glgentextures(1, [0, 0], 1) returns { 07-21 20:48:47.920: verbose/glsurfaceview(5052): [1] = 1 07-21 20:48:47.920: verbose/glsurfaceview(5052): }; 07-21 20:48:47.920: verbose/glsurfaceview(5052): glbindtexture(gl_texture_2d, 1); 07-21 20:48:47.920: verbose/glsurfaceview(5052): gltexparameterf(gl_texture_2d, gl_texture_min_filter, gl_nearest); 07-21 20:48:47.920: verbose/glsurfaceview(5052): gltexparameterf(gl_texture_2d, gl_texture_mag_filter, gl_nearest); is there built in way send message same eclipse android debugging output window (in case filtering on tag glsurfaceview) one way use standard logger correct tag, in case be> log.v("glsurfaceview","custom error string");

python - How to use validation to make a clickable, pseudo-readonly FileField in the admin? -

i'm trying have filefield clickable in admin readonly. there's open ticket issue, need workaround now. i'm trying write validator admin class i'm running exception when run it. have: class modelwithattachment(models.model): attachment = filefield(upload_to=somewhere, blank=true) class modelwithattachmentadminform(forms.modelform): class meta: model = modelwithattachment def clean_attachment(self): attachment = self.cleaned_data['attachment'] return self.cleaned_data['attachment'] class modelwithattachmentadmin(admin.modeladmin): form = modelwithattachmentadminform currently assertionerror no exception supplied @ line attachment = self.cleaned_data['attachment'] . if replace line cleaned_data = self.cleaned_data , same assertionerror. far understand it, self.cleaned_data supposed have been created earlier in validation process, don't understand why doesn't seem exist. secondly, goal who...

javascript - Resizable split screen divs using jquery UI -

i have design in mind involves split panel view in html, similar winforms split panel. i've been expirimenting jquery ui - resizable , function, can't seem co-ordinate resizing of 2 div s. problem current code 2 div s resize away each other, not 1 following other. how can make 2 div s work together? <html> <head> <title>test</title> <link rel="stylesheet" type="text/css" href="css/custom.css" /> <link rel="stylesheet" type="text/css" href="css/superfish.css" media="screen"> <link rel="stylesheet" type="text/css" href="css/jquery-ui-1.8.10.custom.css" media="screen"> <script type="text/javascript" src="script/jquery-1.5.1.js"></script> <script type="text/javascript" src="script/superfish.js"></script> ...

why MySQLi prepared statements? -

what advantages of using prepared statements mysqli? if purpose secure query, isn't better clean query using mysqli_real_escape_string instead of writing many lines of code each query (like prepare, bind_param, execute, close etc.)? preparing statements not code security. helps sql server parse statement , generate execution plan query. if run select 1000 times sql server have parse, prepare, , generate plan on how data 1000 times. if prepare statement run prepared statement 1,000 times each different bound values statement parsed once , same query plan used each time. this helps not when run 1,000 queries inside script if have 1 statement , run script 1,000 times. server can remember plan server side. next time script runs use same plan again. sure may seem trivial 1 or 2 queries when start executing large numbers of queries or same query repeatedly save lot of processing time.

progressdialog - How to display progress dialog before starting an activity in Android? -

how display progress dialog before starting activity (i.e., while activity loading data) in android? you should load data in asynctask , update interface when data finishes loading. you start new activity in asynctask's onpostexecute() method. more specifically, need new class extends asynctask: public class mytask extends asynctask<void, void, void> { public mytask(progressdialog progress) { this.progress = progress; } public void onpreexecute() { progress.show(); } public void doinbackground(void... unused) { ... loading here ... } public void onpostexecute(void unused) { progress.dismiss(); } } then in activity do: progressdialog progress = new progressdialog(this); progress.setmessage("loading..."); new mytask(progress).execute();

algorithm - "Assignment Problem" solution question -

Image
i reading through solution assignment problem here: http://www.topcoder.com/tc?module=static&d1=tutorials&d2=hungarianalgorithm i understand o(n3) solution), had question easier o(n4) solution. perhaps misunderstood notation, when goes modify weights in step 2 -- why doesn't weight w1->j2 increase same way w2->j1 increases. can better explain notation in rule defined in it looks 2 logical symbols supposed "and" , "xor" respectively. xor symbol chosen looks more inclusive or, typo. see http://en.wikipedia.org/wiki/exclusive_or of less confusing alternatives. with interpretation, have following possibilities: neither i nor j in v . first case. i in v , j not. second case. i not in v , j is. second case. both i , j in v . third case. as see, cases covered, , there no ambiguity.

how to access javascript object variables in prototype function -

i have following javascript function person() { //private variable var fname = null; var lname = null; // assign value private variable fname = "dave"; lname = "smith"; }; person.prototype.fullname = function () { return this.fname + " " + this.lname; }; var myperson = new person(); alert(myperson.fullname()); i trying understanding of object orientated techniques in javascript. have simple person object , added function prototype. i expecting alert have "dave smith", got "underfined underfined" . why , how fix it? unfortunately can't access private variable. either change public property or add getter/setter methods. function person() { //private variable var fname = null; var lname = null; // assign value private variable fname = "dave"; lname = "smith"; this.setfname = function(value){ fname = value; }; this.getfname = function(){ return ...

android - How to set icon onCreateContextMenu -

i try does't show public void oncreatecontextmenu(contextmenu menu, view v, contextmenuinfo menuinfo) { super.oncreatecontextmenu(menu, v, menuinfo); menu.setheadertitle("menu"); menu.add(0, edit_id, 0, r.string.menu_edit).seticon(r.drawable.edit); context menus not show icons, sorry.

javascript - jQuery mouseleave not firing correctly while dragging -

i have sortable list mouseleave event listener behaving incorrectly. if move mouse in , out of sortable list, mouseleave fires correctly. if first click , drag 1 of sortable's children, mouseleave fires incorrectly - sporadically or not @ all. any ideas? thanks. update: occurs mouseout events well. <style> #sortable { list-style-type: none; margin: 0; padding: 0; float: left; margin-right: 10px; background-color: #ccc; } #sortable li { margin: 0 5px 5px 5px; padding: 5px; font-size: 1.2em; width: 120px; } </style> <script> $(function(){ $("#sortable").sortable().disableselection(); $("#sortable").mouseleave(function(){ console.log("mouseleave"); }); }); </script> <ul id="sortable"> <li class="ui-state-default">item 1</li> <li class="ui-state-default">item 2</li> <li class="ui-state-default">item 3</li> </u...

python - app engine cron jobs not running in production -

Image
i uploaded application app engine , seems working correctly except cron jobs not running. have cron.yaml file in root directory basically: cron: - description: stuff url: /cron/dostuff schedule: every 1 minutes - description: other stuff url: /cron/dootherstuff schedule: every 1 days this maps following portion of app.yaml file: - url: /cron script: main.py login: admin which maps application in main.py says: # cron ('/cron/(.*)',handlers.cronhandler), which maps cronhandler program so: class cronhandler(basehandler): def get(self, mode=""): if mode == "dostuff": # stuff should happen here i've uploaded app google , else seems working correctly. , when hit cron urls directly (i.e., myapp.appspot.com/cron/dostuff) works correctly. cron jobs don't run on own, , when go in dashboard , view cron jobs page, see this. any idea i'm doing wrong? got figured out. "days" on own...

z index - 3 column layout, fixed vs. relative positioning CSS -

i have 3 column table layout center column being position:relative; inside center column have form needs position:fixed; (well, unless there way) what need form have liquid width when browser widens, needs stick bottom of page. so, if use position:fixed; stays @ bottom, overlaps right sidebar. if use position:relative; stays between sidebars should, scrolls page. i made little jsfiddle doesn't display fixed positioning. can see code. http://jsfiddle.net/winchendonsprings/s5zkm/1/ here can see overlap right sidebar. http://i.imgur.com/awp07.png #center { padding: 0 15px; background-color: green; position:relative; } div.main { position:absolute; bottom:0px; left:0px; right:0px; } you can try (absolute positioning within relative positioning parent). play top , bottom values position vertically. (it should resize window horizontally). want?

scala - Multiple Actors that writes to the same file + rotate -

i have written simple webserver in scala (based on actors). purpose of log events our frontend server (such if user clicks button or page loaded). file need rotated every 64-100mb or , send s3 later analysis hadoop. amount of traffic 50-100 calls/s some questions pops mind: how make sure actors can write 1 file in thread safe way? what best way rotate file after x amount of mb. should in code or filesystem (if filesystem, how verify file isn't in middle of write or buffer flushed) one simple method have single file writer actor serialized writes disk. have multiple request handler actors fed updates processed logging events frontend server. you'd concurrency in request handling while still serializing writes log file. having more single actor open possibility of concurrent writes, @ best corrupt log file. basically, if want thread-safe in actor model, should executed on single actor. unfortunately, task inherently serial @ point write disk. could more invol...

sql server - Stored procedure -

how type of return value in stored procedure. , difference between them. please explain me. typically stored procedures expect dataset. if looking way single values type of query, might better suited making udf (user defined function). nonetheless, here how can create stored procedure output variable create procedure dbo.getnamebyid ( @id nvarchar(50), @personname nvarchar(50) output ) select @personname = lastname person.contact id = @id with procedure, can execute follows. declare @name nvarchar(50) exec dbo.getnamebyid @id = 'a123fb', @personname = @name output select name = @name good luck.

C# Authentication - setting UserRole as global variable? -

our dba has sproc authentication returns user role if successful validation occurs. in custom authentication class, validateuser method hits sproc via entity model & domain service, , since sproc returns rolename on successful validation, have instance of it. when comes time run getrolesforuser method in custom roleprovider, suppose write sproc grab rolename again, seems bit redundant, since i've retrieved role. i'd love able cache user role in validateuser method, access in getrolesforuser method, , ride off sunset. not save time writing sproc, limit number of db calls app making. thoughts? scott thats correct. when running custom roleprovider, have session state can use store value of "rolename".. alternately, can extend membershipuser call include string field "rolename" can populate in first call , assign context.user. i not suggest cache object here becuase roles tied user.

javascript - jquery array confusion -

i have web page bunch of tables decorated datatable jquery plugin. when page loaded, they're hidden. have function toggles them based on index: function expand_job(i) { $(".datatables_wrapper")[i].show(); } but didn't work. browser complains show() not function. work around, i'm doing this: function expand_job(i) { $(".datatables_wrapper").each( function(idx) { if ( == idx ) { $(this).slidetoggle(300); } }); } that works fine it's..... can't let go. so why did first piece of code not work? because [i] takes jquery object , normal js object , result lost jquery functionality? thanks, use .eq() : $(".datatables_wrapper").eq(i).show(); jquery arrays contain underlying dom elements @ each index, when access them dom functions available not jquery methods.

html - CSS Selector :after -

i have 2 divs, 1 floats left other right. i need add clearfix after right float , have been reading on using :after selector. i've tried create style , add relevant attributes doesnt seem work, understanding rule incorrectly? any advice great! http://jsfiddle.net/hjp6f/ it's footer want add clear fix to: #footer:after {content: "."; display: block; height: 0; clear: both; visibility: hidden;} what you're saying here @ end of #footer div, add content , make display block, make clear both. pull footer down on floating content. update of code: http://jsfiddle.net/hjp6f/1/ .

android - Delete a view and recreate it -

is there way remove view set with setcontentview(r.layout.set_map_center); mapview = (mapview) findviewbyid(r.id.mapview); if call view again error saying: java.lang.illegalstateexception: allowed have single mapview in mapactivity try this.. first inflate view trying set in setcontentview() following code; layout = new linearlayout(context); layout.setvisibility(visible); v = view.inflate(getcontext(), r.layout.set_map_center, layout); framelayout.layoutparams params = new framelayout.layoutparams( layoutparams.wrap_content, layoutparams.wrap_content); params.gravity = gravity.no_gravity; addview(layout, params); v.setvisibility(visible); layout.setvisibility(visible); whenever want delete view can layout.setvisibility(gone) if not able access gone view.gone

.htaccess - RewriteRule but not if URL contains -

i need modify rewriterule not if parameter in url. rewriterule ^img/potm/([^/]+) timthumb.php?src=img/potm/$1&h=112&w=160&zc=1 i'm thinking, if there special parameter in match, wont it? assume has done 2 rules right? example a url contain filename, www.example.com/img/potm/blah.jpg fall through rewriterule . bad url www.example.com/img/potm/blah.jpg?fail wont parsed rule. to make rewriterule work if query string empty , have add line before rewriterule line: rewritecond %{query_string} ^$ if rule in question actual rewrite rule, this: rewritecond %{query_string} ^$ rewriterule ^img/potm/([^/]+) timthumb.php?src=img/potm/$1&h=112&w=160&zc=1

c# - WinForms message loop not responsive -

i'm deliberately abusing message loop in windows forms application, "just fun" project progressed beyond level of understanding. while task running form unresponsive. yes, there lots of other questions this, in case deliberately avoiding work on thread (to win bet against myself?) i have function runs (many) short slices of time on ui thread: get_iscomplete() checks if task complete; dowork() loops 0 1000 (just keep cpu warm). task started calling control.begininvoke(new action(continuewith), control); whereupon (tail recursively) calls until completion, running short slice of work on ui thread. public void continuewith(control control) { if (!iscomplete) { dowork(); onnext(control); control.begininvoke(new action(continuewith), control); } else { oncompleted(control); } } i expected application process other events (mouse clicks, control repaints, form moves etc.) seems calls getting more priority i...

how to change Android overflow menu icon -

Image
how change overflow menu icon on far right of action bar seen in image below? holo theme specifies 3 row black stack icon default , want else. can't seem find solution this. have looked @ documentation on http://developer.android.com/guide/topics/ui/menus.html doesn't seem lend help. thanks! define custom style: example, let's call customoverflow . in style set android:src picture use. create style parent theme.holo . in style need define: <item name="android:actionoverflowbuttonstyle">@style/customoverflow</item> i tested , works.

view - How to retrieve object's text onClickListener? -

how retrieve text view object? example, have button has text , onclick of button. want retrieve text in onclicklistener method.. use this:- button button= new button(context); button.settext(r.string.uploadimage); button.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub button b = (button) v; string buttontext = b.gettext().tostring(); toast.maketext(context, buttontext, toast.length_short).show(); } });

Live charts in Excel: for future dates, lines drop to zero -

i run live market charts in excel. graph indicator runs live data fed broker through dde facility in microsoft excel. works fine , happy - except 1 blemish hope can assist with. the lines of graph (it line chart type) created in real time. present time , past time great, clean. unfortunately in period ahead i.e. hasn't arrived yet, lines of graph drop 0 , crawl along x-axis future. spoils current reading of graph. is there way can prevent happening lines (properly called curves) exist in past , current time period. worksheet set not show 0 values in formulae, charting facility not appear have function. if put #n/a in cell (using =na() function) points not drawn. to hide ugliness of cells having #n/a in them future dates can use number format or conditional formatting hide error values. adding formula conditional formatting of =isna(a1) and setting format white font on white background. makes cells #n/a in them appear blank. versions of excel prior condit...

c# - Is all of .NET updated to use Contracts? -

since introduction of contracts .net 4.0, wondering if microsoft propagated of classes in bcl? if not, why? kind of feature makes sense if it's supported in standard library default, right? no code contracts have not been added of bcl. many of common classes have added annotation whole of bcl has not. the primary reason here time. bcl huge , adding correct contracts of bcl massive undertaking. , result, @ time, benefits small subset of .net user base. if contracts grow in popularity i'm sure usage within bcl likewise grow (yes realize not doing 1 makes other less likely) this problem mitigated though ability users declare custom contract assemblies. allows them post-annotate types missed , point code base clean contracts point of view.

c# - Populate textboxes from SQL Datasource Stored Procedure -

i have database has data first name, last name, address, etc. able use stored procedure created. here stored procedure. alter procedure edituser @uid int select * contacts userid=@uid now on page in visual studio create sqldatasource, link stored procedure, , how populate text boxes data has retrieved? not sure if should use reader , loop maybe, im not sure can help. thank you try using detailsview or formview , bind columns appropriate display controls.