Posts

Showing posts from May, 2013

c# - Accessing a Parent form button from a Child form button -

i have program has parent form creates child form. upon clicking updatebutton within child form, want searchbutton within parent form fire. however error protection reasons. have tried setting public see, still wont work me. error 1 'salessystem.systemform.searchbutton' inaccessible due protection level salessystem\updateform.cs 111 20 salessystem this have far. parent code namespace salessystem { public partial class systemform : form { public systemform() { initializecomponent(); } protected void searchbutton_click(object sender, eventargs e) { //search code } private void updatebutton_click(object sender, eventargs e) { try { updateform upform = new updateform(resultbox.selecteditems[0].text, dbdirec, dbfname); upform.showdialog(this); } catch (exception)

java - I've got a very strange crash during Android TextAdventure development -

http://scr.hu/0eug/7vny2 the situation: i press button should launch part of code (work in progress on this, it's not complete yet): public void playerattack1(view view){ setcontentview(r.layout.activity_fight_defense); displaystats(); int attacktype = 1; int dmgminimum = 10; int dmgmaximum = 15; random rn = new random(); int range = dmgmaximum - dmgminimum + 1; int damage = rn.nextint(range) + dmgminimum; fight_p_attack(damage, attacktype); sb.insert(0,"attack!\n"); textview = (textview) findviewbyid(r.id.teststring); textview.settext(sb); public void fight_p_attack(int damage, int attacktype){ setcontentview(r.layout.activity_fight_defense); int k9minimum = 1; int k9maximum = 9; random rn = new random(); int range = k9maximum - k9minimum + 1; int k9 = rn.nextint(range) + k9minimum; switch (attacktype){

javascript - Elements with display set to none are shown -

i have created following greasemonkey script firefox filter class names in long list of java api reference : // ==userscript== // @name jdk api doc helper problematic // @version 1 // @namespace xolve // @description provides in place search jdk api docs // @include http://docs.oracle.com/javase/7/docs/api/* // @run-at document-end // ==/userscript== var classnamesframe; var classnamesdoc; var classnameshash = {}; var timeoutid; function textboxtextchanged(ev) { window.cleartimeout(timeoutid); console.log(ev.target.value); // case insensitive comparision var query = string(ev.target.value).trim().tolowercase(); timeoutid = window.settimeout(filterclassnames, 600, query); } function filterclassnames(query) { if(query.length == 0) { for(k in classnameshash) { classnameshash[k].style.display = ""; } return; } for(k in classnameshash) { if(k.startswith(query)) { con

java - Custom JComponent not showing up on JLayeredPane -

i'm trying create chess interface in java , i'm using jlayeredpane put pieces on top of chessboard image. problem pieces not added layered pane. this code dragimage class (every piece going instance of class can drag , drop on chessboard). class dragimage extends jcomponent implements mousemotionlistener { private static final long serialversionuid = 1l; int imagewidth = 52, imageheight = 52; int imagex, imagey; image img; public dragimage(image i) { img = i; repaint(); addmousemotionlistener(this); } public void mousedragged(mouseevent e) { imagex = e.getx(); imagey = e.gety(); repaint(); } public void mousemoved(mouseevent e) { } public void paint(graphics g) { graphics2d g2 = (graphics2d) g; g2.drawimage(img, imagex, imagey, this); } } and code jpanel . the image

python - balance positives and negatives in numpy -

i have matrix last column has floats in it. around 70% of numbers positive, while 30% negative. i'd remove rows positive number result matrix has approxiamtely same number of positive , negative numbers in last column. i'd remove positives rows randomly. what this: import numpy np x = np.arange(30).reshape(10, 3) x[[0,1,2,],[2,2,2]] = x[[0,1,2],[2,2,2]] * -1 = np.where(x[:,2] > 0)[0] n_pos = np.sum(x[:,2] > 0) n_neg = np.sum(x[:,2] < 0) n_to_remove = n_pos - n_neg np.random.shuffle(a) new_x = np.delete(x, a[:n_to_remove], axis = 0) result: >>> x array([[ 0, 1, -2], [ 3, 4, -5], [ 6, 7, -8], [ 9, 10, 11], [12, 13, 14], [15, 16, 17], [18, 19, 20], [21, 22, 23], [24, 25, 26], [27, 28, 29]]) >>> new_x array([[ 0, 1, -2], [ 3, 4, -5], [ 6, 7, -8], [15, 16, 17], [18, 19, 20], [27, 28, 29]]) i think easier arrays matrices, let m

Scala recursion no side effects -

ok, recursion more functional because not changing state of object in iteration. there nothing stopping in scala. var magoo = 7; def mergesort(xs: list[int]): list[int] = { ... magoo = magoo + 1 mergesort(xs1, xs2); } in fact, can make recursion side effectless in scala can in java. fair scala make easier write concise recursion using pattern matching? there nothing stopping me writing stateless recursion code in java can write in scala? the point in scala complex recursion can achieved neater code. that's all. correct? if course can complex recursion in java. complex recursion in assembler if wanted to. in scala easier do. scala has tail call optimisation important if want write arbitrary iterative algorithm recursive method without getting stack overflow or performance drop.

jQuery Slide CSS Element Out Reducing Opacity -

hi trying slide css element out, gradually removing opacity until disappeared. e.g want slide text right reduced opacity whilst sliding till disappeared. //jquery $(document).ready(function() { $('.heading1').animate({marginright:"20px",opacity:0},500) }) //html <div class="slidercontainer"> <a class="heading1">text</a> </div> //css .heading1 { position:relative; } i have tried doesn't slide out, move across screen. fades out. idea? i want able animate in , out of screen reducing opacity when does. use integers ( 20 ) instead of strings ( 20px ): $(document).ready(function() { $('.heading1').animate({'margin-right':20,opacity:0},500); })

stream - Form boundaries and writing php://input to a file in php -

so want users able upload big files without having worry post max size values. alternative using put , send file raw data. when using jquery can this: var data = new formdata(); jquery.each($('#file_upload')[0].files, function(i, file) { data.append('file-'+i, file); }); $.ajax({ url: 'upload.php?filename=test.pdf', data: data, cache: false, contenttype: false, processdata: false, type: 'put', }); in php can this: $f = fopen($_get['filename'], "w"); $s = fopen("php://input", "r"); while($kb = fread($s, 1024)) { fwrite($f, $kb, 1024); } fclose($f); fclose($s); header("http/1.1 201 created"); i not doing: $client_data = file_get_contents("php://input"); since putting whole file variable surely fill memory when uploading huge files. the thing cannot figure out how write file data without form boundaries. right writes @ top of file this: ------webkitformboundar

nsarray - iOS: Seeding an app with items from a plist -

i'm trying populate or seed app items, using next method, called in didfinishlaunchingwithoptions method: -(void)seeditems { nsuserdefaults *ud = [nsuserdefaults standarduserdefaults]; if (![ud boolforkey:@"muserdefaultsseeditems"]) { // load seed items nsstring *filepath = [[nsbundle mainbundle] pathforresource:@"seed" oftype:@"plist"]; nsarray *seeditems = [nsarray arraywithcontentsoffile:filepath]; nsmutablearray *items = [nsmutablearray array]; (int = 0; < [seeditems count]; i++) { nsdictionary *seeditem = [items objectatindex:i]; mshoppingitem *shoppingitem = [mshoppingitem createshoppingitemwithname:[seeditem objectforkey:@"name"] andprice:[[seeditem objectforkey:@"price"] floatvalue]]; [items addobject:shoppingitem]; } // items path nsstring *itemspath = [[self documentsdirectory] stringbyappendingpathcom

linux - TLB translation vs cache -

i having doubt regarding memory management in operating systems.i know cache temporary storage location used speed memory accesses whereas tlb used speed translation virtual address physical address. now if virtual memory address generated,what first step taken? if first step referring tlb , generating physical address, second step taken?(is referring cache see whether data stored in cache)? do modern computers use tlbs? how cpu know page table located? it depends mean "generated". if meant "read", first step either tlb if address has been translated or, if cache supports virtual addresses, in cache see if there entry corresponding virtual address (and if belongs appropriate process, virtual address not enough). if first step virtual physical translation, cache physical addresses. assuming want read , indeed next step @ cache. yes do. processors using virtual memory use tlb. yes, depends on architecture. on intel(x86) processor, instance, pag

python - Django: get subset of a model with at least one related model -

class category(models.model): # fields class product(models.model): category = models.foreignkey(category) # fields assuming not categories have @ least product, how can categories have @ least 1 product associated ? is there way django querysets? you should able filter on category. want find category 's product isn't null right?: category.objects.filter(product_set__isnull=false).distinct()

json - JsonToTree example from QooXdoo 2.1 demo not working in playground -

i trying jsontotree example working, not work in playground: http://tinyurl.com/b92lkn9 , not work when done locally on system. interestingly, example works fine inside demo browser http://demo.qooxdoo.org/2.1/demobrowser/index.html#data~jsontotree.html if bring part out of event listener, tree.getroot().setopen(true); gives me error saying tree.getroot() null. some other questions regarding have been solved pointing json file did not have root node. using same json given in demo browser example. tree.json looks this: http://demo.qooxdoo.org/2.1/demobrowser/resource/demobrowser/demo/data/tree.json any pointers issue. stuck here. thanks in advance. vishal the sample can not work in playground data json file missing , can not loaded when copying code over. mentioned in comment, if put json file on server, should work , should not have cross origin policy issues anymore.

graphics - Is it expensive to do trilinear texture mapping in a shader? -

imagine big procedural world worths more 300k triangles (about 5-10k per 8x8x8m chunk). since it's procedural, need create data code. i've managed make normal smoothing algorithm, , i'm going use textures (everyone needs textures, don't want walk around simple-colored world, you?). problem don't know it's better calculate uv sets on (i'm using triplanar texture mapping ). have 3 approaches: 1. calculations on cpu , upload gpu ( mesh not being modified every frame - 90% of time stays static , calculations done per chunk when chunk changes ); 2. calculations on gpu using vertex shader ( calculations done for every triangle in every frame , meshes kinda big - expensive every frame?); 3. move algorithm onto opencl ( calculations done per chunk when chunk changes , use opencl meshing of data) , call kernel when mesh being changed (inexpensive, opencl experience based on modifying existing code, still have c background, may take long time befo

database - Recommend Software for Drawing a Normalization Diagram -

i want draw database diagram. should draw normalization steps. i want draw diagram , show functional dependency! -------------------------- | | | | v v ------------------------------------- | user_name | first_name | last_name| -------------------------------------- do know open source software draw diagram this? i use dia dia not support diagram this orm excellent diagrammatic way represent dependencies. don't think there standard notation type of diagram looking orm job nicely. can generate normalized database design directly orm model.

exec - Composer.phar don't want to run by shell_exec from PHP script. Why? -

trying execute possible params, such -d , full path etc.. no errors. when running commands, ok, when running composer cmd, ok too. have tried exec, system, shell_exec etc.. be? echo system('php composer.phar install'); try outputting error stream well: system('php composer.phar install 2>&1'); it might give more of hint going wrong.

cocoa - Custom NSTextFieldCell for NSOutlineView -

Image
i wondering how draw nstextfieldcell 1 in netnewswire. i have subclassed nstextfieldcell group cell , specified in pxsourcelist's datacellforitem . the source list cell based. i don't know how draw cells. check out apple sample "sourceview", contains subclass of nstextfieldcell called imageandtextcell want. https://developer.apple.com/library/mac/#samplecode/sourceview/introduction/intro.html though if me, i'd change using view based outlineview , use built in nstablecellview supports imageview.

python - Text replacing is not working -

i have list of integers looks like: i = [1020 1022 .... ] i need open xml file stored .txt , each entry includes settings="keys1029"/> i need iterate through records replacing each numbers in "keys1029" list entry. instead of having: ....settings="keys1029"/> ....settings="keys1029"/> we have: ....settings="keys1020"/> ....settings="keys1022"/> so far have: import os out = [1020,1022] open('c:\xml1.txt') f1,open('c:\somefile.txt',"w") f2: #somefile.txt temporary file text = f1.read() item in out: text = text.replace("keys1029","keys"+str(item),1) f2.write(text) #rename temporary file real file os.rename('c:\somefile.txt','c:\xml1.txt') this replacing: ....settings="keys1029"/> ....settings="keys1029"/> with ....settings="keys1"/> ....settings="keys1&q

php - Facebook Like button for a specific id -

from homepage click on image has id , directed page shows more details id. i want have facebook button on page contain information specific id don't know type in data-href <div class="fb-like" data-href="http://www.test.com/php/test.php?id=" data-send="true" data-width="150" data-show-faces="false"></div> specify static or coming database ? for database, pass php variable in url: echo "<div class='fb-like' data-href='http://www.test.com/php/test.php?id='".$id."data-send='true' data-width='150' data-show-faces='false'></div>";

Determine if a string starts with an upper-case character in Perl -

i need make subroutine in perl determines if string starts upper-case character. have far following: sub checkcase { if ($_[0] =~ /^[a-z]/) { return 1; } else { return 0; } } $result1 = $checkcase("hello"); $result2 = $checkcase("world"); that's correct. [a-z] might not match uppercase accented characters depending on locale. better use /^[[:upper:]]/ . also subroutine invocations shouldn't have $ character in front of them. i.e. should be: $result1 = checkcase("hello"); $result2 = checkcase("world");

iphone - Disabling simultaneous rightBarButton / tapGestureRecognizer touch -

i have viewcontroller makes navigationbar , statusbar disappear / reappear when user taps screen (much photos app). i'm noticing when push rightbarbutton "done" on navigationbar , tap screen simultaneously, makes bars disappear while viewcontroller transitioning (thus not displaying bars on viewcontroller gets pushed). i've tried disabling rightbarbutton when uitapgesturerecognizer gets triggered, , tried disabling uitapgesturerecognizer when rightbarbutton gets pushed, doesn't make difference, happens when pushed simultaneously. does know solution prevent happening? i think easiest way setexclusivetouch: navbar view (and therefore rightbarbutton ). in viewdidload : for (uiview *v in self.navigationcontroller.navigationbar.subviews) { [v setexclusivetouch:yes]; }

php - How to install Charisma Bundle in Laravel 4 -

there bundle called charisma laravel 3 want use laravel 4. laravel 4 uses composer packages instead of bundles. there package or way use charisma in laravel 4? creator of charisma here. i have not created package laravel 4 yet, way html ui, can download , create own laravel html layout. http://usman.it/free-responsive-admin-template/

proxy - How many nginx buffers is too many? -

reading nginx documentation, proxy_buffer command has explanatory message: this directive sets number , size of buffers, read answer, obtained proxied server. default, size of 1 buffer equal size of page. depending on platform either 4k or 8k. the default 8 4k or 8k buffers. why did authors of nginx choose eight, , not higher number? go wrong if add more buffers, or bigger buffer size? nginx built efficient memory , default configurations light on memory usage. nothing go wrong if add more buffers, nginx consume more ram. eight buffers chosen smallest effective count square of two. 4 few, , 16 greater default needs of nginx. the “too many buffers” answer depends on performance needs, memory availability, , request concurrency. “good” threshold stay under point @ server has swap memory disk. “best” answer is: few buffers necessary ensure nginx never writes disk (check error logs find out if is). here nginx configurations use large php-fpm application o

c# - Putting classes in different folders but calling them under the same name space? -

i using entity framework in web application project , there going lot of tables in proejct cauing lot of class files having made. want orginize class files folders make easier find them , modify if needed. can orginize files in different folders have them have same "namespace" name in class , have no problems calling files? i.e. files under folders project.dal.tables1 others under project.dal.tables2 in each class file give them namespace project.dal , in .aspx files call using project.dal i have done experimentation , far not seeing issues being jr. dev want make sure should not experiance unforseen issues in feature. there no issues changing namespace given .cs file

c++ - Looping through a unique_ptr collection outside of an object -

i'm trying loop through collection of pointers inside object baz outside class having class return vector::iterator . when run for loop following error: 'const class std::unique_ptr' has no member named 'getname' can explain what's going on , how can manage loop through unique pointer collection inside baz? in advance. #include <iostream> #include <string> #include <memory> #include <vector> class baseinterface { protected: std::string name; public: virtual ~baseinterface(){} virtual void setname( std::string objname ) = 0; virtual std::string getname() = 0; }; class foo : public baseinterface { public: void setname( std::string objname ) { name = objname; } std::string getname() { return name; } }; class bar : public baseinterface { public: void setname( std::string objname ) { name = objname; } std::string getname() { return name; } }; class baz { protected: std::vector< std::unique_p

Is it reasonable to develop large-scale projects in ASP.NET MVC 4? -

is reasonable develop large-scale projects (social networks) in perspective process millions of visits per day in asp.net mvc. guess in case performance of site extremely slow. need advice. better choice building social network in terms of performance , scalability? ok build in asp mvc or bad choice? may better ruby on rails example? how u think? in advance!) stackoverflow written asp.net mvc. according wikipedia has on 1,700,000 registered users of june 2013. enough testament power of asp.net mvc large scale social based applications

How to change input border-color, with jQuery, depending on its value? -

i have question jquery. have code below works fine; changes input border-color depending on value, typed , entered. if in input 's value on page-load not change border-color . how can make border-color change beginning, following page-load? thank :) <input type="text" class="col" value=""> // when <input>'s value changes $("input").change(function() { // if value less 7, add red border if ($(this).val() < 7) { $(this).css("border", "5px solid red"); } // else if value equal 7, add green border else if ($(this).val() == 7) { $(this).css("border", "5px solid green"); } // else if value greater 7, add orange border else if ($(this).val() > 7) { $(this).css("border", "5px solid orange"); } // else if value else, add black border else { $(this).css("border", "5px solid black"); } }); just trigger event:

c++ - Locally declared object's internal memory intact outside scope? -

the function f1 creates instance of foo , sets foo.ptr[0] = 2 . #include <iostream> using namespace std; class foo { public: int *ptr; inline foo(int a) { ptr = new int[a]; } inline ~foo() { delete[] ptr; } }; foo f1() { foo a(5); a.ptr[0] = 2; return a; } int main() { foo = f1(); cout<<a.ptr[0]<<endl; return 0; } what expected output: junk value . f1 returns by value , means copy of a made , copy shares same memory locations @ ( a , it's copy) respective ptr s point at. outside f1 , a gets destroyed. it's destructor called deallocate ptr 's memory. means memory location copy's ptr points @ invalid. so, expect junk value output. the output 2 . why? the standard never says should expect "junk value". instead, says you'll undefined behaviour. since not following rule of 3 (or five), dynamic

vb.net - How can I make a variable to accumulate clicks made over a datagridview? -

i want acumulate number of clicks made of clicks made on datagridview obtain 1 click private sub clickmouse(sender object, e datagridviewcellmouseeventargs) handles lrinc.cellmouseclick msgbox(e.clicks & e.columnindex & e.rowindex) end sub messagebox displayed when first click occurs , other clicks ignored. need implement method show result. private sub clickmouse(sender object, e datagridviewcellmouseeventargs) handles datagridview.cellmouseclick system.diagnostics.debug.print(e.clicks & e.columnindex & e.rowindex) end sub result should in output window. alternatively can create textbox ( text1 ) hold result private sub clickmouse(sender object, e datagridviewcellmouseeventargs) handles datagridview.cellmouseclick text1.text = e.clicks & e.columnindex & e.rowindex end sub edit - accumulation declaration , initialization: private accums new arraylist event: private sub clickmouse(sender object, e datagridview

php - Searching in an Array -

i have array: $fruits = array( [0] => array('name'=>'banana', 'color'=>'yellow' , 'shape'=>'cylinder'), [1] => array('name'=>'apple', 'color'=>'red' , 'shape'=>'sphere'), [2] => array('name'=>'orange', 'color'=>'orange' , 'shape'=>'sphere') ) how can find out if array $fruits contains apple in it? i have tried: in_array("apple", $fruits) , didn't work out. i tried various syntax , messed bit array_key_exists() , nothing worked out. ideas? php notoriously unwieldy in such cases. best all-around solution simple foreach : $found = false; foreach ($fruits $fruit) { if ($fruit['name'] == 'apple') { $found = true; break; } } if ($found) .... you can write in number of sexier ways, of them require additional memory al

c# - PerformClick does not execute if placed after Show() -

i have windows form invisible button , progressbar. menuitem instantiate form , trigger click. private void form1_load(object sender, eventargs e) { show(); button1.performclick(); } if place show() above, performclick doesn't execute, sort of makes sense. if place show() after performclick, performclick executes form progressbar doesn't show until code of performclick has executed. no progressbar showing progress until complete. makese sense. how performclick work , have form progressbar showing progress both @ same time? thanks

Couchdb Put design python -

hello i'm trying tu put design couchdb python i've got next code , when execute recive 400 error, can me? i've used requests module , i've been unable puth design couchdb python u.u thank yyou import urllib2 import json import base64 url ="http://localhost:5984/pruebas/_design/example" data="" open("mydesign.json","rb") f: data+=json.dumps(f.readlines()) opener = urllib2.build_opener(urllib2.httphandler)) request = urllib2.request(url, data=data) request.add_header ("authorization", "basic %s" % base64.encodestring("user:password")) request.add_header("content-type", "application/json") request.get_method = lambda: "put" todo = opener.open(request)

sql - Truncate function for SQLite -

does there exist sqlite similar truncate function mysql? select truncate(1.999,1); # 1.9 there no built-in function directly. however, can treat number string, search decimal separator, , count characters that: select substr(1.999, 1, instr(1.999, '.') + 1); (this not work integers.)

ios - performSelector in category of superclass fails when calling method available in specific subclass -

i have uiview category defines methods manipulate attributedtext property of uilabel , uitextview. @implementation uiview (replaceattrtext) -(void) replaceattrtext: (nsstring *)str { if ([self respondstoselector: @selector(setattributedtext)]) { nsmutableattributedstring *labeltext = [self template]; // change [self performselector:@selector(setattributedtext) withobject: labeltext]; } } @end respondstoselector returns false both uilabel , uitextview (although respond setattributedtext) , if setattributedtext executed directly without respondstoselector check exception raised. when category implemented directly on uilabel (without selectors) works, unfortunately uilabel , uitextview don't have common ancestor has attributedtext property. what doing wrong? thanks! uilabel , uitextview not have method named setattributedtext . have method named setattributedtext: . note colon. colon part of method name. having or not represen

delphi - Is it safe to set SEM_FAILCRITICALERRORS on startup with VCL? -

i've found recommended call seterrormode(sem_failcriticalerrors) on application startup: https://msdn.microsoft.com/en-us/library/windows/desktop/ms680621.aspx i know vcl code sets mode temporarily in functions. not globally on application startup. as not see advantage of default behavior, i'm considering setting explicitly code. wonder, if vcl designed run in mode. aware of potential problem? reason, why vcl not set mode itself? it's fine in vcl application follow msdn advice , set sem_ failcriticalerrors @ startup.

scala - How to add dependency on library that is published locally for Play Project? -

i have play project intended library publish locally during development phase. i can achieve running publish-local my question how add dependency in main project in main project access utilities defined in local library? it seems need add dependency in build.scala. here's external libray: "com.google.inject" % "guice" % "3.0" what in case? you must add resolver precising local ivy repository: resolvers += resolver.file("local repo", file("/home/user/.ivy2/local"))(resolver.ivystylepatterns) you may want manage resolvers ordering/priorities (meaning, start searching local repo, if not found, try external repositories). in case, must deal proxy repositories .

Infinite Loop while importing Excel to SQL -

i have code use [database] set ansi_nulls on go set quoted_identifier on go alter procedure [dbo].[getdataexcel] declare c cursor select box, code , validity openrowset('microsoft.ace.oledb.12.0', 'excel 12.0;database=c:\barcodes.xlsx;hdr=yes', 'select box, code , validity [sheet1$]') declare @code bigint declare @box bigint declare @validity date begin open c fetch next c @box,@code,@validity while @@fetch_status = 0 begin insert cards (box, barcode, validitydate) select box, code , validity openrowset('microsoft.ace.oledb.12.0', 'excel 12.0;database=c:\barcodes.xlsx;hdr=yes', 'select box, code , validity [sheet1$]') fetch next c @box,@code,@validity end close c deallocate c end while exporting table "cards" empty rows copied table , process doesn't stop , loop goes on , on , process restarted on , over, query doesn't stop executing unless stop , when see content of table , see

ios - Twitter OAuth 1 POST requests not working -

i creating application ios , using oauth library . requests seem work fine try make post requests following error : [code 32] not authenticate you. now not quite sure happening, post requests generated pretty requests. ideas causing error ? here code generating request: + (nsurlrequest *)preparedrequestforpath:(nsstring *)path parameters:(nsdictionary *)queryparameters httpmethod:(nsstring *)httpmethod oauthtoken:(nsstring *)oauth_token oauthsecret:(nsstring *)oauth_token_secret { if (!httpmethod || !oauth_token) return nil; nsmutabledictionary *allparameters = [self standardoauthparameters]; allparameters[@"oauth_token"] = oauth_token; if (queryparameters) [allparameters addentriesfromdictionary:queryparameters]; nsstring *parametersstring = chquerystringfromparameterswithencoding(allparameters, nsutf8stringenc

c# - How can I allow my program to open a file when "Open with" is used? -

i have written word processor in c#. allow program open files when user right clicks file , selects "open with" , selects program. how can implement such feature program? currently, way user can open file using openfiledialog. as of now, if user chooses "open with" , selects program, doesn't open file selected. what best way implement feature? "open with" passes file name argument application. take @ args parameter here .

SPIM equivalent for x86 assembly language -

having learned mips, super helpful write simple code , testing out spim. being able see registers , stepping through code helped me understand each instruction did. there equivalent emulator x86 language can load simple codes , @ each registers , step through each instructions? i learn best doing , replicating codes on lecture. i used window version of spim. an gui simulator preferred on working on terminal. this isn't emulator x86, give debugging options , not. i'd use microsoft visual c++ , masm. here's tutorial how set up. msvc++ comes great tools debugging assembly code; basic breakpoints, step through options, , other windows such disassembly (for looking @ generated machine code), registers window, memory window, watch windows, , list goes on.

php - Doctrine FIxtures and Symfony2 Request scope -

i want create article fixtures project uses doctrine2 , symfony 2.2. here how articles created: they don't link images directly instead contain image names. before saving article articlemanager parses article text, finding image names, searching images in database , replacing image markup part real image path, example. this article content typed in form , contains ![image description](here awesome image name) then when form submitted , articlemanager->save($article) called, article manager changes image markup real file web path: this article content typed in form ![image description](/path/to/my_awesome_image.png) the problem : articlemanager relies on assetic assets helper service build full web image paths , service resides in request scope. on other hand, doctrine fixtures ran cli can't access service, making me unable image paths when loading article fixture. can suggest me least hackish way of tackling problem? ok, @cheesemacfly's

regex - Using or ( | ) statement in .htaccess rewrite rules -

instead of writing 2 rewrite rules pointing same page, though able 1 rule using or statement ( | ): rewriterule ^([\d]+)-post[\d]*\.html|#post([\d]+) /post.php?p=$1.html [r=301,nc,l] also tried $2 @ end since 1 show anyway: rewriterule ^([\d]+)-post[\d]*\.html|#post([\d]+) /post.php?p=$1$2.html [r=301,nc,l] with above rule, work fine: site.com/14729-post9.html however, not work(even though tested here , should work: http://regexpal.com/ ): site.com/post.php?p=14729#post14729 is there way make work or have create 2 separate rules? btw, more server intense 1 way or other? okay have understand in-document named links such #post14729 never passed server browser. when link contains in-document named link, example: click on <a href='http://some.host.com/foo.php?id=1&bar=2#post250'>some link</a> . here browser strips #post250 part when sending some.host.com , sends url /foo.php variables id=1 , bar=2. when result of comes browser,

javascript - JQuery Player - Doesn't work on Chrome -

i using music player written in jquery converted radio player. the problem doesn't work on google chrome in index.php file, (written in html5 also) have created object these features $(document).ready(function(){ var mycircleplayer = new circleplayer("#jquery_jplayer_1", { //m4a: "http://46.20.4.50:8030/", //safari & fenomen m4a: "http://stream-uk1.radioparadise.com:8034", oga: "http://stream-sd.radioparadise.com:9000/rp_192m.ogg" //firefox //m4a :"muzikler/0.m4a", //oga :"muzikler/0.ogg" }, { cssselectorancestor: "#cp_container_1", canplay: function() { $("#jquery_jplayer_1").jplayer("play"); } }); }); i wondering if chrome doesn't support .ogg or .m4a don't think since ve tried on player. in .js file ve adapted jquery 1.4.4 since 1.3.2 doesnt detect chrome webkit. $.jplayer.uabrowser = function( useragent ) { var u

Simple javascript can't figure out where it's wrong -

i can't figure out went wrong simple javascript <!doctype html> <html> <head> <title> </title> <script> function changecolor() { var elem = document.getelementbyid("para1"); if (elem.style.color == black) { elem.style.color = blue } else if (elem.style.color == blue) { elem.style.color = red } else if (elem.style.color == red) { elem.style.color = black } } </script> </head> <body> <p id="para1"> text here</p> <button onclick='changecolor();'>change!</button> <!-- <button onclick='changecolor("red");'>red</button> --> </body> </html> realise debugging harder javascript vba - i'm used it. you're missing quotes around color values. elem.style.color = 'red';

vb.net - How to display deck of cards and compare for doubles -

so.. right having pretty big problem. have pictures of card deck not displaying @ when deal button clicked. being displayed initially, tweaked , not.. there 3 players, test code player one. right set 16 cards, idea. also, how compare check doubles , remove them discard pile? please help, beyond capabilities @ point , have no idea how proceed. thanks!! deckofcardstest public class deckofcardstest dim playercards integer = 16 dim playermatches integer dim comp1cards integer dim comp1matches integer dim comp2cards integer dim comp2matches integer private deck new deckofcards() ' create deck of cards private sub dealbutton_click(byval sender system.object, byval e system.eventargs) handles dealbutton.click discard1picturebox.visible = true deck.shuffle() ' shuffles deck dim card1 = deck.dealcard() card1picturebox.image = getcardimage(card1) dim card2 = deck.dealcard() card2pictu

visual studio 2010 - WPF styles not being applied from App.xaml -

i'm looking apply styling wpf controls can done css in html. this first dabbling in wpf , i've collected need in app.xaml. below i've got. i've tried targettype="{x:type tabitem}" , targettype="tabitem" . none of styles i've defined being applied. app.xaml <application x:class="vmware_lab_manager_desktop.app" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" startupuri="mainwindow.xaml"> <application.resources> <resourcedictionary source="styles.xaml"></resourcedictionary> </application.resources> </application> styles.xaml <resourcedictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <sty

c# - high frequency timing .NET -

i'm looking create high frequency callback thread. need function execute @ regular high frequency (up 100hz) interval. realize windows has normal thread execution slice ~15ms. specify regular interval can faster 15ms. this i'm trying accomplish. have external device needs messaged @ interval. interval variable depending on situation. expect not ever need more 100hz (10ms) message rate. i can of course implement spin loop, however, hoping there solution not require wasted resources. the provided links questions/answers not resolve question. while agree question has been asked several different ways, there has not been solution solved problem. most of answers provided talk using stopwatch , performing timing task manually entirely cpu intensive. viable solutions using multimedia timers had couple pitfalls haans mentioned. have found solution i'll add below. not know of pitfalls @ time plan testing , research. still interested in comments regarding solu

java - Accessing a returned value from a different case -

hi it's 3rd time i'm posting question on forum , no 1 has been capable enlighten me situation. i pasted code matters here , try explain in best can ... methods: showmenu(in) - show's menu list calls choice(in) choice(in) - accepts in input through -> getnumber(in) getnumber(in) - number returned , selects correct case now i'm dealing case 1: , case 2: case 1: string clef = assigned return value saisirclef(in) saisirclef(in); method returns string after completing logic showmenu(in) needed can pick different case case 2: simple i'm trying access string after has been completed in case 1; if not should go through case 1 can done ? feel everytime gets passed break variables dissapear normal ? how can ? public static void choice(scanner in){ switch(getnumber(in)){ case 1: string clef = saisirclef(in); showmenu(in); break; case 2: if(clef.isempty()){

JNI C function cannot be resolved in Android -

i have package named com.self.tryffmpeg. there's file mainactivity.java inside package declares 2 native functions c inside jni folder static { system.loadlibrary("ffmpeg"); system.loadlibrary("ffmpeg-test-jni"); } private native int createengine(); private native string loadfile(string file, byte[] array); } inside jni folder, there's c file exports functions needed mainactivity.java. inside c , exports functions niexport jint jnicall java_com_self_tryffmpeg_mainactivity_createengine(jnienv* env, jclass clazz) { } jniexport jintarray jnicall java_com_self_tryffmpeg_mainactivity_loadfile(jnienv* env, jobject obj,jstring file,jbytearray array) { } but error functions of loadfile , createengine cannot resolved. unsatisfiedlinkerror. did wrong that. thought export functions correctly.

php - Hosting a website created with xampp -

i have spent time designing wordpress/phpbb site, , hosting on localhost using xampp. host website on real domain, not sure have , change in order make success. possible use files have placed in htdocs inside xampp directory? thanks help, , sorry if question confusing or badly explained. yes is, that's point of xampp - website prototyping. assume real domain mean hosting service. if use mysql make sure copy data new database , check php dependencies new host.

Visual Studio C++ 2010 Express Project creation failing? -

after installing visual studio c++ 2010 express, have not been able create projects. visual studio basic 2010 express installed. getting error after putting name project , selecting type; creating project " project-name " . . . project creation failed. i did check settings project templates , items, seem pointing documents folder instead of programfiles , sure did not work there. another question similar one: project creation failed microsoft visual c++ 2010 express , visual studio 2010 any suggestion thanked, have been trying find solution long time, have not been able find helpful. many thanks, jim

Time complexity of parsing algorithms -

i want write c++ program parse input file of following form. input $input1, $in2, $anotherinput, $a, $b, $x; output $out1, $out2, $k; $xyz = $a + $b + $x; $k = $xyz - $in2; ........ ........ ....... $out1 = $k + $b; input file can have more 10,000 lines. of lines of form $a = $b + $c . efficient parsing algorithm used in terms of time complexity. go simplest algorithm. suggest recursive descent prasing.

extjs - How to UPLOAD a file into my JS application? -

Image
i working on extjs 4.2 application. trying create menu toolbar can add , delete files. example: when press open , want see file browser window. , when finish choosing file , click "open", see this: i know need use onitemclick() function open browser. have no idea how call window. how can program file extensions can chosen. i guessing once press "open" on file browser window, file tree in left panel dynamically add file. have no idea how can connect "open" tree. just clarify - going user based app, not going webapp. opened in user's browser , it. no need info server or send client. edit: have been able solve part click on open file browser dialog pops up. when select file , press "open", displays message box file's name. here code part: var item = ext.create('ext.form.field.file', { buttononly: true, buttontext: 'open', hidelabel: true, listeners: {

die - Custom Error Message in Script Crash? PHP -

i've never worked advanced error handling, , can't find obvious answer searching. in scope script ( require_once ) how set custom "die" message? generally users see page-load die no response. i'd direct them file regarding memory absolutely cannot miss solution. you can kill script , output message using die() command die("your message here"); you can throw custom exceptions in php 5+, , catch them , @ point output message users. http://php.net/manual/en/language.exceptions.php

Android Studio: "Could not reserve enough space for object heap" when making module -

i tried use android studio 0.1 build small project practice, when make module, android studio says: android dex: [(module name)] error occurred during initialization of vm android dex: [(module name)] not reserve enough space object heap i'm using windows 7 64-bit, jdk 1.7, 8gb ram. i'm not familiar gradle , don't have idea how workaround it. same pc not have problem. i have tried modify studio.exe.vmoptions in bin folder, , can see right-down corner change 742m when set -xmx768m. error still occurs. also, if want set larger value -xmx2g , studio.bat shows: error occurred during initialization of vm not reserve enough space object heap error: not create java virtual machine. error: fatal exception has occurred. program exit. then android studio not start up. is there way make android studio usable? thank much. for android studio - solution here .

jsf 2 - Use of annotation in JSF 2.0? -

when use annotations in beans, framework use reflection recognize scope? flow of above process? right page being called bean getting instantiated , being put concerned sessionmap ,applicationmap or requestmap? when use annotations in beans, framework use reflection recognize scope? that's correct. what flow of above process? right page being called bean getting instantiated , being put concerned sessionmap ,applicationmap or requestmap? at point, annotations not been processed. processed once during jsf startup , remembered in server's memory. jsf ends collection of registered managed beans further used during runtime. based on managed bean name, jsf knows class , scope. put, when given managed bean cannot found in scope, jsf class#newinstance() on , put in desired scope.

ruby - How do I do a SQLite to PostgreSQL migration? -

i have problem migrating sqlite3 database postgresql. how , need do? i searching internet, find migrations mysql postgresql. can me? i need convert sqlite database postgresql database heroku cloud hosting. you don't want try binary conversion. instead, rely on exporting data, importing it, or use query language of both , using selects , inserts. i highly recommend @ sequel . it's great orm, makes switching between dbms easy. read through opening page , you'll idea. follow reading through cheat sheet , rest of documentation , you'll see how easy , flexible use. read migrations in sequel. they're akin migrations in rails, , make easy develop schema , maintain across various systems. sequel makes easy open , read sqlite3 table, , concurrently open postgresql database , write it. instance, modified version of first 2 lines of "cheat sheet": sqlite_db = sequel.sqlite('my_blog.db') pgsql_db = sequel.connect('postgres:/

build - Auto Increment version code in IntelliJ IDEA (Android) -

how can have auto increment versioncode (or versionname ) in intellij idea android project? here's question asked eclipse.

Wordpress Filter Categories -

how sub categories id ? catrgories , subcatrgories like 2013 april 10 april 9 april 8 march 10 march 9 2012 june 10 may 6 may 5 cast group party how subcategory id's of month? need pagination show page links site.com/catrgory/catrgory-slug/issue/{year}/{month}/{day}. need show pagination links subcategory pages. list post of particular subcategory. i using rewrite url add_action('generate_rewrite_rules', 'past_issue_rewrite_rules'); function past_issue_rewrite_rules( $wp_rewrite ) { // handles paged/pagination requests $new_rules = array('category/catrgory-slug/issue/(.+)/(.+)/(.+)/' => '?year='.$wp_rewrite->preg_index(1).'&month='.$wp_rewrite->preg_index(2).'&day='.$wp_rewrite->preg_index(3)); // add new rewrite rule top of global rules array $wp_rewrite->rules = $new_rules + $wp_rewrite->rules; } i tired , working $root_categories = get_