Posts

Showing posts from April, 2010

python - How to create URL Parameters from a list -

i have form multiple select field. working through get method. example of request parameters generated form: action=not-strummed&action=not-rewarded&keywords=test&page=2 note there 2 "action" parameters. happening because of multiple select. want is: make dict parameters remove "page" key dict transform-back dict parameter string the urllib.urlencode() isn't smart enough generate url parameters list. for example: { "action": [u"not-strummed", u"not-rewarded"] } urllib.urlencode() transforms dict as: action=%5bu%27not-strummed%27%2c+u%27not-rewarded%27%5d this wrong , useless. that's why wrote iteration code re-generate url parameters. parameters_dict = dict(self.request.get.iterlists()) parameters_dict.pop("page", none) pagination_parameters = "" key, value_list in parameters_dict.iteritems(): value in value_list: pagination_item = "&%(ke

Export button from blender to ogre is inactive -

i have downloaded coconut tree mesh internet. tried export mesh blender 2.66 ogre. file->export->ogre3d(.scene , .mesh) button inactive. can reason button inactive? in such cases how can export blender ogre? you must in object mode button selectable.

excel - Search result files needs to be looped through -

the code written below searches file user provided name , shows in message box. can stored in array when required , search result files can opened , looped read content of search result files private sub cmdsubmit_click() if me.part_number.value = "" msgbox "please enter part number.", vbexclamation, "part search" me.part_number.setfocus exit sub end if if me.id_tag.value = "" msgbox "please select id tag.", vbexclamation, "part search" me.id_tag.setfocus exit sub end if call flist end sub sub flist() dim mylist dim fldr string, fltr string, stemp string, shldr string dim long dim msg string dim filecount integer filecount = 0 fldr = "c:\users\op\desktop\new folder" if right$(fldr, 1) <> "\" fldr = fldr & "\" fltr = (me.part_number.value & "*.xls") msg = fltr & " files found:" & vblf shldr = dir(fldr &

vb.net - Formatting data using vb and excel -

this may sound simple, need it. i using vb create excel file , doing searches text file. have result column (a1 a4) in excel following data: h'4404 h'5712 h'5129 h'f112 what need somehow using vb, instruct excel show numbers read backwards i.e following in a1 cell: 404421759215211 any welcome. excel vba has vba.strreverse() function possibly simpler vb.net. dotnetperls page shows how replicate function. (there other ways - linq example.) so need reverse strings, join them create single string, replace h'. replace h' first if prefer. i think should attempt , you'll able come code if struggle.

iphone - Unwind Segue nil argument error -

i new ios development , trying create simple test app allows users record , edit pills in medicine cabinet. i using ios 6.1, arc , segues. background error: so user has list of pills in medicine cabinet, picks 1 , segue brings him view controller gives him information pill. has option edit info segues him view controller shows current info in textfields can edit , click save button initiates unwind segue original medicine cabinet. the error getting this. user can edit info , save , pop cabinet. when goes edit pill again, error: *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[__nscfstring appendstring:]: nil argument' i did digging , found out happening. in unwind segue method,i setting properties of pill match text in textfield of editpillview controller. example, have pill , belongs jay. edit , belongs raf. using breakpoints, can see string change jay raf in unwind segue method of medicinecabinetviewcontroller. once u

operators - How do I print the percent sign(%) in c -

this question has answer here: how escape % sign in c's printf? 13 answers i beginner in c, , wondering why program not print % sign? the code is: #include<stdio.h> main() { printf("%"); getch(); } your problem have change: printf("%"); to printf("%%"); or use ascii code , write: printf("%c", 37); :)

javascript - How can I send a message from one controller to another in AngularJS? -

i have following set up: stapp.controller('admintablecontroller', ['$rootscope', '$scope', 'gridservice', function ($rootscope, $scope, gridservice) { $scope.$watch('tabledata.$pristine', function (newvalue) { $rootscope.broadcast("tabledataupdated", { state: page.$pristine }); }); }]) stapp.controller('admingridcontroller', ['$rootscope', '$scope', 'gridservice', function ($rootscope, $scope, gridservice) { $rootscope.on("tabledataupdated", function (args) { //args.state have state. alert(args.state); }); }]) when run code getting message: object #<object> has no method 'on' note tried both $rootscope.on , $scope.on you must have meant $broadcast , $on (rather broadcast , on ), is: $rootscope.$broadcast("tabledataupdated", { state: page.$pristine }); // ... $ro

javascript - Import shared code between Firefox addon and Chrome addon into Firefox -

i developing firefox addon has chrome counterpart. eliminate code duplication there javascript libraries share in common. libraries not written commonjs design firefox jetpack modules expect. there way import , use shared javascript firefox modules? preferably shared code can sit in directory in root directory, shared library has own rich directory structure , don't want stuff data or lib directory. it's easy make js file loadable via commonjs, need add functions needed properties exports object, like: function foo() {} function bar() {} if (exports !== void 0) { exports.foo = foo; exports.bar = bar; }

ruby - How do I make my rack app a gem? -

i have nice litte .ru file can run rackup want able publish as gem. assume can move lib directory , add gemspec else need can run run after installing gem? gemspec +correct directory structure+(most importantly) placing script launch app(with run , probably) bin/ directory. a little more details on gem binaries here update an example requested. have made gem called agent depends on sinatra (it depends on rack ). has definition of agent::server : module agent # code goes here... class server < ::sinatra::base '/sync' [200, "yahoo!"] end end i created file called test following contents: #!/usr/bin/env ruby require "rubygems" require "agent" rack::handler::webrick.run( agent::server.new, :port => 9000 ) then, if run chmod 0755 test , ./test after that, can go http://localhost:900/sync , see yahoo! .

algorithm - Data structure for loaded dice? -

suppose have n-sided loaded die each side k has probability p k of coming when roll it. i'm curious if there algorithm storing information statically (i.e. fixed set of probabilities) can efficiently simulate random roll of die. currently, have o(lg n) solution problem. idea store table of cumulative probability of first k sides k, them generate random real number in range [0, 1) , perform binary search on table largest index cumulative value no greater chosen value. rather solution, seems odd runtime doesn't take probabilities account. in particular, in extremal cases of 1 side coming or values being uniformly distributed, it's possible generate result of roll in o(1) using naive approach, though solution still take logarithmicallh many steps. does have suggestions how solve problem in way somehow "adaptive" in it's runtime? edit : based on answers question, have written an article describing many approaches problem , along analyses. looks vos

curl - Downloading an image that is hotlink protected -

i download image hotlink protected. how can forge http header curl referer coming own server? i have tried command fails. i'm not familiar php , apreciated. curl -a "mozilla/5.0" -l -b /tmp/c -c /tmp/c -s 'http://remote-site.com/image.jpg' > image.jpg option looks curlopt_referer curl_setopt , or curl --referer not sure correct syntax. edit 2 : i got error saying curl_setopt() expects parameter 2 long. after removing mute option error gone. to show image have tried code page remains blank. $image = curl_exec($ch); curl_close($ch); fclose($fp); print '<img src="'.$image.'"/>'; edit 1: the code have entered in wordpress post (i use plugin insert php ) [insert_php] curl --referer http://www.domain.com/ -a "mozilla/5.0" -l -b /tmp -c /tmp -s 'http://www.domain.com/image.png' > image.png [/insert_php] the error have when load page : parse error: syntax error, unexpected ‘<‘ i

html5 - Use a php loop to process text and file inputs from html form -

i stuck on trying make work, have html form has file , text inputs, after submission want process these inputs through loop in php script. loop skips file input , processes text inputs. new @ php, , cant seem understand wrong , how fix it. here form code , php code process it. <form action='loop.php' enctype="multipart/form-data" data-ajax="false" method="post"> <input type ="text" name ="input1"/> <input type ="file" name ="input2"/> <input type ="text" name ="input3"/> <input type ="text" name ="input4"/> <input type='submit' data-corners="false" value ='submit'/> </form> loop.php <?php foreach ($_post $key => $value){ if($_post[input2]) //check if file input {//some manipulation on file} else //process other text inputs}

Prevent resubmit a form and struts -

i have 2 jsp page: page1.jsp form , page2.jsp displays message tell user if record insert happened or not. if form submitted , user refreshes page2, insert happens. i wouldn't use session variable, , setting request attribute in page2 doesn't resolve issue (it seems not work). you can give try this: from page1.jsp set request attribute, when control reaches page2.jsp check request attribute if there redirect control same page2.jsp. in way when control redirected same or other resource, previous request , response objects no more there(i.e. both request , response object destroy because http stateless protocol) , after redirection there no data related previous request , on refreshing page2.jsp not repeat previous task. i not sure in 1 of application used same purpose. let me know if has better alternative.

java - Add button to actionbar in android activity -

i add share button in action bar of current activity. i don't know how it. is possible in activity ? here code of activity : package com.rss.utils; import com.rss.r; import android.app.activity; import android.content.intent; import android.os.bundle; import android.util.log; import android.webkit.webchromeclient; import android.webkit.webview; import android.webkit.webviewclient; import android.widget.progressbar; public class webbrowserviewactivity extends activity { webview webview; progressbar progressb = null; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.web_browser_view); intent intent = getintent(); string url = intent.getstringextra("url"); log.d("webbrowserviewactivity", "url load : " +url); progressb = (progressbar) findviewbyid(r.id.progressbar1); webview = (webview) findviewb

Will Perl's $@ ever be undefined after an eval? -

i'm working on "error handling , reporting" chapter of mastering perl . in perlvar 's entry $@ , says: perl syntax error message last eval() operator. if $@ null string, last eval() parsed , executed correctly (although operations invoked may have failed in normal fashion). now i'm wondering when eval might not execute correctly, leaving $@ undefined value. there such cases? here's 1 way (but sit down before read it. ;)) $@ = 123; eval q{ $@ = 456; print ">>>$@<<<\n"; goto skip; }; skip: print ">>>$@<<<\n";

c# - Resize and Fit Image in WPF -

i have following: using (bmp == new bitmap(50, 50)) { using (g == graphics.fromimage(bmp)) { g.interpolationmode = drawing2d.interpolationmode.highqualitybicubic; g.drawimage(img, 0, 0, 50, 50); } } the user provides app image app has resize , fit entire image. the problem above code stretches image, not fit (as 4:3 movie fits in widescreen tv leaving blackbars). does have solution this? also, prefer not use gdi. you need take size of input image account. here code snippet should right direction: int x1 = 0, y1 = 0, x2 = 50, y2 = 50; if (img. width <= img.height) { // compute x1, y1 fit img horizontally bmp } else { // compute y1, y2 fit img vertically bmp } g.drawimage(img, x1,y1, x2,y2); also notice asking resizing image in wpf using system.drawing uses gdi+ under hood.

javascript - function executed by .apply() works with array, but does not the original function -

if math.max([1,3,9]) returns error (needs list of numbers, not array), why calling via apply below works? function getmaxofarray(numarray) { return math.max.apply(null, numarray); } getmaxofarray([1,3,9]) //9 getmaxofarray(1,3,9) //error i understand .apply passes array, why should max function work them when called via apply? there internal transformation array => list ? apply expects parameters in array. if have parameter list how in second case, use call instead math.max.apply(null,[1,3,9]) math.max.call(null,1,3,9) what difference between call , apply? goes amount of detail on difference between call , apply

php - while (!feof($handle)) -- Error code to warning information -

http://www.example.com/pageview?test=111&test2=999 -> data loading , working.. 189 <?php 190 $handle = @fopen("http://www.example.com". htmlspecialchars($_get["test"]) ."/". htmlspecialchars($_get["test2"]) .".txt", "r"); 191 while (!feof($handle)) 192 { 193 $buffer = fgets($handle, 4096); 194 195 if (strlen(trim($buffer)) > 0){ 196 197 list($a,$b,$c,$d,$e,$f,$g,$h,$i,$j)=explode(",",$buffer); 198 199 $items[] = array('col1' => $a,'col2' => $b,'col3' => $c,'col4' => $d,'col5' => $e,'col6' => $f,'col7' => $g,'col8' => $h,'col9' => $i,'col10' => $j); 200 } 201 } 202 ?> http://www.example.com/pageview?test&test2= -> not loading.. normal error in page.. warning: feof(): supplied argument not valid stream resource in /home/---/public_html/---/---.php on line 191 warni

Javascript executed after the load of a PartialView via ajax in a JQuery Dialog works only once -

i know it's long title ^^ i'm using mvc 4 , jquery version 1.8.2. i'm loading partialview in jquery dialog , works fine. recently wanted add javascript, hide textbox in dialog, , here starts pain. the javascript hide code works : only once, if close dialog $(this).dialog('close'); everytime, if close dialog $(this).remove(); i'm not expert in jquery / javascript i'd understand what's going on :) here's code : $(function dialoglink() { // don't allow browser caching of forms $.ajaxsetup({ cache: false }); // wire click event of current or future dialog links $('.dialoglink').on('click', function () { var element = $(this); // retrieve values html5 data attributes of link var dialogtitle = element.attr('data-dialog-title'); var updatetargetid = '#' + element.attr('data-update-target-id'); var updateurl = element.attr('data-update-url');

javascript - How to show overflow content in bootstrap modal -

i using modals bootstrap web/mobile application. , intention modals fill on whole mobile screen when triggered. have added custom css make modals 'full size'. .modal { &.full_size { top: 0; bottom: 0; left: 0; margin-left: 0; width: 100%; height: 100%; } } however, on mobile phone, although did see full screen modal being display, don't seem able see contents 'overflow' full screen modal i.e. if content height greater screen height, won't able scroll down see rest of content. how can resolve can scroll , see content in modal? try adding overflow:auto; allow scrolling when content exceeds container's dimensions

regex - How to write a regular expression to get text inside XML tags? -

Image
i trying write regular expression return text inside xml tags. instance if had file format <name>joe blog</name> <email>abc@sample.com</email> <address>123 sample st</address> how extract text address field? any appreciated. thanks, this expression capture address value <address>(.*?)<\/address> and place first capture group example sample text <name>joe blog</name> <email>abc@sample.com</email> <address>123 sample st</address> matches [0][0] = <address>123 sample st</address> [0][1] = 123 sample st however most langages have html parsing tool, example in php using: $dom = new domdocument(); $dom->loadhtml($your_html_here); $addresses= $dom->getelementsbytagname('address'); foreach($addresses $address) { $address = $address->innertext; // }

mysql - relationships one to one -

i hope can me this. trying develop online admission system in php/mysql. have far created 2 tables: 1- member (memberid (auto increment), username, email, password, activation) 2- personal_details (nationality, religion, passport no, place of birth, date of birth) i split data 2 tables reduce load on tables. can please tell me how define one-one relationship in such cases. thanks you put memberid column on each table regular foreign key relationship. difference should put unique constraint or primary key constraint on both tables. it's uniqueness constraint changes relationship 1:n 1:1 relationship.

creating dir with mkdir in debian -

i trying create directory using mkdir in debian problem directory created in root directory. problem comes trying install openfoam , suspect because "$" used create it. following instructions in openfoam web site, says create folder $home/openfoam/user-2.2.1 and then, create within folder called "run" using: mkdir -p /foam_run the problem final directory (run) should have following form: /home/openfoam/user-2.2.1/run but using debian cannot create dir "sudo", have root , when go inside directory /home/openfoam/user-2.2.1 , mkdir -p /foam_run , created folder is: /root/openfoam/root-2.2.1/run and need created in /home directory , not in /root directory. had created folder using mkdir -p /home/openfoam/user-2.2.1/run but when try execute openfoam orders doesn't work. my questions are: why should mkdir $foam_run create run directory , if "mkdir run", doesn't work? why "$" symbol there when use mkdir

java - How to cache data in server using files -

i writing application in need store huge amount of data in db , cache same. when ever client requests comes, server needs fetch data cache , return same. here how doing it: (offline process) 1. have spring batch application gets json file (around 6mb in size). 2. reads each object , store in db. 3. approximately 17k records being stored in db. (online process) 4. when ever request comes server (web app - spring web mvc), app gets data db , returns response. i planing avoid db storage here. instead of using db, can add file in file server , cache data present in file whenever server started? let me know if there existing methodology. caching won't replacement persistence. can store data in file system instead of db whole point of having db in first place data storage , retrieval faster in db in normal file system because of better structuring of data , indexing (along huge advantage of ease of querying data). can dump data in db in huge file formats (not recom

c++ - Is std::unique_ptr ABI-compatible with raw pointers? -

my reading std::unique_ptr has convinced me (along other smart pointers) best choice pointers internally in project (especially after could optimizing compiler remove runtime costs std::unique_ptr? ), i'm not sure yet @ interface. don't grok how various c++ abis work, please bear me if dumb question, functions take or return pointers, classes/structs have pointer members, etc. replaced uses unique_ptr (maybe using unique_ptr refs?) without requiring recompilation? can c code interact c++ interfaces using unique_ptr without complication? afaik, there's no guarantee sizeof(unique_ptr<t>) == sizeof(t*) , no. but if same size, there's no guarantee arbitrary abi pass pointer arguments same mechanism "value" arguments.

ipad - how can i test my camera on xcode without a device (using output from simulator)? -

i making ipad app uses camera. not have ipad cannot test app on device. there way figure out if camera works using output simulator? i'm afraid you're creek here. if memory serves pure going see black screen in simulator. know it's covered in developer library since they're overhauling portal can't exact verbiage. mentions simulaor can't emulate accelerometer or camera.

How to invalidate specific session at logout in Rails /w Devise? -

i want invalidate session when user logs out using devise, have callback catch when user logs out, more protection against session hijacking. class applicationcontroller < actioncontroller::base def sign_out(*args) super(*args) reset_session end end my understanding remove session info stored on server side, therefore invalidating it. however can still login using session id got before signing out. misunderstanding how works? want invalidate session, not of them. i using default session_store. after googling , meditating, came apon question , modified fit needs, all did application_controller.rb def sign_out(*args) current_user.update_attribute(:current_sign_in_token, "") super end which invalidate sign_in_token, invalidating session, hijacking session id still kicked out.

with django app, how to link to image in .css file -

so in website, make , in css, do #logo { background: url(../images/logo.jpg); } however, no since using django project, image in c:\users\me\documents\mysite\myapp\static\images and .css file in c:\users\me\documents\mysite\myapp\static\css in settings.py, static_root is static_root = 'c:/users/me/documents/mysite/myapp/static' i tried doing #logo { background: url({{ static_url }}/images/logo.jpg); } but didn't work. idea i'm doing wrong , how fix it? since have both directories in same path "static", usual: #logo { background: url(../images/logo.jpg); }

java - Why does this cause a ClassCastException? -

public class test8 { public static void main (string args[]) { number numberref = new integer(0); double doubleref = (double)numberref; } } it shows me exception @ runtime: exception in thread "main" java.lang.classcastexception: java.lang.integer cannot cast java.lang.double why so? you trying cast instance of integer reference double cannot happen. integer , double 2 different classes , objects of each cannot cast each other number common super class integer , double , hence instance of double or integer can upcasted number . in other words, integer is a number , double is a number but, integer is not a double integer = new integer(0); double d = new double(1); number ni = i; number di = d; integer id = d; //invalid; double dd = i; //invalid

php - Writing parameters to a database and link encryption -

i writing database using parameters link. consider following link: mywebsite.com/index.php?ud=33&nt=117&g=yes if play link , change values write database wrong data, available ways prevent happening? note links clicked email message what thinking of 1 time authentication key per message works 1 time cost alot of space on databas, there better way? remember sensitive data shouldn't in querystring. follow these steps: 1 - before write link database, should check part of business rule if parameters consistent , user has permission access it. 2 - then, should think params of querystring should in plain text (i.e. inside link stored in database). example, if keep id of entity querystring , send database, must think if there problems in case mentioned entity deleted. since querystring in plain text, no cascade performed. in case, best approach convert query string data , store in database foreign keys instead of querystring. then, can recover full lin

flash cs3 - randomize/shuffle array item without repeat actionscript 3.0 -

i creating question , answer quiz using flash cs3 , actionscript 3.0. have large array of question, wish put xml document(can xml file reside in flash file itself?i thought ive seen did that.) ok,my main problem shuffle questions without repeat until questions asked. have worked on tutorial,and great shuffling without repeat. http://www.flashandmath.com/howtos/deal/ but,i wish ask 1 question @ once. have looked option shuffle frames, think how can count score of quiz @ end of it? so have edited codes according answer, i want make button named "check" check if answer filled correct or wrong. , score increase if answer right. user hit button named "next" go next question. the final score shown @ next frame, after questions finished. alright bring score counted next frame? or, should make movie clip visible score when question ended? check_btn.addeventlistener(mouseevent.click, checkanswer); next_btn.addeventlistener(mouseevent.click, nextquestion);

jquery - Save path to the remote img with cookies? -

i'm using jquery (1.10.1) + backstretch , cookies plugin . idea set remote img , save path img using cookies . first part wasn't hard: $("#own").click(function(e) { e.preventdefault(); var own = $("input#img-link").val(); $(".backstretch img").attr("src", own); $.cookie("postcode", $("input[name=postcode]").val()); }); if ( typeof $.cookie("postcode") !== "undefined") { $("input[name=postcode]").val($.cookie("postcode")); } now i'm litle bit confused of how can set cookies work it. i've found example example link : $('#go').click(function(){ $.cookie('postcode', $('input[name=postcode]').val()); }); //retrieve cookie on load if it's not undefined if(typeof $.cookie('postcode') !== 'undefined'){ $('input[name=postcode]').val($.cookie('postcode')); } cookies stor

angularjs - The real (or hidden) difference/s between Twitter bootstrap and Angular.js -

i've been comparing these 2 frontend frameworks , can tell, seem exact same thing in terms of providing dev html, css , js frontend. boostrap: sleek, intuitive, , powerful front-end framework faster , easier web development. (over 53 000 starred on github) angular.js: angularjs structural framework dynamic web apps. (12 000 starred on github) the ratings mean nothing, thought i'd put in there show isn't 'quickie' question didn't research. from i've understood of angular through wikipedia, aims separate frontend design/layout/ui backend - database is, web server , business logic happens. from understand of bootstrap (with js) can achieve exact same thing. the angular site mentions: other frameworks deal html’s shortcomings either abstracting away html, css, and/or javascript or providing imperative way manipulating dom. neither of these address root problem html not designed dynamic views. now i'm not sure if they're taking pot

rotation - Inertia Tensor (OpenGL) -

i have been working on rigid body mechanics system week , not sure doing wrong. have rotation matrix computes rotations in yxz order. rotations computed based off of previous rotation , updated offset. inertia tensor computed every time detect collision using rotation matrix i.e. = rot*i0*rotnot. i0 constant inertial frame when rotations lined principle axis. trying compute resultant angular , linear velocity of object after collision. code have below messy commented , based on off of wikipedia page http://en.wikipedia.org/wiki/collision_response scalar jr computation , angular , linear velocity computations. //calculate inertia tensor based on rotation matrix matrix rotmat = rectangle1->getrotmat(); matrix trotmat = rotmat.transpose(); i1 = rotmat*i1*trotmat; //inverse of i1 //determinant of i1 float det1 = i1.getdeterminant(); //transpose of i1 matrix i1t = i1.transpose(); //cofactors float *a = i1t.getmatrix(); matrix i1n

html5 - Library for universal XML parser app -

i have developed simple html 5 app parses list of products in xml form , displays data. i extend app work valid xml input , create web based ui allow user view xml structure , label according it's application. in other words, instead of defining node names "product" , "price", names of elements pulled xml, user defines , go. my question: there library or method exists capable of outputting xml structures dynamically?

java - Buzzing on Exit -

i'm trying build game uses sound effects. haven't dealt java api before may making mistakes. said though, effects work great — my problem strange buzzing sound maybe second whenever program exits. any idea how might rid of it? right i'm trying kill playing sounds before exit takes place killloop() method, isn't getting me anywhere. i'd appreciate help! public class sound { private audioinputstream audio; private clip clip; public sound(string location) { try { audio = audiosystem.getaudioinputstream(new file(location)); clip = audiosystem.getclip(); clip.open(audio); } catch(unsupportedaudiofileexception uae) { system.out.println(uae); } catch(ioexception ioe) { system.out.println(ioe); } catch(lineunavailableexception lua) { system.out.println(lua); } } public void play() { clip.setframeposition(0); clip.start(); }

java - Run jar through php -

im trying run jar file php using shell_exec(java -jar c:/myfile.jar) . not working , im getting following error in apache error log. "java not recognized internal or external command". working windows command prompt well. please help. it sounds java.exe executable isn't on path. just include fully-qualified path it, quoting necessary if directory contains spaces.

objective c - Implicit declaration of function "..." is invalid in C99? -

i'm trying declare function within function. here's part of code: viewcontroller.m - (void)updatedisplay{ [_displaytext settext:[nsstring stringwithformat:@"%d", counter]]; } - (ibaction)minus1:(id)sender { counter--; updatedisplay(); } viewcontroller.h - (ibaction)minus1:(id)sender; - (void)updatedisplay; which returned me error of "implicit declaration of function "..." invalid in c99". result: http://i.imgur.com/rsit6r2.png i've found people have encountered similar problem, newbie didn't know next. help! :) implicit declaration of function '...' invalid on c99 you not declaring function ; instance method , call must send message self ; [self updatedisplay]; edit as @rmaddy pointed out (thanks that) declared instance method not class method. make things clear; - (return_type)instance_method_name.... called via 'self' or pointer object instance. + (return_type)class_metho

javascript - How to pass arguments to a function in setTimeout -

i have following code: function fn($){ return function(){ innerfn = function(){ settimeout(show, 1000); }; show = function(){ $.alert("test"); } } } but, after 1 second, when function show run, says $ undefined. how resolve issue? how pass arguments function in settimeout settimeout has built in mechanism adding params var timeoutid = window.settimeout(func, delay, [param1, param2, ...]); use it. if you're going use this - should careful. that's question.

c++ - Storing values in arrays -

the user supposed enter name followed grades. when user hits -1 there can no more grades stored individual. when user types x, s/he enters total , -1 indicate no more grades can stored. don't understand why loops outputting in weird way. names array storing int values supposed go numbers array. for example, input should this: jane 3 4 -1 lane 4 5 -1 x 10 10 -1 the output should this: jane 3 4 jane had 7/20 lane 4 5 lane had 9/20 this work far: #include <iostream> #include <cstring> #include <string> using namespace std; int main() { string name = " "; string names[20]; int numbers[20]; int = 0, j=0, number; { cin >> name; names[i]=name; i++; j=0; if(number!=-1) { cin>> number; numbers[j]=number; j++; } }while(name!="x"); for(int x = 0; x <= i; x++) { for(int y = 0; y <= j; y++) { cout << names[x]; } } } one issue code ,

Performance of CUDA __threadfence() synchronization versus synchronization by two separate kernel calls -

i'm trying understand how use __threadfence() , seems powerful synchronization primitive lets different blocks work without going through huge hassle of ending kernel , starting new one. cuda c programming guide has example of (appendix b.5), fleshed out in "threadfencereduction" sample in sdk, seems "should" using. however, when have tried using __threadfence() , shockingly slow. see code below example. understand, __threadfence() should make sure pending memory transfers current thread block finished, before proceeding. memory latency better microsecond, believe, total time deal 64kb of memory transfers in included code, on gtx680, should somewhere around microsecond. instead, __threadfence() instruction seems take around 20 microseconds! instead of using __threadfence() synchronize, can instead end kernel, , launch entirely new kernel (in same, default, stream synchronized), in less third of time! what going on here? code have bug in i'm not n

ios - Pass data from one viewcontroller to existing viewcontroller programmatically -

recently stuck in problem cannot move on next coding part. there 2 view controllers(let's first.m , second.m) , pass parameter data 1 view controller without using storyboard. tricky part me second view controller initiated in appdelegate.m file. i can pass data if have initiated second view controller in first view controller importing header file, example.. @import "second.h" second *secondview = [[second alloc] initwithnibname:@"secondnib" bundle:nil]; secondview.somestringvalue = @"passthisstring"; however, coding makes new second view controller, not want. found there like myappdelegate *appdelegate = (myappdelegate *)[[uiapplication sharedapplication] delegate]; to connect appdelegate.m file. after few days struggling brain getting blackout. please give me advice.. there way pass data existing view controller without using storyboard? or way through appdelegate second view controller. appreciated @jazzed28 can without init

java - Reflection finding method with Generic Type withing Parameterized Class -

i have class following signature: public class multiplesorting<t extends enum<?>> { private class<t> criteriatype; private t selectedcriteria; public multiplesorting(class<t> criteriatype) { super(); this.criteriatype = criteriatype; } public void setselectedcriteria(t selectedcriteria) { this.selectedcriteria = selectedcriteria; } public t getselectedcriteria() { return selectedcriteria; } public class<t> getcriteriatype(){ return criteriatype; } public void setcriteriatype(class<t> criteriatype){ this.criteriatype = criteriatype; } } i instantiating new multiplesorting(articlesortfield.class); . here articlesortfield enum . method within multiplesorting when trying method setselectedcriteria through reflection as: method setselectedcriteriamethod = getclass().getdeclaredmethod("setselectedcriteria",getcriteriatype()); th

ios - playing sound and changing image in UIImageView when button is pressed -

as title describes i've been able add sound when button pressed, wondering if there way add image change main uiimageview when same button pressed. there way stick picture code in "playfaceofaudiotype" method presented? here's code far: #import "fourthviewcontroller.h" @interface fourthviewcontroller () @end @implementation fourthviewcontroller @synthesize audioplayer; - (id)initwithnibname:(nsstring *)nibnameornil bundle:(nsbundle *)nibbundleornil { self = [super initwithnibname:nibnameornil bundle:nibbundleornil]; if (self) { // custom initialization } return self; } - (void)viewdidload { [super viewdidload]; // additional setup after loading view. } - (ibaction)facesaudioaction:(id)sender { uibutton *btn=(uibutton *)sender; [self playfaceaudiooftype:btn.tag];//tag button set on xib.. } -(void)playfaceaudiooftype:(int)type{ [self stopaudio]; nsstring *sound=@""; switch (t

xliff - Filter.jar in java project -

i want ask xliff filters.jar file. xliff (xml localisation interchange file format) xml-based format created standardize way localizable data passed between tools during localization process. my project localization. translating sentences source destination language.i want use filters. jar can take input in file format , translation done , output is. so want know how use filters.jar file in existing project. how import jar file in eclipse project ? thank u if work eclipse read page without eclipse : javac -classpath external.jar myclass.java edit: if main class in package package com.mycompany; public class myclass { ... ... you'll need javac -classpath external.jar com/mycompany/myclass.java and to run java -classpath external.jar com.mycompany.myclass

windows ce - Hardware Keyboard support for several language [WIN CE 6.0 CF] -

i'm working on platform wince 6.0 r3 compact framework. change settings in register different culture , different language layouts. works text, time, date, etc. when connect usb hardware keyboard 3 languages supported: usa, korea, , japan. i want other languages finish, swedish, germany, etc. guess need drivers? how solve this? feels i'm not first 1 going down path. you'll need update keyboard driver's key map include other keyboards. had decade ago finnish on ce 5.0, don't recall of details know simple change layout map , took little actual time fix. did, however, require recompile of driver , os. msdn has pointers drive location current layouts, etc. are .

ios - App name not available in iTunes -

in itunes have created 1 app name. , after have edited name before uploading build. have tried revert previous name whice entered first. getting message "the app name entered has been used.". please me old app name. thanks, jasmine. unfortunately can't. since have used name in past name locked , cannot use again. strangely, doesn't matter same app. if try contacting apple , explain situation.

c# - Programly scroll list box -

Image
my problem have newslist box: taping on item open aticle page full article. so, when return on news page see list box before navigated article, want item used appear on top 1) changing index doesn't because must remain are. i have tried: if (currentarticle < newslistbox.selectedindex) { var scrollviwer = getscrollviewer(newslistbox) scrollviewer; if (scrollviwer != null) { scrollviwer.scrolltoverticaloffset(scrollviwer.verticaloffset + (newslistbox.selectedindex - currentarticle)); } currentarticle = newslistbox.selectedindex; } else if (currentarticle == newslistbox.selectedindex) { } else { var scrollviwer = getscrollviewer(newslistbox) scrollviewer; if (scrollviwer != null) { scrollviwer.scrolltoverticaloffset(scrollviwer.verticaloffset - (currentarticle - newslistbox.selectedindex)); } currentarticle = newslistbox.selectedindex; } public static dependencyobject getscrollviewer(dependencyobject o) {

PHP 5.4 php_ssh2 dependend library libssh2.dll can't register in window server 2008-x64 -

recently deploy php 5.4.17-nts - version on windows server 2008 -x64 r2 standard . download php5.14.17 http://windows.php.net/download/ , php extension ssh2 (php_ssh2-0.12-5.4-nts-vc9-x86.zip) http://windows.php.net/downloads/pecl/releases/ssh2/0.12/ . but, after add ssh2 extension on php.ini file , check version of php, throw error message "the program can't start because libssh2.dll missing computer. try reinstalling program fix problem". i execute command regsvr32.exe registered "libssh2.dll" , failed. interesting, if use version php 5.3 , 0.11 version ssh2 , doesn't show error message, ssh2 version 0.11 php 5.3 has 1 dll php_ssh2.dll on php_ssh2-0.11.2-5.3-nts-vc9-x86 folder. on php_ssh2-0.12-5.4-nts-vc9-x86.zip contains 3 files 1 php_ssl.dll , libssh2.dll , pdb file. queries know 1) php_ssh2-0.11.2-5.3-nts-vc9-x86 contains 1 dll ( php_ssl.dll ), php_ssh2-0.12-5.4-nts-vc9-x86.zip contains 2 dll ( php_ssh2.dll , libssh2

Can I use a PayPal donation button in my Android app in Google Play? -

my country not supported google merchant account can't publish paid apps. donations users. know google says in policy payments must go through google play. how donations? can use donation button, links paypal accept donations? or can use paypal mobile payment libraries (mpl) accept donations? yes can use paypal services in app there many apps using example- check link https://play.google.com/store/apps/details?id=biz.apporiginal.creditcall

iphone - Load UITableViewController before webservices -

i trying load data web-services , insert uitableviewcontroller . i can problem is, 'hang' short period @ first uiview before going uitableviewcontroller , when loading web-services internet. hang longer if internet speed slow. any chance can showing empty uitableviewcontroller first 'loading' sign , start retrieving data web-services , reload table? currently, put function used call web-services in - (void)viewdidload { [super viewdidload]; self._completelist = [[nsmutablearray alloc]init]; self._completelist = [self getlistfromwebservices]; } best approach suggestion have use grand central dispatch (gcd) bellow example dispatch_async(dispatch_get_global_queue(dispatch_queue_priority_default, 0), ^{ //code webservices calling dispatch_async(dispatch_get_main_queue(), ^{ //reload tableview here [self.tableview reloaddata]; }); });

java - XHR Error : Origin http://localhost is not allowed by Access-Control-Allow-Origin -

i'm working on application uses spring mvc, , jquery on client side. ajax call executed client (a page hosted on apache running on port 80) looks : var login = function() { $.ajax({ url: "http://localhost:8080/login", type: 'post', data: { key: "value" }, error: function(jqxhr){console.log("error");} }).done(function(data, textstatus, jqxhr) { console.log(jqxhr.responsetext); }); return false; } and server (tomcat running on port 8080) designed follows (taking account cors requirements) : @requestmapping(value = "/login", method = requestmethod.post) @responsebody public string login(httpservletresponse response, @requestbody map<string,object> requestparameters){ response.setheader("access-control-allow-origin", "*"); response.setheader("access-control-allow-headers", "*"); response.setheader("access-control-request-method","

php - How to encrypt in device and decrypt in server side with encryptoin key -

what best practice encode string encryption key(like password) in device side(android , ios).and decode encoded string in server side encryption key used in device side. you try 1 of following rsa encryption: encrypt using public key in ios device , decrypt using private key in web service host web service ssl certificates set secured vpn , access service through vpn. since mentioned encrypting passwords.salting , hashing password preferred.

ruby on rails - Transition after a certain period of time in state machine -

i developing rails app , using state_machine gem guide customer through complex process. at multiple states of process, need trigger events after period time. instance, if customer hasn't confirmed received order after 5 days i'd automatically send him email , enter in parcel tracking process. class order < activerecord::base state_machine :initial => :confirmed after_transition :on => :not_received_by_5_days, |order, transition| order.send_email order. ..... order. ..... event :customer_confirmation transition :confirmed => :order_received end event :not_received_by_5_days transition :confirmed => :parcel_tracking_process end def send_email blabla end end end editing after testing previous solution: how can trigger transition after period of time? thank you, clément to break solutions 2 major gro