Posts

Showing posts from May, 2014

javascript - Hide a message after 5000 milliseconds with jquery -

i want if message( div class="message" ) there (mean display: block; ) after 5000 milliseconds hide( display: none; ). how it? example: http://jsfiddle.net/slrft/1/ <div class="message">this message</div> settimeout(function(){ $('.message').fadeout('slow'); }, 5000); $('.message').delay(5000).fadeout('slow'); http://jsfiddle.net/xavi3r/slrft/3/

asp.net mvc 3 - Ajax.BeginForm OnSuccess not executed after Submit -

i trying use jquery dialog edit data in webgrid. everythings works fine until form submitted, instead of return current page open browser goes url of controller action. using html.actionlink in webgrid adds jquery behavior button webgrid, , works fine. opens view in jquery dialog. dialog defines 2 buttons: update button , cancel button. clicking cancel button nothing. clicking update button takes browser controller url edit action item id. have jquery.unobtrusive-ajax.js library defined , added unobtrusivejavascriptenabled key in web.config file, although not sure it's needed. has experienced behavior, appreicated! i've experienced problem in 2 situations: the event handler not being binded form's submit event, or not suppressing default behavior (through event.preventdefault(); or return false; ). there error in event handler, causing fall default behavior. well how can try without source.

php - calculate value of selected checkboxes -

Image
i have php page displaying results of mysql query. adds checkboxes each row. selected rows inserted table on submit. my application transport planning platform. looking way display total weight of selected rows in real time, box @ top of page dispalying current sum of selected rows. can guide me on how add functionality existing page. my code shown below: <?php mysql_connect("localhost", "username", "password")or die("cannot connect"); mysql_select_db("databasename")or die("cannot select db"); $sql="select `crtd dept`,`customer`,`case no`,`gross mass` despgoods_alldetails transporttypename= 'localpmb'"; $result=mysql_query($sql); $count=mysql_num_rows($result); ?> <table border=1> <tr> <td> <form name="form1" method="post"> <table> <tr> ...

jquery - jqgrid: I would like to auto select the cell my mouse is currently hovering over -

know may odd question. how auto select cell in jqgrid mouse hovering over? reason is, not sure how accomplish custom deletion of row without cell being selected first. currently have: jqgrid code snippet: gridcomplete: function(){ var ids = jquery("#breed_list").jqgrid('getdataids'); for(var i=0;i < ids.length;i++) { var cl = ids[i]; ed = "<img src=\"../images/edit.png\" alt=\"edit\" onclick=\"jquery('#breed_list').editrow('"+cl+"');\" />"; de = "<img class=\"del_row\" src=\"../images/delete.png\" alt=\"delete\" />"; ce = "<input class=\"del_row\" type='button' onclick=\"deleterow()\" />"; jquery("#breed_list").jqgrid('setrowdata',ids[i],{act:ed+de+ce}); } $(this).mouseover(function() { //do code ...

c# - What are the Pros and Cons of having one-to-many bi-direcional relationships in Entity Framework (4.1)? -

i working on new project makes use of entity framework. in love relationship inverses, having navigation properties on both types make life easier. problem is: our project manager thinks using facility may lead mistakes , advising not use it. let's have category , product: public class product { public int id { get; set; } public string name { get; set; } public virtual category category { get; set; } } public class category { public int id { get; set; } public string name { get; set; } public virtual icollection<product> products { get; set; } } he says 1 can, mistake, set productz.category categoryx , categoryy.products.add(productz), example. relationship persisted when save context? last one? ok, if first 1 correct category? , kind of error hard debug (which agree). i don't think scenario can happen respect opinion, he's way more experienced me, want convince him let have bidirectional navigation properties , argument have is: ...

ie7.js - Jquery Validation not working in IE7 -

working on site: http://changemyaddressform.com/ in regards jquery.validate , .datepicker. neither working in ie7 leads me beleive have simple wrong...can noobie? works fine in ie8, ff, safari, etc - nothing super complicated, using built in .validate() function. idea why ignoring validation attempts in ie7 , posting next page? know formatting off, working on function before form @ moment. best, scott mmm, dont know, try change button type "button" instead of submit add onclick event calling function , add validation inside. i had problems validating information when there submit button, times form submitted not matter what. way can add alert inside onclick function know if function executed or not.

.net - What does "A type cannot be be used as a standalone statement" error mean? -

this delphi prism .net. running error(s), "a type cannot be used standalone statement", , don't understand or know why. compiler pointing @ lines right below var keywords. method scriptdlgpas.executestartup; var sname:string; <------ error raised here slist:arraylist; <------ error raised here begin sname := basedir+'system\startup.scr'; if file.exists(sname) begin slist := new arraylist; executescript(slist); end; end; the google search isn't helping either. thanks in advance. there's above doesn't closed properly.

How do I change the default location for Git Bash on Windows? -

i using git on windows 7 , access repositories through git bash. how can change default location git bash opens when start it? it's time consuming navigate htdocs, , specific folder. there way change configuration file have open elsewhere? or possible write .sh file this? unfortunately git bash won't open htdocs folder shortcut on desktop, , takes 5 cd s desired directory. after installing msysgit have git bash here option in context menu in windows explorer. navigate directory , open bash right there. i copied default git bash shortcut desktop , edited start in property point project directory. works flawlessly. windows 7x64, msysgit.

jquery - How do I scroll an element with the page, but confine it to it's parent DIV? -

i using method described here: http://www.wduffy.co.uk/blog/keep-element-in-view-while-scrolling-using-jquery/ initially, can working (current cdn loaded jquery) when scrolling bottom of page sidebar element carries on scrolling down, makes page longer, scrolls down again creating infinite scroll. i want confine sidebar within parent element - in case main-container. when element hits bottom of div, want stop scrolling. i've attempted manipulate answer here: jquery scrolling div - prevent entering site footer little success. clues? #html structure <!doctype html> <html> <body> <div id="container"> <div id="content-container"> <script> $().ready(function() { var $scrollingdiv = $("#sidebar"); $(window).scroll(function(){ var y = $(this).scrolltop(), max...

sql - Detecting changes within a dataset in mysql -

i have table has time-ordered values: id date value value same hundreds of records @ strech, , i'd able determine when value changes. in other words, know when d/dx (the derivative of data) not equal 0! it seems there should common pattern can't find examples or come 1 myself. did find an example change detection done, can't use because database adapter pools connections , queries not issued on same connection. similarly, i'd rather not use database trigger. here's example table: id | date | value 1 | 2011-04-05 12:00 | 33 2 | 2011-04-06 12:00 | 39 3 | 2011-04-07 12:00 | 39 ... 72 | 2011-05-16 12:00 | 39 73 | 2011-05-17 12:00 | 37 74 | 2011-05-18 12:00 | 33 75 | 2011-05-19 12:00 | 33 ... i'm looking query pull rows values change: id | date | value 1 | 2011-04-05 12:00 | 33 2 | 2011-04-06 12:00 | 39 73 | 2011-05-17 12:00 | 37 74 | 2011-05-18 12:00 | 33 its not necessary first row included in result, since table ...

jquery - How can I get the devise error messages in a pop up -

i using jquery load signup form of devise popup. problem not able load error messages of devise in popup. if click on empty signup form redirected page see error message. i have gone through github posts of devise not find solution looking for. i have created method in application helper <%= devise_error_messages! %> code in form helper works properly. the application helper code follows :- def devise_error_messages! resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join end i know wrong cannot figure out what. can please me out one. update i think since errors not showing in pop box when hit submit button, there might issue registration controller's create action. try override default create action of registration controller of devise. lets see if works these change. update 2 made changes mentioned in update above although not working gives feeler close solution :) still waiting help. thanks, are overriding creat...

ms access - create database using C#? -

is possible create access database on c:\ drive on click event of button ??? yes can. duplicate. to create access database c# code use adox: - how create access database using adox , visual c# .net : using system; using adox; namespace consoleapplication1 { class class1 { [stathread] static void main(string[] args) { adox.catalogclass cat = new adox.catalogclass(); cat.create("provider=microsoft.jet.oledb.4.0;" + "data source=d:\\accessdb\\newmdb.mdb;" + "jet oledb:engine type=5"); console.writeline("database created successfully"); cat = null; } } } [to create sql server database c# code use sql server management objects (smo). ]

winforms - C# transparent forms -

Image
how can build transparent form windows vista weather gadget? there example this? this i'm trying achieve: i think should use wpf. winforms not suitable creating transparent forms.

regex - JQuery between limit regular expression checker? -

how can write jquery code test if given variable between given variable: min and given variable: max also test alphanumeric(a-z, a-z, 0-9) or not? ps: can check length(i value input field @ known id) test between condition, 1 better? don't need jquery problem. plain-old javascript function inrange(x, min, max){ return (x >= min && x <= max); } function isalphanumeric(str){ return /^[a-za-z0-9]+$/g.test(str); } alert(inrange(50, 0, 100)); //shows true alert(isalphanumeric("me & you")); //shows false

c - fscanf bus error: 10 when switching from Snow Leopard to Lion -

first off, snippet not meant production code. please, no lecturing "being unsafe." thanks! so, following code part of parser takes in csv , uses populate sqlite3 db. when compiled , ran in snow leopard, worked fine. i've switched lion, scanf statement throws bus error: 10. specifically, seems have how consuming , discarding '\n' @ end of each line: int main() { sqlite3* db; sqlite3_open("someexistingdb.sqlite3", &db); file *pfile; pfile = fopen("exceldata.csv","r"); char name[256],country[256], last[256], first[256], photouri[256]; char sqlstatement[16384]; while(fscanf(pfile, "%[^,],%[^,],%[^,],%[^,],%[^\n]%*c", name, country, last,first, photouri) != eof) { blah... ... if remove last %*c, meant consume '\n' , ignore advance next line, program not crash. of course incorrect parsing. also, mind you, eof doesn't seem problem; i'e tried single fscanf statement in...

ios - Hide a UIButton when another button is tapped -

how can hide uibutton on tap of button, or other event? create outlet button hide , connect in xib: iboutlet uibutton *mybutton; now create ibaction other button , connect in xib: -(ibaction)hidebutton { mybutton.hidden = yes; } so when click on second button, hide mybutton .

Remote file extension validation in ASP.NET MVC3 with C#? -

i have mvc3 application uploads file users' hard drive , manipulates it. 1 requirement file extension should .xls(or xlsx). i validate file name know best option in terms of reusability , performance (and of course best coding practices). i have following index view: @using (html.beginform("index", "home", formmethod.post, new { enctype = "multipart/form-data" })) { <br /> <p><input type="file" id="file" name="file" size="23"/></p><br /> <p><input type="submit" value="upload file" /></p> } called controller action method index : public actionresult index() { return view("index"); } and user response handled index action method ( httppost ): [httppost] public actionresult index(httppostedfilebase file) { fileservices lfileservices = new fileservices(); var lfilep...

osx - Putting the display to sleep (⇧⌃⏏/shift+control+eject) in AppleScript -

is possible write applescript put display sleep (which locks display if computer set lock on sleep)? can keyboard entering ⌃⇧⏏ ( shift + control + eject ); leaves programs, etc., running, , just turns off screen. edit 2015-08-23: possible (from shell) of os x 10.9! go see user3064009's answer update :-) there's no way this; there's a superuser question same thing. depending on why want this, however, there's 1 workaround know: activate screen saver. (this suggest on over superuser). can in applescript launch application id "com.apple.screensaver.engine" , or command line running application /system/library/frameworks/screensaver.framework/resources/screensaverengine.app/contents/macos/screensaverengine . don't know whether or not technically documented anywhere, it's worked several iterations of os now. may not want—your screen saver may, instance, colorful, isn't helpful if want black screen—but same in lock screen if ...

unicode - Why is � not listed in the Windows character table? -

Image
so there "�", replacement character 0xfffd, symbol byte-sequence not represented character in unicode (right?). well, wonder 'is' 'thing' actually, can't 'see'/'find' in windows' character table, neither searching symbol itself, nor searching fffd. after character, right? should in there. confused ... the font arial not contain corresponding glyph represent character. try different font arial unicode or arial unicode ms .

JSF validation Message Display in Dialog Box when Button click -

i need jsf validation messages displaying in dialog box when button clicked dialog box should shown not hidden. <h:form prependid="false"> <h:panelgrid columns="1" cellpadding="5"> <p:commandbutton value="modal" onclick="dlg2.show();" type="button" /> </h:panelgrid> <p:dialog header="modal dialog" widgetvar="dlg2" modal="true" height="200" width="400"> <h:panelgrid columns="1" > <p:messages /> <p:inputtext id="txt" value="#{converterbean.doublevalue}" required="true"/> <p:commandbutton ajax="false" value="submit" action="#{converterbean.submit}" /> </h:panelgrid> </p:dialog> </h:form> your case similar this example primefaces showcase . notice <h:form> inside <p:dialo...

objective c - NSDictionary: Store 3 float values for every key -

how can this? want store rgb color values can retrieved in response color name. c++ code uses boost unordered_map this: ("slateblue1", color(0.5137f, 0.4353f,1.0f)) ("tan3", color(0.8039f, 0.5216f, 0.2471f)) ("grey32", color(0.3216f, 0.3216f, 0.3216f)) color class stores 3 values. trying in objective-c tying me in knots , weird errors! of dictionary examples i've found matching 2 strings. of course can use c++ code in .mm file, if has ideas how achieve obj-c way, i'd pleased learn, thanks. it's same in cocoa - use nsdictionary instead of unordered_map, nsstring instead of const char* key , uicolor instead of color object , you're done. e.g., [nsdictionary dictionarywithobject: [uicolor redcolor] forkey: @"red"]] create single-entry map. adjust multiple colors , you're set. use nscolor if you're not on ios. you might missing key point dictionary (almost) untyped collection, can store heterogenous set...

iphone - Change the navigation bar's font -

the question plain easy , simple, answer unfortunately not. how can change font of text in uinavigationbar ? from ios 7 , later: nsshadow* shadow = [nsshadow new]; shadow.shadowoffset = cgsizemake(0.0f, 1.0f); shadow.shadowcolor = [uicolor redcolor]; [[uinavigationbar appearance] settitletextattributes: @{ nsforegroundcolorattributename: [uicolor greencolor], nsfontattributename: [uifont fontwithname:@"helvetica" size:20.0f], nsshadowattributename: shadow }]; from ios 5 , later: [[uinavigationbar appearance] settitletextattributes: @{ uitextattributetextcolor: [uicolor greencolor], uitextattributetextshadowcolor: [uicolor redcolor], uitextattributetextshadowoffset: [nsvalue valuewithuioffset:uioffsetmake(0.0f, 1.0f)], uitextattributefont: [uifont fo...

ios - iOS4 iPhone turn screen off, keep accelerometer on -

i know has been asked before, answers see 2 years back. i'll rephrase question: are there new power management apis in ios4 can take advantage of turn off screen? -overlaying black view on top of existing view still drives screen's backlight , refresh rate. can let device screen timeout , run app in background? need collect accelerometer data. thank you! as far know can't collect accelerometer data while phone locked. there no power management apis. i found tho give trick of using proximity sensor doesn't seem reasonable solution. enable iphone accelerometer while screen locked

c++ - Handle Alt Tab in fullscreen OpenGL application properly -

when trying implement simple opengl application, surprised while easy find plenty of examples , documentation on advanced rendering stuff, win32 framework poorly documented , samples , tutorials not implement basic cases, not mentioning advanced stuff multiple monitors. despite of several hours of searching unable find way handle alt-tab reliably. how should opengl fullscreen application respond alt-tab? messages should app react (wm_activate, wm_activateapp)? should reaction be? (change display resolution, destroy / create rendering context, or destroy / create opengl resources?) if application uses animation loop, suspend loop, minimize window. if changed display resolution , gamma revert settings before changing them. there's no need destroy opengl context or resources; opengl uses abstract resource model: if program requires ram of gpu or other resources, programs resources swapped out transparently. edit: changing window visibility status may require reset...

iphone - how to set current scrolling values -

if have uiscrollview , move around specific location, there way position has moved too? check uiscrollview's contentoffset property: contentoffset - point @ origin of content view offset origin of scroll view. get current uiscrollview scroll values on iphone

c# - How to determine distributed architecture? -

i'm trying head around thought process when designing large scale application. let's have client needs new customer website , estimating 40,000 orders per day 25,000 user base. when desiging application, how determining if distributed architecutre needed? should use web farm? etc. i've build 2 tier (physical) applications in past , want improve understanding. any insight great! it's going depend on lot of other factors number of orders per day. hosted? physical architecture like? else application besides ecommerce? need integrate other applications (besides payment gateways of course)? etc. a simple 2 tier application in right cloud hosting environment (say vmware instance) can scale dynamically work fine ecommerce website. simple 2 tier application in right on-premises hosting environment (load balanced web farm) should work fine ecommerce website. it's difference between scaling (potentially hidden virtualization, ends being scale out of sorts...

sql - Scope of derived tables -

i have complex sql query, we'll need return number of columns, , each represents different row table. derived tables need filtered value, bring ones account. following works great: select currentbalance.value, currentbalance.customer, debt30balance.value expr1, debt30balance.customer expr2, debt60balance.value expr3, debt60balance.customer expr4, debt90balance.value expr5, debt90balance.customer expr6, wipcurrent.value expr7, wipcurrent.customer expr8, wip30days.value expr9, wip30days.customer expr10, wip60days.value expr11, wip60days.customer expr12, wip90days.value expr13, wip90days.customer expr14 (select top (1) value, customer debtbreakdown ( customer = @customerid ) , ( type = 0 ) order timestamp desc) currentbalance inner join (select top (1)...

android - Image button focus isn't working -

i'm brand-new android, , i've been trying make image button 3 images, default, focused, , pressed. i've tried lot of examples i've found, can't seem make button respond focus. i found following example on forum, , displays button, , responds being pressed, doesn't change on focus. can tell me why? are using selectors changing drawable behind button? example, did use android:src="@drawable/selector1 . selector code button should (more description here) : <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android="http://schemas.android.com/apk/res/android" > <item android:state_pressed="true" android:drawable="@drawable/but1_pressed" /> <item android:state_focused="true" android:drawable="@drawable/but1_focused" /> <item android:drawable="@drawable/but1_default" /> </selector> ...

bash - How to wrap another shell still passing $OPTIND as-is? -

i'm trying wrap bash script b script a. want pass options passed b are. #!/bin/bash # script ./b ${@:$optind} this print $1 (if any). what's simplest way not to? so calling: ./a -c -d 5 first-arg i want b execute: ./b -c -d 5 # without first-arg in bash, can build array containing options, , use array call auxiliary program. call_b () { typeset -i i=0 typeset -a a; a=() while ((++i <= optind)); # i=1..$optind a+=("${!i}") # append parameter $i $a done ./b "${a[@]}" } call_b "$@" in posix shell (ash, bash, ksh, zsh under sh or ksh emulation, …), can build list "$1" "$2" … , use eval set different positional parameters. call_b () { i=1 while [ $i -le $optind ]; a="$a \"\$$i\"" i=$(($i+1)) done eval set -- $a ./b "$@" } call_b "$@" as often, rather easier in zsh. ./b "${(@)@[1,$optind]}"

c - How do I get DOUBLE_MAX? -

afaik, c supports few data types: int, float, double, char, void enum. i need store number reach high 10 digits. since i'm getting low 10 digit # int_max , suppose need double. <limits.h> doesn't have double_max. found dbl_max on internet said legacy , appears c++. double need? why there no double_max? dbl_max defined in <float.h> . availability in <limits.h> on unix marked "(legacy)". (linking unix standard though have no unix tag since that's found "legacy" notation, of shown there float.h in c standard c89)

Is there a limit excution time when I run a PHP Script by Cron Jobs? -

is there limit excution time when run php script cron jobs? for example, need backup big database file through php script. set cronjobs automatically run everyday. my question, php script run until ok? how set cron job scripts printing (especially errors or exceptions) standard out. experience cron systems email output of script whatever local user running script. have mail forwarded work account notify me script ran , if there errors. basic maintenance scripts run daily or weekly i've found quick, effective way keep me updated on status.

css - Can I target a :before or :after pseudo-element with a sibling combinator? -

is there reason why css doesn't work? http://jsfiddle.net/6v5bz/ a[href^="http"]:after { content:""; width:10px; height:10px; display:inline-block; background-color:red; } a[href^="http"] img ~ :after { display:none; } .. on html? <a href="http://google.com">test</a> <a href="http://google.com"> <img src="https://www.google.com/logos/classicplus.png"> </a> the idea have pseudo-element on matching anchor tags. not want apply anchor tags wrap image. , since can't target anchors using a < img , figured maybe target :after pseudo-element finding image it's sibling of. any insight appreciated. you can't target :after since it's content not rendered in dom , not manipulate - work dom have re-rendered , css can't manipulate this. check specification detailed understanding: http://www.w3.org/tr/css2/generate.html#propdef-co...

encryption - How to decrypt sha1-encrypted String in Java -

is possible decrypt string earlier encrypted sha-1 algorithm in java? sha1 cryptographic hash function , , entire point can't undo it. if possible reverse hash (find input given hash), wouldn't useful. if need encrypt , later decrypt it, should use encryption function aes or rsa . however, simple inputs may possible crack hash function guessing input , checking if hash same. example python code: def crack_hash(hash_to_crack, hash_function, list_of_guesses): # try hash in our guess list guess in list_of_guesses: new_hash = hash_function(guess) # if hashes match, found if new_hash == hash_to_crack: return guess # if none of them match, give return none of course, if want crack hashes efficiently, using software john ripper or hashcat best bet. note works on passwords since they're short , easy guess, difficulty increases exponentially input increases. can crack every sha-1 hash 6-character input in ...

iphone - Reload current view with tab bar -

is possible create refresh button in tab bar refreshes current view? , don't change view? how done? cheers! you can uitabbar , - (void)tabbar:(uitabbar *)tabbar didselectitem:(uitabbaritem *)item delegate method. i won't suggest doing that, though, because that's not how tabbar works. since want act tool bar, why not use uitoolbar ?

iis 7 - wcf service hosted under IIS address -

i have wcf service hosted under iis. have following configuration: <services> <service name="billboardservices.loginservice" behaviorconfiguration="loginservicebehavior"> <host> <baseaddresses> <add baseaddress="http://myip/loginservice/" /> </baseaddresses> </host> <endpoint address="" name="loginservice" binding="basichttpbinding" contract="billboardservices.iloginservice" /> <endpoint contract="imetadataexchange" binding="mexhttpbinding" address="mex" /> </service> if enter http://myip/loginservice/ , 404. if enter http://myip/service1.svc , service metadata. what changes configuration need in order service accessible through nice url? thank you. in order have , extensionless service, need use wcf 4 , init routing engine in glob...

configuration - Custom Start Number for Order Numbers in Magento 1.5 -

how customise starting number orders, invoices etc in magento 1.5? magento's forum: by lindykyaw (magento team member) , changing start number (through sql query): there table in database stored increment id of order. called “eav_entity_store” table. can check entity type id belongs entity looking @ eav_entity_type table. can run following query update last increment id order. update eav_entity_store inner join eav_entity_type on eav_entity_type.entity_type_id = eav_entity_store.entity_type_id set eav_entity_store.increment_last_id=3001 eav_entity_type.entity_type_code='order'; by fooman (active contributor) , changing start number (through db management tool) , removing "0"s @ beginning: with tool phpmyadmin @ database. in table eav_entity_type find entity types listed. 1 of interest change order number starts order sales/order. remember entity_type_id (in install 11). remove leading zeros (padding) set increment_p...

java - Map Reduce Couch Db -

i have simple database couch db. have users have fields: string username string password string mail boolean admin i keep users @ db. new couch db , nosql. how can implement map reduce on example (or internally , don't need anything?) i use spring 3 , ekorp application. in couch, add field in documents called _type or type_ the map function be function(doc) { if(doc.type_=="user") { emit(doc.name,doc._id); } }

c# - Can Entity Framework create Objects with default values for Non-Null columns? -

Image
i thought saw somewhere being able generate object in ef non-null values filled in generic values. i tried using context.createobject<myentity>() , still getting errors trying save null data non-null column. was mistaken in thinking this? or have wrong syntax? in model designer, can enter default value on property sheet each field.

java - Trying to shuffle a "Deck" class, doesn't seem to be shuffling -

i've written deck class , have shuffle it, , print out few hands check how works. however, doesn't seem shuffle anything, rather give exact same deck. public void makehands () { deck deck = new deck (); deck shuffled = shuffledeck (deck); printdeck (subdeck (shuffled, 0, 4)); printdeck (subdeck (shuffled, 5, 9)); printdeck (subdeck (shuffled, 10, 14)); printdeck (subdeck (shuffled, 15, 19)); } public static int randomint (int length, int i) { double x = math.random () * length; int g = (int) x; return g; } public deck shuffledeck (deck deck) { (int i=0; i<deck.cards.length; i++) { int g = randomint (deck.cards.length, i); swapcards (i, g); } return deck; } } public void swapcards (int first, int swap) { card temp = cards[first]; cards[first] = cards[swap]; cards[swap] = temp; } the code looks incomplete. it looks need pass deck object swapcards method. swapcards(...

sending increment value from jquery to php file with for loop help -

i have loop in jquery $(document).ready(function() { for(i=0; i<counter; i++) { datacounter = i; $.ajax({ url: 'file.php', datatype: 'json', data: datacounter, error: function(){ alert('error loading xml document'); }, success: function(data){ $("#contents").html(data); } }); } }); and want bring in datacounter file.php variable , have change each time can different records in mysql in file.php, doing right? how php portion like? know how pass variables php file method if had form, don't have or post form work with. also, variables going change. can me? thank you! while don't recommend running ajax query inside of loop, wiling explain data option $.ajax() . ideally, pass object data option, , translated jquery qu...

php - What Code Runs After Executing a Dataflow Profile -

often, after executing dataflow import profile (for products), next request user makes in admin console slower normal requests. what's weird is, seems tied particular browser session . i.e. if you're logged admin console in browser, system responsive. what code or processes running slow down subsequent magento requests? can think of dozen things (indexing, cron, etc.), i'm looking specific areas of code tie session, , code doing. my guess in parser there loop on csv file updates session, on bright side @ least realized comment out initializing models in iteration loops , add them before: class mage_dataflow_model_session_parser_csv extends mage_dataflow_model_convert_parser_abstract { public function parse() { $fdel = $this->getvar('delimiter', ','); $fenc = $this->getvar('enclose', '"'); if ($fdel=='\\t') { $fdel = "\t"; } // fixe...

How do I conditionally create a new instance of a class in C# asp.net? -

i have class different constructors. 1 constructor, nothing passed through (creating new record), other id passed through (which used update). i'd test condition , make new instance of class object based on outcome. problem object doesn't carry out of if statement. protected void position() { if (session["positionid"] == null) { jobposition p = new jobposition(); } else { jobposition p = new jobposition(convert.toint32(session["positionid"])); } p.positiontitle= ptitle.text; p.positionmission= pmission.text; p.positiondepartment= pdept.text; session["positionid"] = convert.tostring(p.savedb()); } p cannot used in current context. copy code each condition, seems shouldn't need that. how can use p ? you need move declaration of p above if statement: jobposition p; if (session["positionid"] == null) { p = new jobposition(); } else { p = new jobpos...

.net - CIL - What is the difference between ldc.i4 33 and ldc.i4.33? -

i'm trying figure out cil code. seems these 2 statements same thing (according have read). ldc.i4 33 and ldc.i4.33 both supposedly "load int32 onto stack of value 33". is correct? why? have thought ldc.i4.33 "load integer local variable index 33 onto stack". where going wrong here? the opcode ldc.i4.33 doesn't exist. there's few special (called macro) opcodes, from: ldc.i4.m1 // has same effect as: ldc.i4 -1 to ldc.i4.8 // has same effect as: ldc.i4 8 but short form of ldc.i4 opcode, common cases, optimize cil size. similarly, ldloc.0 short form (i.e. has more compact cil encoding, doing same as) ldloc 0 , etc.

Reading numbers from file in C -

i python programmer, i've been working c because python slow graphics (20 fps moving fractals ftw). i'm hitting sticking point though... wrote little file in hex editor test with. when try reading first byte, 5a, correctly gives me 90 program this... #include <stdio.h> #include <stdlib.h> #include <math.h> file *data; int main(int argc, char* argv[]) { data=fopen("c:\\vb\\svotest1.vipc","r+b"); unsigned char number; fread(&number,1,1,data); printf("%d\n",number); } but when try reading first 4 bytes, 5a f3 5b 20, integer 542896986 #include <stdio.h> #include <stdlib.h> #include <math.h> file *data; int main(int argc, char* argv[]) { data=fopen("c:\\vb\\svotest1.vipc","r+b"); unsigned long number; fread(&number,1,4,data); printf("%d\n",number); } it should 1525898016!!! problem has reversed byte order. gah! of course! way program wo...

c++ - how to parsing of xml in mosync ide -

i sending request server , receive response form of xml want parse method should prefer... if question "how parse xml" use simple expat (sax parser) or plug more sophisticated xerces (sax & dom parser) or libxml2. from headline seems using mosync, provides xml parsing http://www.mosync.com/documentation/tutorials/processing-xml if question "how choose between sax , dom parsing" read wikipedia articles on sax http://en.wikipedia.org/wiki/simple_api_for_xml , stating benefits , drawbacks. comes down "sax requires less resources dom might easier use". otherwise please describe problem in more detail.

c# - Gridview Data Update by textbox -

when trying update datagridview textbox value shows empty value in textbox code this.wt's wrong in this. bnddata() has dataset assign gridview protected void gridview1_rowediting(object sender, gridviewediteventargs e) { gridview1.editindex = e.neweditindex; bnddata(); } protected void gridview1_rowupdating(object sender, gridviewupdateeventargs e) { gridviewrow row = (gridviewrow)gridview1.rows[e.rowindex]; string emailid = gridview1.rows[0].cells[0].text; textbox txtadress = (textbox)row.findcontrol("txtadress"); con.open(); string upd = "update empeasty set adress='" + txtadress.text+ "' emailid='"+emailid+"'"; sqlcommand cmd = new sqlcommand(upd,con); int i=cmd.executenonquery(); if (i > 0) response.write("data updated"); else response.write("data not updated...

html - image takes up whole table cell width and height in CSS -

how can make image takes whole table cell width , height if image size smaller table cell? image inside div tag. try following css - example here -> http://jsfiddle.net/pq67x/1/ <style> div { width:50px; height:100px; } div img { height:100%; width: 100%; max-width:100%; max-height:100%; } </style> <div> <img src='path/to/img.gif' /> </div>

osx - How to detect if the A,S,D or/and W button is pressed in cocos2d-mac? -

i want move ccsprite/b2body w , a , s , d keys in cocos2d mac . how can detect if 1 of these buttons pressed? can user press multiplie keys @ simultaneous? can cocos2d mac handle multiplie keys when pressed? thank much check out: cocos2d handling events (it detects none, one, or several keys pressed @ same time) find key codes mac keyboard

JavaScript block scope vs function -

are following snippets equal? if no deference? var x = (function() { ... //a return function(){ ... //b }; })(); vs. var x; { ... //a x = function(){ ... //b }; } there major difference: in javascript, blocks don't induce new variable scope. therefore, can't define private variables in // a code block. compare var x = (function() { var v = 42; return function(){ return v; }; })(); // v; yield referenceerror: v not defined, need call x and var x; { var v = 42; x = function(){ return v; }; } // v 42 here, that's not what's intended.

Does .NET have something similar to what Azul provides for Java? -

azul provides highly scalable java solutions claim provide performance large applications, both memory , core wise, opposed standard oracle java on x86 hardware. is there similar in .net world? i know microsoft has cloud solution, scale equally well? no, best of knowledge there isn't comparable azul or zing .net. part of azul got started making proprietary cpus optimized java jvm . here video that, , why x86 / x64 architecture has ... issues in modern use. however, proprietary hardware product doesn't seem successful in market. guess zing described strategy pivot azul: original plan sell proprietary hardware matching highly optimized jvm. they're focused on leveraging optimized jvm, , sell use on regular x86 machines. @gamlor right 1 of main selling points of zing "hitless garbage collection", or garbage collection doesn't make jvm pause. i'm not aware of pushing .net. perhaps answer regarding .net vs java gc interesting. you mo...

wpfdatagrid - Is ScrollIntoView synchronized in virtualstackpannel (Especially in WPF DataGrid)? -

we have problem focus cell of datagrid after data of bounded collection has refreshed. example set filter collection , want refocus stored cell of stored column. is true think call scrollintoview synchronized means after call our desired row , cell created , can set focus? (again means after call scrollintoview , true think itemsgenerator finished work , can surly find our desired cell) $ //set filter of datagrid collection datagrid_standard.scrollintoview(rownumber,cellnumber); //we sure our desired cell created datagridrow row = (datagridrow)datagrid_standard.itemcontainergenerator.containerfromindex(index); if (row == null) { // may virtualized, bring view , try again datagrid_standard.scrollintoview(datagrid_standard.items[index]); row = (datagridrow)datagrid_standard.itemcontainergenerator.containerfromindex(index); } datagridcellspresenter presenter = getvisualchild<datagridcellspresenter>(rowcontaine...

CSS3 Support for Windows Phone 7 IE -

i know sort of css3 transformation properties hardware accelerated in latest ie in windows phone 7 mango update. information seems found. there isn't around this, imagine computationally intensive transformations if anything: out of list of css3 features supported mentioned on ie9 mobile article here , maybe 2d transforms? in case, why information on css3 transforms hardware accelerated useful? seems kind of weird/counterintuitive designing css based on whether accelerated or not?

vb.net - Retrieve datatable.column value in rpt_RowDataBound sub in asp.net -

based on selected answer in post displaying records grouped month , year in asp.net , have modification work with. in rpt_rowdatabound sub, instead of using fileinfo object, need use database value ("statusupdate"). if month <> trycast(e.item.dataitem, fileinfo).creationtime.month orelse year <> trycast(e.item.dataitem, fileinfo).creationtime.year how can replace " fileinfo " in above code line datarow("statusupdate") code: html: <asp:repeater id="rpt" runat="server" onitemdatabound="rpt_rowdatabound" visible="true"> <itemtemplate> <table width="100%" runat="server" visible="true" id="headertable"> <tr> <td colspan="3" style="color: white;" class="textfont"><asp:label id="headertitle" runat="server"></asp:label></...

haskell - Conversion between Int and fractional values -

i programming in haskell , having trouble following code: exactrootlist :: int -> int -> [int] exactrootlist ini end = [x | x<-[ini .. end], (floor (sqrt x)) == (ceiling (sqrt x))] then, when execute: > hugs myprogram.hs i get error instances of (floating int, realfrac int) required definition of exactrootlist i not understand error. my program should show list of numbers have exact root 4 or 9, on interval [a, b] , b 2 params of function. example: exactrootlist 1 10 it must return 1 4 9 because between 1 , 10 1, 4 , 9 have exact root. greetings! if @ type of sqrt see works on types instance of floating : > :t sqrt sqrt :: floating => -> as know, int not floating point value. need convert ints (the variable x ) using fromintegral : [x | x<-[ini .. end], let = fromintegral x in (floor (sqrt a)) == (ceiling (sqrt a))]

iphone - Button click not working when in presence of single Tap gesture -

i have view hierarchy follows myviewcontroller --> scrollview(added via ib) --> imageview (+ zooming there) ---> button added on image view (added via code) imageview = [[uiimageview alloc] initwithimage:[uiimage imagenamed:@"map.png"]]; [scroll addsubview:imageview]; uibutton *mybutton = [uibutton buttonwithtype:uibuttontyperoundedrect]; mybutton.frame = cgrectmake(660, 120, 40, 40); [mybutton settitle:@"10" forstate:uicontrolstatenormal]; [mybutton addtarget:self action:@selector(asiapressed:) forcontrolevents:uicontroleventtouchupinside]; [mybutton setenabled:yes]; [imageview addsubview:mybutton]; later on in view controller, defined selector as -(void) asiapressed:(id)sender{ nslog(@"asiapressed clicked"); } but never going inside selector.. pls help...i guess basic error.. thanks in advance uiimageview has userinteractionenabled property set no default (and subviews) not receive touch events. need set propert...

c++ - How is this private data member of a base class being accessed by a derived class? -

i have private data member called balance in base class called bankaccount. wanted derived class checkingaccount able use balance made protected i've noticed derived class seems able still access balance when put in private section of base class. thought impossible? know muight going on? base class: class bankaccount { public: bankaccount(); void setaccountinfo(int accountnumtemp, double balancetemp); void applytransaction(char accounttype, char transactiontypetemp, int amounttemp, int j); private: int accountnumber; double balance; }; derived class: class checkingaccount: public bankaccount { public: checkingaccount(); double applytransaction(char transactiontypetemp, int amounttemp, int c, double balance); private: float interestrate; int minimumbalance; float servicecharge; }; base class function member derived class function member receives datamember in question: void...

php - Zend MVC:: How can javascript file + javascript code inserted to partial for head or body area? -

how can javascript file + javascript code inserted partial head or body area? [inside view call insert head headscript , body inlinescript - not works inside partial(if wrong please write). ] thanks, yosef i have not tried this, have tried using following code inside partial $view = zend_layout::getmvcinstance()->getview(); $view->headscript()->appendfile('/scripts/somefile.js'); i know saying doesn't work, maybe method getting view instance? in theory should work.

c# - What's the purpose of the Expression class? -

i'm wondering difference between wrapping delegate inside expression<> , not ? i'm seeing expression<foo> being used lot linq, far i've not found article explains difference between this, , using delegate. e.g. func<int, bool> is42 = (value) => value == 42; vs. expression<func<int, bool>> is42 = (value) => value == 42; by storing lambda delegate, storing specific instance of delegate action. can't modified, call it. once have delegate, have limited options in inspecting , whatnot. by storing lambda expression, storing expression tree represents delegate. can manipulated other things changing parameters, changing body , make radically different. compiled delegate may call if wish. can inspect expression see parameters are, , how it. query provider can use understand , translate expression language (such write sql query corresponding expression tree). it whole lot easier to create delegate dynamically ...

Sql NTILE() function with Postalcode -

Image
i trying split records in equal number of decks. works fine sql ntile(20) function. issue splits post code well. splitting should happen within postcode. select (ntile(20) over(order postalcode asc)) 'decknumber' xxx order postalcode any ideas how solve ? if you're using sql server - should able this: select ntile(20) over(partition postalcode order postalcode asc) 'decknumber' dbo.xxx order postalcode this "partition" data groups postalcode , , inside each group, ntile(20) function applied. maybe want use different order by clause inside ntile...over() function - since you're partitioning postalcode , ordering doesn't make whole lot of sense...

ajax - jQuery timeout: e.nodeName is undefined -

<script type="text/javascript"> var delay = (function() { var timer = 0; return function(callback, ms) { cleartimeout(timer); timer = settimeout(callback, ms); }; })(); $(function() { $('#activity').change(function() { $(this).val() == "sid" ? $('.sidcontainer').show() : $('.sidcontainer').hide(); }); $('.sid').keyup(function() { delay(function() { $.ajax({ url: '../sentineloperationsui/generichandler.ashx', data: { 'sid': $(this).val() }, datatype: 'json', success: function(data) { if (data.sid != null) { $('.sidresult').text('match: ' + ' sid: ' + data.sid); console.log(data); } } }); }, 500); }); }); the code works without de...

java - Modify the HTML of a servlet's errorPage from a Filter -

i have requirement rewrite html generated web application. requirement applies pages equally naturally went filter. i cribbed stream wrapping approach oracle documentation on filters , works cases. unfortunately, if servlet throws exception flow of execution leaves filter , rewriting logic not executed. means html of error pages not modified. i want intercept error page response well. how do that? try adding filter-mapping : <dispatcher>forward</dispatcher> <dispatcher>error</dispatcher>

resources - Android - Cascading drawable folders and default drawables -

i have following drawable folders /drawable/ /drawable-hdpi/ /drawable-ldpi/ /drawable-mdpi/ /drawable-xhdpi/ if have image resource, need create 5 (or 4?) different resolution versions of file? let's make 2 versions , put them in respective folders: /drawable/ /drawable-hdpi/image.png /drawable-ldpi/ /drawable-mdpi/image.png /drawable-xhdpi/ what happens when on ldpi or xhdpi device visits activity needs display image.png ? not show it? app crash? or android follow resource cascading system, show version nearest current screen density? also, in case don't have image.png in /drawable/ folder. bad? should every single resource have (at minimum) version in /drawable/ folder? also, if have specified 4 screen density drawable folders (xhdpi, hdpi, mdpi, ldpi), point of normal /drawable/ folder? when ever used? if have image resource, need create 5 (or 4?) different resolution versions of file? no, don't have to what happens when on ldp...

Question about implementing abstract functions in C++? -

i learning , testing piece of c++ code follows: #include "stdafx.h" #include <iostream> using namespace std; #include <conio.h> #include <cstring> class shape { public: shape() {}; ~shape() {}; virtual void display() const = 0; virtual double volume() const = 0; }; class square : public shape { public: square() {}; ~square() {}; void display() const; double volume() const; }; void square::display() const { cout << "square!!!!!!!!!!!!!!" << endl; } double square::volume() const { cout << "square volume........." << endl; return 0.0; } int _tmain(int argc, _tchar* argv[]) { shape *s; s = new square; // error here (*s).display(); return 0; } the above code not compile successfully. produces: " fatal error lnk1120: 1 unresolved externals ". can me out that? using ms vs c++ 2005. thanks the above code compiles , runs on vs 2010 id...