Posts

Showing posts from September, 2012

.net - What is the proper way to manually check and uncheck a RadioButton when the AutoCheck property is set to false in C#? -

i have set of radio buttons, , 2 of them need prompt user confirmation dialog before allowing value change. this, handle click event , set autocheck property false on each of these radio buttons. however, selected radiobuttons no longer unchecked when set check property true on clicked radiobutton. right i'm looping through controls on panel , making sure none of other radiobuttons checked, there more efficient way this? you can use variable store last checked radiobutton: //first, have set lastchecked = radiobutton1 (or of radiobuttons) radiobutton lastchecked; //click event handler used radiobuttons private void radiosclick(object sender, eventargs e) { radiobutton radio = sender radiobutton; if (radio != lastchecked){ radio.checked = true; lastchecked.checked = false; lastchecked = radio; } //else radio.checked = !radio.checked; } if want allow user uncheck radio (a strange behavior), remove // before else clause in code

c++ - "printf" appears to be non-deterministic in Qt? -

i know "printf" standard-c , should deterministic. when run in qt see more non-deterministic response(clock cycles). due qt adding "pork" response? i have multiple threads make call function uses mutex. when 1 thread enters set switch others can't until done. things appeared work ok acouple seconds , threads appeared killed off 10 1 thread. tried adding delay: (k=k+1: no help), (looping k=k+1: no help), (usleep works), , (printf) work @ creating random delay , allowing threads continue running. void ccb::write(int ithread) { static bool buse = false; bool bdone = false; char cstr[20]; int poswrite;// = *m_poswrite; // issue of poswrite altered next extrance long k = 0; long m = 0; m_threadcount++; while(bdone == false){ if(buse == false){ buse = true; poswrite = *m_poswrite; memcpy(m_cmmessagecb + poswrite, &m_cmmessagewrite, sizeof(typecanmessage)); me

jQuery width toggle moves the div to the left -

i have script http://jsfiddle.net/z8cuz/2/ code: $('.list').hide(); $('.close').hide(); var widthval = false; $('#left').click(function () { if (widthval == false) { $('#middle').hide('fade', 300); $('#right').hide('fade', 300, function () { $('#left').find('.list').show(); $('#left').find('.close').show(); $('#left').animate({ width: "96%", opacity: 1 }, 1000); }); widthval == true; } }); $('#middle').click(function () { if (widthval == false) { $('#left').hide('fade', 300); $('#right').hide('fade', 300, function () { $('#middle').find('.list').show(); $('#middle').find('.close').show(); $('#middle').animate({

regex - tcl: parse string into list -

i'm trying parse string flat list in tcl. the string has format of name1='value1',name2='value2',name3='value3' i'm wondering if there's way capture names , values list looks this: {name1 value1 name2 value2 name3 value3} note name or value may contain includes characters ' or = or , well, possible set data {name1='value1',name2='value2',name3='value3'} foreach {- key value -} [regexp -all -inline {(.*?)='(.*?)'(,|$)} $data] { lappend result $key $value } note : if key occurs once, suggest using dicts ( dict set result $key $value ).

asp.net mvc - ExactTarget - How to add dynamic user created content in an Email Template -

we have email being created in end code (c#) , sent through exacttarget api. want move template in exacttarget don't have maintain html written in stringbuilder() in c#. issue content of email determined user inputs. user fills out form of samples want email sent person fulfill order. so example be: <tr> <td>product number</td> <td>quantity</td> </tr> <tr> <td>product number</td> <td>quantity</td> </tr> the maximum number of samples can ordered 16. there way loop through content posted exacttarget create correct number of rows instead of hard coding 16 rows template , half of them being blank. please let me know if need more specific anything you try creating partial view below, @model ienumerable<cartitems> <table> @foreach(var item in model) { <tr> <td>@item.number</td> <td>@item.quantity</td> <tr> } </ta

loops - Populating Bash array fails -

here simple command running in bash, array won;t populated reason. array=() && sudo iwlist wlan0 scan | grep 'address'| while read line; array[${#array[@]}]=$line; done i have tried populate array way: array=() sudo iwlist wlan0 scan | grep 'address'| while read line; array+=($line); done but gives me same result. know works because when this: sudo iwlist wlan0 scan | grep 'address'| while read line; "echo $line"; done it print every line piped grep while loop. when check size of array " echo ${#array[@] " show 0 , if print array prints nothing. see errors in line? **update. got working using loop so: for line in $(sudo iwlist wlan0 scan | grep 'address' -a5); array+=($line); done bash faq entry #24: "i set variables in loop that's in pipeline. why disappear after loop terminates? or, why can't pipe data read?" the while loop [...] executed in new subshell own copy of varia

java - Append an element in a XML using DOM keeping the format -

i have xml this <?xml version="1.0" encoding="utf-8" standalone="no"?> <empleado> <consultortecnico> <nombre>pablo</nombre> <legajo antiguedad="4 meses">7778</legajo> </consultortecnico> <cnc> <nombre>brian</nombre> <legajo antiguedad="1 año, 7 meses">2134</legajo> <sueldo>4268.0</sueldo> </cnc> </empleado> what want read xml , append "sueldo" @ same level "nombre" , "legajo" in element "cnc". "sueldo" must "legajo" x 2 the code have appends "sueldo" can see in xml above not indent should, im using propierties indent (this xml created same way, using dom) public class main { public static void main(string[] args) { try { file xml = new file("c:\\empleado.xml"); if (xml.exists()

ios - How to let a thread A wait until thread B is finished, then continue thread A? -

within thread call asynchronous service, runs in thread b. service calls delegate method once finished. want thread wait until thread b finishes. used nscondition this. this set (skipped unimportant stuff): -(void)load { self.somecheckistrue = yes; self.condition = [[nscondition alloc] init]; [self.condition lock]; nslog(@"log1"); service *service = // set service [service request:url delegate:self didfinishselector:@selector(response:)]; while (self.somecheckistrue) [self.condition wait]; nslog(@"log3"); [self.condition unlock]; } -(void)response:(id)data { nslog(@"log2"); [self.condition lock]; self.somecheckistrue = no; // response, doesn't matter here [self.condition signal]; [self.condition unlock]; } for reason, "log1" printed, neither "log2" nor "log3". assume it's why delegate method response called "service thread",

Windows - How to copy one file from each sub-folder (Sampling) -

i know how java, open each folder , copy first file , next folder , on. what want know if possible batch file? (e.g. for loop) to clarify again, let have folder of 1000 sub-folders , each folder includes many files (with same format , different names). want copy sample file of each folder in destination folder. @echo off &setlocal /d %%a in (*) ( set "folder=%%~a" %%b in ("%%~a\*") set "file=%%~b" setlocal enabledelayedexpansion copy "!file!" "x:\target folder" endlocal )

c++: public private error -

so i've got problem. want variables diferant class main , i've lerned it's hide data wont easely changed , use getxxx function acces it. tried use private: , public: thing when error saying error: expected unqualified-id befor 'private' i got class nr1# called dialog , class variables called race (not in black , white) anyway call function this: (class dialog) above #include stuff dialog::dialog(int y) { race raceo; switch(y) { case 1: cout << "choose class \n1 elf = " << raceo.getstats(1.1) << endl; break: } and race class //were supposed put private: , public: include "race.h" include <iostream> include <string> using namespace std; race::race(){ } int race::raceelf(){ return 0; } int attack = 5; int defence = 3; int stamina = 6; int race::getstats(int x){ if(x == 1

VBScript - Find specific term in between commas in .csv and append columns based on values found -

i trying append additional columns existing .csv file called original.csv, values appended should vary base on whether n or j part of value between 4th comma , 5th comma in original.csv (technically 5th column if file opened in excel). below codes wrote. don't work, it's reference only. in advance help. rowcounter = 1 until objoriginal.atendofstream stroriginal = objoriginal.readline arroriginal = split(stroriginal, ",") arrtype = split(arroriginal(5),",") strtype = arrtype(1) if istrue(instr(strtype,"n")) stroriginal = objoriginal.readline & ",type n,usd" objposition.writeline(stroriginal) else stroriginal = objoriginal.readline & ",type j,usd" objposition.writeline(stroriginal) end if rowcounter = rowcounter + 1 loop the proper tool .csv files ado. need create new (text) table appending columns existing table sql statement like: select s.

c# - Programming model - Manager + Tools -

i have 1 question regarding model descried bellow: a manager class holds tools , them... every tool something... every tool should register (in static method) manager (manager can contain static field of tools) when manger starts should able see tools. what best practice ? if have differently. have interface tool, itool contains methods common tools dojob() or whatever feel appropriate. then design manager class accepts list of itool via constructor, , have method enables add more tools @ design time. interface itool { dojob(); } class manager { public manager(ienumberable<itool> tools); public addtool(itool tool); } edit: although don't understand requirements completely, think have feeling trying do. you said assume itool s private or have been loaded before manager, don't know why might cause problem unless classes implement itool private in assembly different assembly manager , if case please read on. if project big or

regex - Redirecting folder from one domain to another using .htaccess 301 redirect -

i'm trying figure out rewrite redirect directory , of it's files & subdirectories 1 domain another. here achieve: olddomain.com/oldfolder/* to http://newdomain.com/newfolder/* currently using following: rewriteengine on rewritebase / rewritecond %{http_host} ^www\.olddomain\.com$ rewriterule (.*) http://newdomain.com/newfolder/$1 [l,r=301] this works www.olddomain.com not olddomain.com. what's best way achieve this? help. replace code this: options +followsymlinks -multiviews rewriteengine on rewritebase / rewritecond %{http_host} ^(www\.)?olddomain\.com$ [nc] rewriterule ^oldfolder/(.*)$ http://newdomain.com/newfolder/$1 [l,r=301,nc]

c++ - VS2010: Temporaries can't be bound to non-const references -

this question has answer here: rvalue lvalue conversion visual studio 3 answers i came know temporaries connot bound non-const references. class x { int i; }; x fun() { return x(); } void func(x &x) { } int main() { func(fun()); return 0; } isn't call fun producing temporary? why can temporary linked non-const reference here. unable comprehend why compiling fine. edit: using vs2010. don't understand how should matter. isn't call fun producing temporary? yes. why can temporary linked non-const reference here. it can't. i unable comprehend why compiling fine. because compiler faulty. i using vs2010. don't understand how should matter. that compiler has many non-standard "extensions" language. 1 example of dodgy code that's accepted compiler, not conformant one.

How to take input of space seperated integers in an array (c++) -

suppose have take input of n integers (previously provided user) , enter them array directly. example cin >> >> b; is given input 5 10 5 assigned , 10 b. i want similar thing arrays. please help. for(int = 0; < n; i++){ cin>> array[i] >> array2[i]; } right?

R - shuffle a list preserving element sizes -

in r, need efficient solution shuffle elements contained within list, preserving total number of elements, , local element sizes (in case, each element of list vector) a<-letters[1:6] b<-letters[6:10] c<-letters[c(9:15)] l=list(a,b,c) > l [[1]] [1] "a" "b" "c" "d" "e" "f" [[2]] [1] "f" "g" "h" "i" "j" [[3]] [1] "i" "j" "k" "l" "m" "n" "o" the shuffling should randomly select letters of list (without replacement) , put them in random position of vector within list. i hope have been clear! :-) you may try recreating second list skeleton of first, , fill elements of first list, this: u<-unlist(l) l2<-relist(u[sample(length(u))],skeleton=l) > l2 [[1]] [1] "f" "a" "o" "i" "s" "q" [[2]] [1] "r" "

grails - Geb - no input for numbers 2 and 4 -

i wanted test webapp geb , grails , come across strange error. when tried enter numbers 2 or 4 input, these numbers ignored , no number entered. other numbers work fine. error occured when used chrome driver, when switched firefox, works ok. have same problem or know solution? much! e.g. def "test numbers"(){ $("input#someid\\.search") = "0123456789" } then in input (text field), have 01356789. regards, lojza try this: $("yourselector") << "0123456789"

javascript - How can I make setInterval also work when a tab is inactive in Chrome? -

i have setinterval running piece of code 30 times second. works great, when select tab (so tab code becomes inactive), setinterval set idle state reason. i made simplified test case ( http://jsfiddle.net/7f6dx/3/ ): var $div = $('div'); var = 0; setinterval(function() { a++; $div.css("left", a) }, 1000 / 30); if run code , switch tab, wait few seconds , go back, animation continues @ point when switched other tab. animation isn't running 30 times second in case tab inactive. can confirmed counting amount of times setinterval function called each second - not 30 1 or 2 if tab inactive. i guess done design improve performance, there way disable behaviour? disadvantage in scenario. on browsers inactive tabs have low priority execution , can affect javascript timers. if values of transition calculated using real time elapsed between frames instead fixed increments on each interval, not workaround issue can achieve smother animation

c# - Object of type 'System.Reflection.MdFieldInfo' cannot be converted to type 'MyEnum' -

i loading assembly @ runtime , trying lot of operations @ runtime going far anyways trying achieve: i have class called student in foreign assembly loading @ runtime public class student { public bool isgood { get; set; } public studenttype st { get; set; } public university university { get; set; } } i can dynamically load object assembly doing like: var assembly = assembly.loadfrom("//path"); type type = assembly.gettype("testframework.student"); var student = activator.createinstance(type); now, comes turn set properties type dynamically loaded foreign assembly. type universitytype = assembly.gettype("testframework.university"); type.getproperty("university").setvalue(student, activator.createinstance(universitytype), null); nice part works too!! but here problem starts. when try assign studenttype enum same assembly fails error object of type 'system.reflection.mdfieldinfo' cannot converted to

shell - Script file that executes other scripts -

how make script file executes other scripts line line? have multiple scripts need executed in correct order work you can have scripts execute in order chaining command && && makes sure first command has completed before moving onto other sin chains. opposed & execute them if prior ones fail. first.sh echoes first second.sh echoes second command sh first.sh && sh second.sh output i first second you can tie cron job if wish have execute @ certains times etc.

c++ - Buildbot : how to manually launch a build? -

we using buildbot ( http://buildbot.net/ ) build our c++ project. there way run exact build commands command line executed when hit "force build" button on web ui? i'm trying debug build problem present on our build server not on our local machines, , don't want spam email list each time fails. thank you, sean to run command command [arg]... in clean environment use env --ignore-environement command [arg]... .

php - group data of multiple fields in an array -

i have hidden input values each module see in following html. once data posted, how can data of each module in array, can store it. <div class="module">module1</div> <input type="hidden" value="module1" name="module_id"> <input type="hidden" value="title" name="title"> <input type="hidden" value="some text" name="text"> <div class="module">module2</div> <input type="hidden" value="module2" name="module_id"> <input type="hidden" value="another title" name="title"> <input type="hidden" value="another text" name="text"> i unable understand how combine title , text input module id. put [] after names. php turn them each array. <div class="module">module1</div> <input type="hidden"

function - import modules from folder (Python) -

i have python file "a.py", folder named folder , in folder has "b.py". a.py has code: from folder.b import * function() it says: nameerror: name 'function' not defined it defined. why? thank you! do have use folder.b ? if not: can add folder name folder system path: import sys sys.path.append(your_folder_containing_b.py) and change a.py to: from b import * a less straight forward way change current working directory folder , from b import * import os os.chdir(your_folder_containing_b.py)

objective c - How do you change the add button text instead of a -

the add button comes default masterdetail template in xcode displays + symbol. rather have word "add" instead. tried using following line in viewdidload method: self.navigationitem.rightbarbuttonitem.title = @"add"; to no avail. this because bar button has been created uibarbuttonsystemitemadd so: uibarbuttonitem *addbutton = [[uibarbuttonitem alloc] initwithbarbuttonsystemitem:uibarbuttonsystemitemadd target:self action:@selector(insertnewobject:)]; you should rewrite line create bar button item title, this: uibarbuttonitem *addbutton = [[uibarbuttonitem alloc] initwithtitle:@"add" style:uibarbuttonitemstylebordered target:self action:@selector(insertnewobject:)]; you can find in viewdidload method of master view controller.

General overview of chess algorithms -

i trying understand basic chess algorithms. have not read literature in depth yet after cogitating here attempt: 1) assign weight values pieces(i.e. bishop more valuable pawn) 2) define heuristic function attaches value particular move 3) build minimax tree store possible moves. prune tree via alpha/beta pruning. 4) traverse tree find best move each player is core "big picture" idea of chess algorithms? can point me resources go more in depth regarding chess algorithms? following overview of chess engine development. 1. create board representation. in object-oriented language, object represent chess board in memory. options @ stage are: bitboards 0x88 8x8 bitboards recommended way many reasons. 2. create evaluation function. this takes board , side-to-evaluate agruments , returns score. method signature like: int evaluate(board boardposition, int sidetoevaluatefor); this use weights assigned each piece. use heuristics if desire. si

html - Full sized background image in div? -

i want full sized background image, inside div. div last element, want fill bottom of page. far, have code, makes fill sides, changing height 100% makes disappear, , can't seem fill page. .launch { background: url('images/launchbackground.jpg') no-repeat center center fixed; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; } without seeing html, have tried: background-image: url('images/launchbackground.jpg') also can try set manually: .launch { top: 0px; left: 0px; min-height: 100%; min-width: 100%; position: fixed; }

javascript - D3 Multi-series transition overlapping data -

i have graph correctly plots several lines based on sensor's serial number. problem need transition new dataset , data overlap. here's have far...... var thresholdtemp = 72; var minutes = 5; var transinterval; //main function create graph plot function plot(date1, date2, interval) { var data; //if define date search parameter don't want have load interactive if (date1 == undefined && date2==undefined) { data = loadminutesjson(minutes); } else { data = searchjson(date1, date2, interval); } var margin = {top: 20, right: 80, bottom: 60, left: 50}, width = 960 - margin.left - margin.right , height = 500 - margin.top - margin.bottom; //re-order data more usable rest of script var parsedate = d3.time.format("%y-%m-%d %h:%m:%s").parse; //set x domain exist within date , times given var x = d3.time.scale().domain([getmindate(data), getmaxdate(data)]).range([0, (width)]); //y

ios - Copied iPhone storyboard over to iPad, but iPad loading with different view controller -

Image
i copied in iphone storyboard on ipad storyboard , changed nothing. runs on iphone, loading welcomeviewcontroller initial scene. however, when run on ipad, program crashes because tries load mainviewcontroller initial scene. i checked on interface builder, , initial scene set view controller welcomeviewcontroller. went in debugger , put breakpoint in viewdidload method of welcomeviewcontroller, , ipad never hits breakpoint iphone does. this identity inspector view controller of initial scene. this attributes inspector view controller of initial scene (same above). why ipad insist on trying load viewcontroller initial view controller? thanks edit: when go targets > ipad deployment info, , set main storyboard mainstoryboard_iphone instead of mainstoryboard_ipad works. reason mainstoryboard_ipad, literal clone of iphone storyboard, doesn't. make sure ipad view has initial controller set welcomeviewcontroller in storyboard. represented arrow given be

How to determine if an object is a certain type in F# -

this question has answer here: f# equivalent of `is` keyword in c#? 3 answers f#: check if value array of strings, array of arrays of string or string 1 answer in c# use keyword 'is' if (variable string) { } how done in f# try if (variable :? string) ... or let x = variable :? string

c++ - What does “request for member '*******' in something not a structure or union” mean? -

is there easy explanation error means? #include <stdio.h> #include <string.h> struct student { char surname[30]; char name[30]; int age; char address[10]; }; int main(){ int i; char temp1; char temp2; int temp3;; char temp4; struct student x[2]; for(i=1; i<3; i++){ struct student x[i]; printf(" surname of student %s:", i); scanf("%s",&temp1); printf(" other names of student %s:", i); scanf("%s",&temp2); printf(" age of student %s:", i); scanf("%s",&temp2); printf(" address of student %s:", i); scanf("%s",&temp3); strcpy(x->surname,&temp1); strcpy(x->name,&temp2); //x[i].surname=temp1; //x[i].name=temp2; x[i]

javascript - Getting error when appending to documentFragment -

i'm getting error when creating document fragment, appending elements , returning fragment. i've used document fragments in past (abused them way beyond example) , have never run in error. in developer console lists source of error: fragment.appendchild($balancenumber, $balancesign); error uncaught notfounderror: attempt made reference node in context not exist. function var constructbalancefragment = function(balance) { var $balancenumber, $balancesign, fragment, sign; fragment = document.createdocumentfragment(); $balancenumber = $('<span class="balance_number"></span>'); $balancesign = $('<span class="balance_sign"></span>'); if (balance > 0) { sign = "+"; $balancesign.addclass("positive_number"); } else if (balance < 0) { sign = "-"; $balancesign.addclass("negative_number"); } else { sign = &quo

Fast C++ String Output -

i have program outputs data fpga. since data changes extremely fast, i'm trying increase speed of program. right printing data this for (int = 0; < 100; i++) { printf("data: %d\n",getdata(i)); } i found using 1 printf increases speed printf("data: %d \n data: %d \n data: %d \n",getdata(1),getdata(2),getdata(3)); however, can see, messy , can't use loop. tried concatenating strings first using sprintf , printing out @ once, it's slow first method. suggestions? edit: i'm printing file first, because realized console scrolling issue. still slow. i'm debugging memory controller external fpga, closer real speed better. if writing stdout, might not able influence all. otherwise, set buffering setvbuf http://en.cppreference.com/w/cpp/io/c/setvbuf std::nounitbuf http://en.cppreference.com/w/cpp/io/manip/unitbuf and un tie input output streams (c++) http://en.cppreference.com/w/cpp/io/basic_ios/tie std::ios_base::s

How to insert a string in another string in C -

i need insert string in string @ specific place. here's simple example: char *a = "dany s."; char *b = "my name *a , come ... "; so, in string b in place of *a expect have dany s. how ? the best/easiest way use standard c conventions: char *a = "dany s."; char *b = "my name %s, come from..."; char *c = malloc(strlen(a) + strlen(b)); sprintf( c, b, ); then c contains new string. when you're done c , need free memory: free( c ); if want use c in output terminates line, can declare b as: char *b = "my name %s, come from...\n";

c# - Nancy Razor partial views do not render in release mode -

partial views render in debug mode not release mode. stack trace [argumentnullexception: value cannot null. parameter name: key] system.collections.concurrent.concurrentdictionary`2.getoradd(tkey key, func`2 valuefactory) +5895838 nancy.viewengines.defaultviewcache.getoradd(viewlocationresult viewlocationresult, func`2 valuefactory) +329 nancy.viewengines.razor.razorviewengine.getorcompileview(viewlocationresult viewlocationresult, irendercontext rendercontext, assembly referencingassembly, type passedmodeltype) +186 system.dynamic.updatedelegates.updateandexecute5(callsite site, t0 arg0, t1 arg1, t2 arg2, t3 arg3, t4 arg4) +401 callsite.target(closure , callsite , razorviewengine , viewlocationresult , irendercontext , assembly , object ) +575 nancy.viewengines.razor.razorviewengine.getviewinstance(viewlocationresult viewlocationresult, irendercontext rendercontext, assembly referencingassembly, object model) +1128 system.dynamic.updatedelegates.upd

symfony - Symfony2 minify without java or node -

i not have access java or node on shared host. there way minify server side, can continue use assetic, without these engines? uglify uses node , yui-compressor (deprecated anyway) uses java. thanks! there seem 2 filters using php code: cssminfilter jsminplusfilter you need install minify php library through composer, , use cssmin , jsminplus assetic filters.

batch file - Substring in a list of entries -

i have variable contains list of filenames , based on extension, need perform different action. not able extract extension inside loop set binaries=file1.dll fil2.dll fil3.sys :: each file in list of binaries %%g in (%binaries%) ( :: if extension dll if /i [%%g:~-4%]==[.dll] ( echo dll file ) else ( echo sys file ) ) if condition failing. how correctly extract extension. if /i "%%~xg"==".dll" from cmd shell window for /? : in addition, substitution of variable references has been enhanced. can use following optional syntax: %~i - expands %i removing surrounding quotes (") %~fi - expands %i qualified path name %~di - expands %i drive letter %~pi - expands %i path %~ni - expands %i file name %~xi - expands %i file extension %~si - expanded path contains short names %~ai - expands %i file attributes of file

x86 assembly print register ascii -

i realize there lot of questions/answers how output integer in decimal, ascii form. i've taken code , modified own needs, instead of printing number, continues printing gibberish characters, , windows tells me program stopped working. think problem keeps popping values of stack though should break out of loop. here full code: .386 .model flat, stdcall option casemap :none include \masm32\include\windows.inc include \masm32\include\kernel32.inc include \masm32\include\masm32.inc includelib \masm32\lib\kernel32.lib includelib \masm32\lib\masm32.lib .data base dd 10 ans dd ? .code start: mov ecx,3 ;i'm writing compiler using push ecx ;jack crenshaw's "let's build compiler!" mov ecx,9 ;this sample output put in add ecx,[esp];the answer prints out should 42 push ecx mov ecx,2 xor edx,edx pop eax idiv ecx mov ecx,eax push ecx mov ecx,7 imul ecx,[esp] mov eax,ecx xor ecx,ecx separatedigit: xor edx,edx idiv base push edx inc ecx cmp eax,0 jne

image processing - how to convert a raw RGB data array to a bitmap in C# -

i trying convert raw rgb24 data array bitmap in c#, running trouble in doing so. this corresponding code: using system.runtime.interopservices; byte[] frame; //... code frame = new byte[1280 * 960]; // code frame system.runtime.interopservices.gchandle pinnedarray = gchandle.alloc(frame, gchandletype.pinned); intptr pointer = pinnedarray.addrofpinnedobject(); bitmap bmp = new bitmap(width, height, 3 * width, pixelformat.format24bpprgb, pointer); memorystream jpegstream = new memorystream (); bmp.save(filepath, system.drawing.imaging.imageformat.bmp);** i a "an unhandled exception of type 'system.accessviolationexception' occurred in system.drawing.dll" with code above. however if change: bitmap bmp = new bitmap(width, height, stride, pixelformat.format24bpprgb, pointer); to bitmap bmp = new bitmap(width/3, height/3, stride, pixelformat.format24bpprgb, pointer); i not crash , 3 images covering 1/3 of tot

Chrome Rich Notifications in normal web pages? -

i found documentation chrome apps rich notifications. possible (after getting right permissions) use these notifications in regular web page? if not, there other type of desktop notification possible in chrome? maybe gmail has been doing long time? so need this? try it! <script> function notify() { var havepermission = window.webkitnotifications.checkpermission(); if (havepermission == 0) { // 0 permission_allowed var notification = window.webkitnotifications.createnotification( 'http://test.didacticmedia.ro/img/didactic.png', 'notification test!', 'details text' ); notification.onclick = function () { window.open("http://stackoverflow.com/questions/18414462/chrome-rich-notifications-in-normal-web-pages/19031405#19031405"); notification.close(); } notification.show(); } else { window.webkitnotifications.requestpermission(); } } </script> <div style

variables - bash indirect reference by reference -

a lot of similar questions, hadn't found 1 using variable in name way: #!/bin/bash # $1 should 'dev' or 'stg' dev_path="/path/to/123" stg_path="/path/to/xyz" # use $1 input determine path variable 'execute' ${!\$1'/morepath'} using $1, want able reference either $dev_path or $stg_path ($1 == 'dev' or $1 == 'stg') , able reference value of $1_path '/path/to/123' or '/path/to/xyz' so result either be: '/path/to/123/morepath' or '/path/to/xyz/morepath' based upon $1 being 'dev' or 'stg'. i've tried various iterations of using ! , \$ in various places other posts, no luck i think unsafe. if $1 gets value that's not dev or stg cause syntax error , other unexpected things may happen. eval wouldn't idea unless add conditional filter. use case statement: case "$1" in dev) "$dev_path"/bin/execute ;; std)

jquery - AJAX get custom response headers with CORS -

my server sends custom headers along response. response data alright, can't access custom headers jquery's getallresponseheaders() or angularjs $http service. content-type . when inspect request response devtools or fiddler, can see custom headers being sent server, can't them xhr. there way access headers? ok got working after adding allowed headers in server config access-control-expose-headers

xml - UTF8 Find Replace Tool? -

forum members, coding in xml , using validator / parser chokes when encounters utf8 related text hiding within text. using notepad++ in ansi mode, , when switch utf8 mode shows me these utf8 errors exist. once manually delete unwanted utf8 text character validator/parser works perfectly. notepad++ not able find , replace utf8 characters within xml file. question out there. notepad++ plugin exist let me globally search file unwanted utf8 text , replace nothing? also, can regex find , replace unwanted utf8 text? there text editor out there capable of hunting down unwanted utf8 text? in addition, can out there educate me utf8 text , why prevent xml validator working correctly? spent several hours trying figure out why xml code not parsing , of been lot easier if have had ability hunt down unwanted utf8 characters. appreciated. in advance. i use editplus 3 . can try yourself. at other side, mind show text of xml code?

python - Most labels update well, except for one -

i apologize pasting of code. i'm @ loss how should post question. did other answers throughout week, cannot life of me figure out. know there more have program work, i'm trying team_at_play label update. i've tried printing variables , team_at_play.set() , team_at_play = team_b.get(). print team_at_play.get() shows team turn is, label not update. also, have put functions, coin_toss(), etc. in right place respect mainloop? here link text file can loaded menu item: "abrir capitulo": http://www.mariacarrillohighschool.com/teachers/jamesbaptista/spanish7-8/classdocuments/handouts/expres_1_1.txt any appreciated! #!/usr/local/bin/env python # -*- coding: utf-8 -*- ## recall game """this timed game of vocabulary recall focus on previous units studied. if possible, sessions have time limit, teams might compete against 1 another. teams win points according how many answers given correctly. questions randomly selected.""" imp

c# - how to create loading window while web conncetion is checking in windows form app? -

i have test web connection form in c#. want show loading window while connection being checked, , show result of checking. this code testing web connection: public bool connectionavailable(string strserver) { try { httpwebrequest reqfp = (httpwebrequest)httpwebrequest.create(strserver); httpwebresponse rspfp = (httpwebresponse)reqfp.getresponse(); if (httpstatuscode.ok == rspfp.statuscode) { // http = 200 - internet connection available, server online rspfp.close(); return true; } else { // other status - server or connection not available rspfp.close(); return false; } } catch (webexception) { // exception - connection not available return false; } } and this: private void button1_click(object sender, ev