Posts

Showing posts from February, 2013

python - Locational triangulation -

i have data 10 points in 2d map, know location of points 1,2 , 3. know distance between point 1,2 , 3 other points. i know cell phone uses distance gsm towers locate location. wish use similar approach locate points 3-10. how can implement such solution python? libraries can use? thank help first, solve math. make drawing. find can use 2 points , distance reduce possible points two, third 1 needed disambiguate between two. putting whole python should easy then. note i'm not going spell out you, because customary not spoil other programmers experience of doing own homework, doing research etc. if have have problem with, ask specific questions , demonstrate effort on side first.

jsf - How to initialize variables in a session scoped bean -

i have 2 booleans controls render of components, problem variables saves there last state until session expires, i <f:facet name="footer"> <p:commandbutton action="#{personbean.report}" ajax="false" value="publish" rendered="#{personbean.reportmode}" icon="ui-icon-check" /> <p:commandbutton action="#{personbean.saveediting}" ajax="false" value="save" rendered="#{personbean.editmode}" icon="ui-icon-check" /> </f:facet> the bean session scoped , has following attributes: @managedbean(name = "personbean") @sessionscoped public class reportperson { private boolean editmode; private boolean reportmode; } the bean contains these method changes values of booleans: public string editperson() { system.err.println("edit missing person"); editmode = true; repo

php - Why Iframe dosen't work for yahoo.com -

i find doesn't work: <iframe src="http://www.yahoo.com"> </iframe> i have read question , don't understand mean add: <?php header('x-frame-options: goforit'); ?> i tried add top of html file(change php file, of course), , php file became: <?php header('x-frame-options: goforit'); ?> <iframe src="http://www.yahoo.com"> </iframe> i run in appserv(with php 5.2.6), , doesn't work. explain should overcome this? you're out of luck: yahoo.com doesn't allow embed site in iframe. nor facebook or other popular sites. the reason restriction clickjacking . you can verify checking response headers site; specify x-frame-options:sameorigin means yahoo.com can embed yahoo.com pages. some older browsers won't enforce header new ones will. afaik, there's no simple way around it. the solution can think of implementing proxy script, i.e. embed script lives on server fetch

html - form onchange AJAX function for PHP database query -

i quite new ajax , appreciate help. have been trying use ajax onchange of first drop down menu call function php query database , populate matching results second drop down menu. db connect script works fine, , php query accurately pulls correct info database. (when not using posted variable $cityinput) problem has been getting result php ajax, , displayed in second drop down menu. <?php require'connect.php'; $cityinput=$_post['cityinput']; $query="select mname masseurs lounge='$cityinput'"; $result=mysql_query($query); $num=mysql_numrows($result); echo "<b><center>database output</center></b><br><br>"; $i=0; while ($i < $num) { $mname=mysql_result($result,$i,"mname"); $mname="<option value=''>"mname"</option>"; $i++;} if (!mysql_query($query)) {die('error: ' . mysql_error());} mysql_close(); ?> <html> <head> &

asp.net mvc - How can i load partial view dynamically? -

how can load partial view dynamically?i tried use querystring below got error when runtime. my code: @html.partial("_sample?id=3") you can like: @html.action("sample", "users", new { userid = 1 }) and in userscontroller : [childactiononly] public actionresult sample(int userid) { // stuff here }

magento database restore duplicate entry -

i have issue when try restore . see error 1062 (23000) @ line 1893: duplicate entry ' type of error. don't understand because used blank database , try restore it. original backup magento 1.6.2 , try restore in magento 1.7 . when try restore via ubuntu terminal see error. solution type of error. thanks

Yii: Naming relations and fields -

i wrote yii code same name db field , relation: public function relations() { return array( 'kin' => array(self::belongs_to, 'kin', 'kin'), 'child' => array(self::belongs_to, 'child', 'child'), ); } now understand wrong, because relations "cover" on field attributes , queries $this->child child id not work. my question: naming scheme suggest db fields , relations? firstly, i'd avoid naming primary key after table. makes kind of statement difficult read. name primary keys childid or kinid; way it's clear field you're talking about. i think there no hard , fast rules naming, except use makes sense in context. this, assuming i've understood table structure correctly, i'd inclined go this: table 1: kin primary key: kinid table 2: child primary key: childid foreign key table kin: fkkinid then, assuming 1 kin can have many children, relation in kin model be

c++ - Function variable instead of pointer to function -

there code: void a() { } // function parameter first defined function, pointer function void g(void f() = a, void (*d)() = a) { } int main(){ void (*z)() = a; // works ok //void z() = a; error: illegal initializer (only variables can initialized) return 0; } in function parameter list can define function parameter function or pointer function (see function g parameter list). in main function pointer function version seems work. there way define function variable (not pointer function) in block scope (like void f() = a variable in g function)? you cannot have variables of function type in c++. can either have pointers or references functions, though: typedef void (funtype)(); void call(funtype & f) { f(); } // ok, funtype & == void (&)() void call(funtype * g) { g(); } // ok, funtype * == void (*)() in sense, always call function through function pointer: expression value function decays corresponding function pointer. in above examples,

spring - update XML file in a page Jsp -

i use spring security , have many roles in database example role_admin , role_user in xml file named "spring-security.xml" defin each page wich role can see : <http auto-config="true"> <intercept-url pattern="/" access="role_admin,role_user" /> <intercept-url pattern="/index*" access="role_admin,role_user" /> <intercept-url pattern="/les_statistiques*" access="role_admin,role_user"/> <intercept-url pattern="/mise_a_jour*" access="role_admin,role_user" /> <intercept-url pattern="/recherche*" access="role_admin,role_user" /> <form-login login-page="/login" authentication-failure-url="/faillogin" /> <logout logout-success-url="/logoff" /> <access-denied-handler error-page="/403"/> </http> what w

Sorting two stacks by using structs -

there 3 stacks - a, b, c stacks , b sorted (the number on top of stack biggest). stack c empty 5 operation allowed: push, pop, top, is_empty, create we need write function receives stacks , b, moves numbers in stacks , b stack c , stack c must sorted (biggest number on top). i have algorithm : compare top of top of b pop least element , push stack c repeat step 2 until of stack ( or b) becomes empty move remaining elements non-empty stack c. have elements in c in ascending order. (that least element @ top). move elements c a. (contents in in descending order) move elements b. (contents in b in ascending order) move elements b c. and started write code there errors , don't know why ! the code : #include <stdio.h> #include <stdlib.h> #include <conio.h> #define max_members 10 typedef struct { int num; }item; typedef struct { item a[max_members]; int top; }stack; void create_stack(stack *s) { s->top=-1; } int is_

Regex end modifier not returning results in a Go program -

i have simple program in go aid in learning regular expressions. runs in infinite loop , has 2 channels, 1 used provide input (input contains regex pattern , subject), , second one, provides output. usage: main.exe (cat)+ catcatdog however there propably wrong in code, can't seem results $ modifier. for example, expect "cat" output from main.exe cat$ cat\ndog yet receive 0 results. code: package main import ( "fmt" "regexp" "bufio" "os" "strings" ) type regexrequest struct { regex string subject string } func main() { regexrequests := make(chan *regexrequest) defer close(regexrequests) regexanswers, err := createresolver(regexrequests) defer close(regexanswers) if(err != nil) { // todo: panics when exited via ctrl+c panic(err) } interact(regexrequests, regexanswers) } func interact(regexrequests chan *regexrequest, regexanswers chan []

algorithm - How to determine the runtime of this function -

i'm having trouble basic runtime understanding, maybe can clarify me. how go determining runtime of function? i need determine rather f = o(g) or f = omega(g) or f = theta(g) f(n) = 100n + logn g(n) = n + (logn) 2 so 100n , n in same order; , linear time > log time; @ point still need @ log part? or can determine f = theta(g) ? you can safely determine same order of magnitude. there no need @ "log part". here formal proof specific case, general proof can shown limit arithmetic. let's @ function h(n) = f(n)/g(n) n approaches infinity, if stays bounded above 0 , below number m know f(x) = theta(g(x)) (because of how theta defined). so have h(n) = (100n + logn)/(n + logn^2) we know if show for real x, holds natural numbers too. enough show for: h(x) = (100x + logx)/(x + logx^2) we know l'hospital's rule if derivatives of nominator , denominator exist , converge limit of original function exists , equals same number

java - How to map an array index to a certain date? -

i want map index 3d array date. have array (sorteddata[34][12][31]) , have if date selected jcalendar corresponds correct index in array. e.g. date 01/01/1974 selected map sorteddata[0][0][0]. how go doing this? thanks. use java.util.calendar object day, month , year of date: calendar calendar = new gregoriancalendar(); calendar.settime(thedate); int year = calendar.get(calendar.year); int month = calendar.get(calendar.month); int day = calendar.get(calendar.day_of_month); then indices in array using int = year - 1974; int j = month; int k = day;

java - To use Android Studio encountered an error -

i have android studio (google i/o preview). created android project in android studio, , when run it, studio tell me : /usr/lib/jvm/java-1.7.0-openjdk-amd64/bin/java -ea -didea.launcher.port=7534 -didea.launcher.bin.path=/home/username/android-studio/bin -dfile.encoding=utf-8 -classpath /home/username/android-studio/lib/idea_rt.jar:/home/username/android-studio/plugins/junit/lib/junit-rt.jar:/home/username/android-studio/sdk/platforms/android-17/android.jar:/home/username/android-studio/sdk/platforms/android-17/data/res:/home/username/android-studio/sdk/tools/support/annotations.jar:/home/username/androidstudioprojects/test/test/libs/android-support-v4.jar com.intellij.rt.execution.application.appmain com.intellij.rt.execution.junit.junitstarter -ideversion5 @/tmp/idea_junit6666593680737984739.tmp -socket52225 exception in thread "main" java.lang.noclassdeffounderror: junit/textui/resultprinter @ java.lang.class.forname0(native method) @ java.lang.class.forname(class.ja

.htaccess or something adds additional stuff to the URL. PHP -

i started work .htaccess on website i'm working on. works fine, when try acces user.php file located on index, keep getting url: http://lifeline.andornagy.info/user/?url=user on every other file , place, works great. this function call different pages depending on url : public function lifeline() { global $templatepath; if ( isset($_get['url']) && $_get['url'] !== 'user' ) { $url = $_get['url']; $result = mysql_query("select * posts url='$url' "); if ( !mysql_num_rows($result) ) { if ( file_exists($templatepath.'404.php') ) { include_once($templatepath.'404.php'); } else { include_once('404.php'); } } while($row = mysql_fetch_assoc($result)){ if ( $row['type'] === 'post' ) {

emacs - Line wrapping in visual-line-mode -

is there way make lines wrap @ specific column in visual-line-mode ? in virtual console lines long read comfortably. this seems similar this post . in particular, this might interesting.

c - Error:unresolved external symbol _popen -

why using popen result in error: failed close command stream under windows? you have use: _popen , _pclose (yes silly underscore) under windows. see msdn entry on it ; has nice example now _popening "ps" know whether or not have ps on system.

client - Remote login desktop environment -

so here's deal, started whole server world , genius , practical! started slow file sharing , remote login. can manage login server ssh , it's great command line interface not enough want do. remembered in university students able login university-account computer connected university server, wether windows, freebsd or gnu/linux distribution such debian or fedora. i'm trying same @ home. server , running on debian want able login server desktop environment, in university. client i'm using macbook pro running mac os x lion. don't know protocol or how set clue? what looking vnc (virtual network computing). http://en.wikipedia.org/wiki/virtual_network_computing

javascript - Rainbow Effect not working correctly with A hrefs -

i have code trying write website host, member asked support. , wrote this, , works text hrefs ruins markup. http://jsbin.com/izebej/1/edit code: $.getscript("http://xoxco.com/projects/code/rainbow/rainbow.js",function() { var selectme= ["u1","u2"]; for(var =0;i<selectme.length;i++){ $('.username').find('a[href*='+selectme[i]+']').addclass('selected'); } $('.selected').text(function() { $(this).rainbow({ colors: [ '#ff0000', '#f26522', '#fff200', '#00a651', '#28abe2', '#2e3192', '#6868ff' ], animate:true, animateinterval:100, pad:false, pauselength:100 }); }); }); the markup in jsbin- can see happening. i've tried many different ways. if @ markup marked href last 1 u21, seeing object wrote u1 , u2. combining them see if looki

Is multiple inheritance possible in javascript? -

this question has answer here: does javascript support multiple inheritance c++ 4 answers i have situation here. have 2 modules(nothing javascript function) defined this: module1: define(function(){ function a() { var = this; that.data = 1 // .. } return a; }); module2: define(function(){ function b() { var = this; that.data = 1; // ... } return b; }); how inhert both modules inside other module? 1) in js object. 2) javascript inheritance uses prototype inheritance , not classic inheritance. javascript doesn't support multiple inheritance. have both of them inside same class try use mixins better anyhow: function extend(destination, source) { (var k in source) { if (source.hasownproperty(k)) { destination[k] = source[k]; } } return destination;

php - Receive info regarding the amount of cookies created by other domain -

user visit site , type input address of site. jquery send ajax request php script , now: how php script can check amount of cookies domain creates (domain input) ? thanks help. you need check headers of connection create server website. every cookie header starting with: set-cookie: ... you can use of curl in php , curlopt_nobody . the user manual here .

php - htaccess redirection with PHPSESSID -

could me redirect using htaccess i'd : www.some site.eu/?p=73&phpsessid=8448afcfa47802a65d8f451b14262b45 content p , different phpsessid redirect www.some site.eu/ and one www.some site.eu/cms.php?id_cms=3 www.some site.eu/content/3-rules

php - Cakephp 2.x Stuck with Auth component with different models -

i'm coding app car selling, i'm stucked auth component. have 3 kind of access: admin: app owner dealers: owners of car dealers user: people whach car offers , make questions etc i'm not working roles, ech 1 (admin, dealer , users) has username , password diferent models, i'm lost. i'm not asking codes, wanna explanation how can deal auth assuming scenario. well it's matter of allowing/denying access user. if can recognize users model in controllers beforefilter method, can allow/deny access accordingly $this->auth->allow() or $this->auth->deny() (in beforefilter method). maybe can put pseudo-role in session after login if don't wish have in db table. can put auths allow/deny in conditions on pseudo-role stored in session. or have misunderstood question? update i realized refering actual login. changing default model documented in cookbook . see usermodel configuration key. keep in mind supposed change in beforefilter m

vb.net - Refresh DataGridView after executing SQL Command? -

here code: cn.open() cmd.commandtext = "insert student values('" ...... cmd.executenonquery() cn.close() after closing connection want datagridview refresh it's data's also. new in vb.net tried datagridview.refresh() it's not working think it's repainting not updating it's data's. thanks. if update underlying business object, ui should update automatically. guess forgot data binding, example datagridview.datasource = yourdatatable . edit: easiest way right replace this: cmd.executenonquery() with this : dim dt new datatable dt.load(cmd.executereader()) and then: datagridview.datasource = dt if need database updates, may want use dataadapter , update method. overload linked datatable, i.e. don't need dataset, unless have already.

mysql - PHP Explode Array Issue -

i start off saying new @ php. following code written acquaintance no longer able assist , trying further develop additional things it. running issue cannot wrap head around. the explode array used break series of commands parts used within mysql statements manipulate database. the issue having commands seem work , don't. see below: if(isset ($_post['commandline'])){ //handle cammand $command = $_post['commandline']; $parts = explode(",",$command); //print_r($parts); //we know first part command //update nature code event number works //part 1 event id part 2 new call type else if(preg_match("/ute/",$parts[0])){ mysql_query("update runs set calltype='{$parts[2]}' id='{$parts[1]}'");} //update location event number works //part 1 event id part 2 new location else if(preg_match("/ule/",$parts[0])){ mysql_query("update runs set location='{$parts[2]}' id='{$parts[1]}'&qu

node.js - How to include other NPM modules when publishing to NPM? -

i trying publish first module npm, renders markdown ejs templating, uses 2 other npm modules marked , ejs, have these dependencies in package.json file. have .gitignore file contains node_modules directory, , .npmignore file empty. i have published npm. however when try install module putting package.json of test app , doing npm install -d installs, not install dependencies, if go test app root node_modules directory , newly published module's installed directory, has not installed of dependencies, has not have nested node_modules directory of own. there should way module's dependencies install correct, when include express dependency, installs own node_modules folder connect , other modules installed, want same 2 other npm modules. i know work if install nested node_modules dependencies, when works. $ npm install -d $ cd node_modules/my_module $ npm install -d $ cd ../.. $ node app edit: here link github repo module, , here package.json . edit: no

Upload a picture with a php function -

it's first time i'm trying create function , can't figure out... i'm trying build function upload picture , return path, echo doesn't display andi don't have syntaxe error tho... don't understand? i hope may see more clearer me. function.inc.php: function upload_photo( $photo_input_name, $photo_path, $photo_type1, $photo_type2, $photo_max_weight, $photo_max_height, $photo_max_width) { if (isset($_files[$photo_input_name])) { //upload de fichier if(!empty($_files[$photo_input_name]['tmp_name'])) { //si n'est pas vide //spécification du chemin d'enregistrement $dossier = $photo_path; if (exif_imagetype($_files[$photo_input_name]['tmp_name']) != $photo_type1 , exif_imagetype($_files[$photo_input_name]['tmp_name']) != $photo_type2) { //si le format de l'image est différent de jpg ou png $erreur = 'oups, extension non reconnu. les

javascript - What happens with data received by the server using ajax? -

one.php : html: <button value="testvalue" name="foo">click</button> javascript: var keyvals = {foo:"bar"} $(function() { $("button").click(function() { $.ajax({ type:"post", url:"two.php", data: keyvals, success: function() { $("#center").append("<p>data transfer succeeded! </p>"); } }); }); }); now, happens data? how can use in two.php ? want save in file/database, why not save directly one.php ? i've tried following: two.php : <?php var_dump($_request); ?> comes out empty. happens data sent one.php ? how can use it? strangely enough, i've looked @ every similar question find, , none of them answered properly, , of them downvoted. what'

java - How do I check if a "name" value exists in a SQLLite Database? -

i have sqllite database of sites name field. have save , create buttons. want run addrecord() or updaterecord() depending on whether or not value in name field exists. i have method in dbadapter: public cursor getrow(long rowid) { string = key_rowid + "=" + rowid; cursor c = db.query(true, database_table, all_keys, where, null, null, null, null, null); if (c != null) { c.movetofirst(); } return c; } how can create similar method rowid based on name string supplied? ie public cursor getrowid(string _name) { ... } search name instead of id in clause. public cursor getrowid(string _name) { string = "name = '" + _name + "'"; cursor c = db.query(true, database_table, all_keys, where, null, null, null, null, null); if (c != null) { c.movetofirst(); } return c; } get rowid cursor this: cursor c = getrowid

javascript is adding assets folder to image path (rails 3) -

i have js code looks smth this: ... html_string = '<img src="urlgoeshere" >' url = "http://www.remote_site.com/address/to/my_pic.png" html_string.replace(new regexp("urlgoeshere", 'g'), url) $('body').append html_string ... so.. should make this, right? <img src="http://www.remote_site.com/address/to/my_pic.png" > instead this: <img src="/assets/http://www.remote_site.com/address/to/my_pic.png" > can't image_tag . how rid of /assets/ part? yes think so. add image_tag javascript code embedded in erb template making me crazy. use raw html tag ok.

javascript - id manipulation in jQuery -

say have unordered list of item1 , item2 , item3 , item4 , each div around it. <ul> <div><li>item1</li></div> <div class="current"><li>item2</li></div> <div><li>item3</li></div> <div><li>item4</li></div> </ul> i want every time click itemx, loads itemx.html , give div around itemx current class attribute. i'm writing 4 functions separately 4 items, , same. how can write general function works on itemx, loads itemx.html , changes div's attribute? current code seems redundant. assuming you've fixed html problem(li should sub element of ul). still such problem, need do: $("li").click(function() { $(".current").removeclass("current"); $(this).parent().addclass("current"); }); but correct solution : html : <ul> <li>item1</li> <li class="current">

mysql - CodeIgniter - SQL Query AND clause with table columns -

i'm new codeigniter , i'm struggling active record class , apostrophes adds query: this query codeigniter outputs (via enable_profiler): select `login`.`idlogin`, `login`.`username`, `login`.`password` (`login`, `pessoa`) `login`.`username` = 'user1' , `login`.`password` = 'pass1' , `pessoa`.`nbi` = 'login.pessoa_nbi' limit 1 user1 , pass1 strings login form (ignore password in plain cleartext). produces 0 results. however correct query, i.e., result want is: select `login`.`idlogin` , `login`.`username` , `login`.`password` (`login` , `pessoa`) `login`.`username` = 'user1' , `login`.`password` = 'pass1' , `pessoa`.`nbi` = login.pessoa_nbi limit 1 only difference penultimate line, login.pessoa_nbi isn't surrounded apostrophe. which produces out 1 result, should. database mysql. edit: here active record code: $this -> db -> select('login.idlogin, login.username, login.password'); $this -&

javascript - Form Input: Get Unique Value With Same Name & ID -

below result query posted address page. accomplished using php called ajax. <div id="address-wrap"> <div id="report-address">3719 cocoplum cir <br> unit: 3548<br> coconut creek, fl 33063</div> <div id="report-button"> <form action="report.html"> <input name="property-id[]" type="text" class="property-id" value="64638716"> <input name="submit" type="submit" value="view report"> </form> </div> <div id="clear"></div> </div> <div id="address-wrap"> <div id="report-address">3927 cocoplum cir <br> unit: 35124<br> coconut creek, fl 33063</div> <div id="report-button"> <form action="report.html"> <input name="property-id[]" type="text" class="property-id" value="6463874

weird django error: cannot import name get_path_info -

i started getting error when try start django development server, , cannot figure out coming from. have tried updating django. file "/virtualenv/lib/python2.7/site-packages/django/contrib/staticfiles/management/commands/runserver.py", line 6, in <module> django.contrib.staticfiles.handlers import staticfileshandler file "/virtualenv/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 9, in <module> django.core.handlers.base import get_path_info importerror: cannot import name get_path_info has seen error before? trying best figure out... for me, problem dj_static 0.0.5 didn't seem playing nicely django 1.7 . upgraded dj_static 0.0.6 , fixed it.

regex - C# Check if filename ends with pattern -

with list of file names below: foo.pdf foo(1).pdf foo(2).pdf foo(321).pdf how can check if file name ends pattern (n).extension? , if does, how filename without (n) part? this seems work void main() { string test = "file(321).pdf"; string pattern = @"\([0-9]+\)\."; bool m = regex.ismatch(test, pattern); if(m == true) test = regex.replace(test, pattern, "."); console.writeline(test); }

objective c - Unrecognized Selector in AVplayer setNumberOfLoops Method -

when calling numberofloops method so: [_player setnumberofloops:-1]; i following error: -[avplayer setnumberofloops:]: unrecognized selector sent instance 0x7d52d30 how can fixed? code: header: #import <uikit/uikit.h> #import <avfoundation/avfoundation.h> @interface viewcontroller : uiviewcontroller { } @property (strong, nonatomic) avaudioplayer *player; - (ibaction)playmusic:(id)sender; @end implementation: #import "viewcontroller.h" #import <avfoundation/avfoundation.h> @interface viewcontroller () @end @implementation viewcontroller - (void)viewdidload { [super viewdidload]; // additional setup after loading view, typically nib. } - (void)didreceivememorywarning { [super didreceivememorywarning]; // dispose of resources can recreated. } - (ibaction)playmusic:(id)sender { _player = [avplayer playerwithurl:[nsurl urlwithstring:@"http://urlpath.wav"]]; [_player setnumberofloops:-1]; [_pla

json - extract tweets from a text file (python) -

sorry, trying store 'id_str' each tweet new list called ids[].. getting following error: traceback (most recent call last): file "extract_tweet.py", line 17, in print tweet['id_str'] keyerror: 'id_str' my code is: import json import sys if __name__ == '__main__': tweets = [] line in open (sys.argv[1]): try: tweets.append(json.loads(line)) except: pass ids = [] tweet in tweets: ids.append(tweet['id_str']) the json data tweets missing fields. try this, ids = [] tweet in tweets: if 'id_str' in tweet: ids.append(tweet['id_str']) or equivalently, ids = [tweet['id_str'] tweet in tweets if 'id_str' in tweet]

c++ - Why icon of an MFC ribbon galery button does not change? -

i trying create mfc ribbon galery button( similar mspaint brushes button ) using visual studio 2010 ribbon wizard. step1 created galery button, changed button mode true, set columns 4, icon width 32, set large icon it. step2 added icons galery button. everything looks fine except when select icon drop down menu of galery button, main icon of galery button stays same. how can change galery button icon selected icon ?

uiimage - iOS can write or read from image data from disk -

i'm trying load images using following method. i first check if have images on disk, if image data disk , load otherwise image server , write disk second time need image won't have access server. the problem doesn't seem write or read disk. everytime want load images second time it's still reads them server , nslog(@"disk"); never gets called. i don't know i'm doing wrong if has idea? -(uiimage *)imagewith:(nsstring *)imagename ispreview:(bool)preview { //imagename "56.jpg" nsstring *mainorpreview = @"preview"; if (!preview) { mainorpreview = @"main"; } nsstring *pathsuffix = [[@"images" stringbyappendingpathcomponent:mainorpreview] stringbyappendingpathcomponent:imagename]; nsstring *path = [[nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes) objectatindex:0] stringbyappendingpathcomponent:pathsuffix]; nsdata *imagedata = [ns

asp.net - iTextSharp - MVC / HTMLWorker one string to add to a paragraph -

i sending contents of telerik mvc editor controller using ajax string: comes out as: "<strong>hello world!</strong> <object height=\"1\" id=\"plugin0\" style=\"position:absolute;z-index:1000;\" type=\"application/x-dgnria\" width=\"1\"><param name=\"tabid\" value=\"{84594b7b-865f-4ad7-a798-294a8b0eb376}\" /></object>" in controller, save string session variable using following: string comments = httputility.htmldecode(text); mysession.current.pdftext = comments; i can convert pdf using ..... htmlworker parser = new htmlworker(document); ....... however not add other paragraphes same page, makes new page. i tried use following make new paragraph using htmlwork: string pdftext = mysession.current.pdftext; string pdftext1 = htmlworker.parse(pdftext); stringreader reader = new stringreader(pdftext1); paragraph.add(reader); i go

android - Whenever I try to rotate imageview, it only rotates on axis -

so have been attempting create program can drag, zoom , rotate photo. big problem seem running whenever try rotate photo, rotates along corner, rather around center. means try rotate image, leaves fingers. another big problem have every time touch 2 fingers, image resets being upright, instead of angle held when touched it. @override protected void ondraw(canvas canvas) { canvas.save(); //if(mode==drag) canvas.translate(mposx, mposy); if (myscale.isinprogress()) { canvas.scale(mscalefactor, mscalefactor, myscale.getfocusx(), myscale.getfocusy()); } else{ canvas.scale(mscalefactor, mscalefactor, mlastgesturex, mlastgesturey); } if (myscale.isinprogress()) { canvas.rotate(degrees, myscale.getfocusx(), myscale.getfocusy()); } else{ canvas.rotate(degrees, mlastgesturex, mlastgesturey); } //canvas.setmatrix(matrix); //setimagematrix(matrix); super.ondraw(canvas); canvas.restore(); //ca

javascript - See if text input is there -

so i'm trying check if user has inputed text through textbox userinput. however, when try writing if else statement validate input, nothing seems work. help? <div class="container"> <div class="row"> <div class="page-header"> <h1 align="center">sub me <small>easily create youtube subscription links!</small></h1> </div> </div> <script type="text/javascript"> function showlink() { $("#linkbox").css("visibility", "visible"); $("#linktext").html("http://subto.me/"+$("#usernameinput").val()) $("#linkhref").attr("href", "http://subto.me/"+$("#usernameinput").val()) } </script> <div class="row"> <div class="span6 offset3"> <div class="form-inline">

If equivalent without using conditional operations and other loop methods java -

int function(int a, int b, int c){ if(a==c) return a; else return b; } question achieve same o/p without using if, while, do, for, switch,conditional expression(?:) , other general inbuilt methods equals please tell me logic , code.. here's approach using operators only: int function(int a, int b, int c) { //if == c: result = 0x00000000 //else: result = 0xffffffff int result = (a - c | c - a) >> 31; //if == c: result = 0x00000000 & (a ^ b) = 0 //else: result = 0xffffffff & (a ^ b) = ^ b result &= ^ b; //if == c: result = 0 ^ = //else: result = (a ^ b) ^ = b result ^= a; return result; }

Android - Why use pending intents for geofences -

i finished tutorial geofencing on android ( http://developer.android.com/training/location/geofencing.html ) , wonder why 'callback' geofences done via pending intents , not simple callback interface. if implemented in activity, 1 disconnect location client in onpause() anyway, added geofences not tracked either after application paused/was destroyed, why pending intent? or mistaken here? i wonder why 'callback' geofences done via pending intents , not simple callback interface. mostly because geofences designed work without application running. if implemented in activity, 1 disconnect location client in onpause() anyway, added geofences not tracked either after application paused/was destroyed, why pending intent? or mistaken here? i believe mistaken here. in fact, geofences not designed directly triggering ui, discussed in the documentation : the intent sent location services can trigger various actions in app, should not have start

android - How to turn wifi on using ADB or any other way when usb debugging is disabled -

when android locked after many pattern attempts, ask sign in google account unlock, have username , password mobile data , wireless not enabled , can't enable because it's totally locked, don't want make factory reset because lose data. as programmer have wasted 2 days searching on how , have found answer using adb turn on wifi : adb shell sqlite3 /data/data/com.android.providers.settings/databases/settings.db update secure set value=1 name='wifi_on'; .exit however,it not work if usb debugging disabled, there other solution enable usb debugging on using adb or wifi or mobile data on? please don't close questions because questions on stack overflow expected relate programming or software development, because question related software development, @ lease please android experts, answer me , answer thousands of people losing data everyday, because android not turning wireless on default if it's locked or gives @ least opportunity log in , unlock sto

c++ - error LNK2019: unresolved symbol "char_cdecl st(void) -

okay, i've looked around , still not quite understand why getting error. code included below. had older code working fine. decided make perform more 1 calculation per opening of application. after fixing several other errors, 1 popped up. 1 had popped after realized needed ' ' around y. #include "stdafx.h" #include <cstdio> #include <cstdlib> #include <iostream> using namespace std; int main(int nnumberofargs, char* pszargs[]) { int x; int y; int result; char z; char = 'y'; char st(); { cout << ("do calculation?: y/n"); cin >> a; if (a = 'n') { system("pause"); return 0; } } while (a = 'y'); { cout << "symbol here: " <<endl; cin >> z; cout << "number 1: " <<endl; cin >> y; cout <&

android - Is there a workaround for when HttpURLConnection.getResponseCode throws NullPointerException? -

i'm getting lot of errors caused error explained here . happens on android 2.3 or below, when call getresponsecode of httpurlconnection, weird happens randomly (one of causes when use underscores on url, have seen work these on url). i know first recommendation use apache library, found i.e. facebook sdk android uses too, , breaks frequently. debugged this, on facebook it's breaking on line 301 of class com.facebook.response: if (connection.getresponsecode() >= 400) { //a nullpointerexceptions thrown here. what recommendation here? don't think feasible approach migrate facebook part use apache library, or if can't avoided , ignore error , let user retry, bad, not sure how other apps resolve this. thanks time. are sure connection isn't null? you can catch nullpointerexception , treat entire attempt download failure , retry/giveup.

visual studio 2010 - Adjacency list implementation in C++ -

i looking concise , precise adjacency list representation of graph in c++. nodes node ids. here how did it. want know experts think it. there better way? this class implementation (nothing fancy, right don't care public/private methods) #include <iostream> #include <vector> #include <fstream> #include <sstream> using namespace std; class adjlist { public: int head; vector<int> listofnodes; void print(); }; void adjlist :: print() { (int i=0; i<listofnodes.size(); ++i) { cout << head << "-->" << listofnodes.at(i) << endl; } } class graph { public: vector<adjlist> list; void print(); }; void graph :: print() { (int i=0; i<list.size(); ++i) { list.at(i).print(); cout << endl; } } my main function parses input file line line. each line interpreted following: <source_node> <node1_connected_to_source_node> <node2_

How can I select multiple columns from a Django model? -

at moment have query selects distinct values model: meeting.objects.values('club').distinct() in addition 'club' field, wish select 'time' field. in other words wish select distinct values of 'club' field , associated 'time' field. example for: club,time abc1,10:35 abc2,10:45 abc2,10:51 abc3,11:42 i want: abc1,10:35 abc2,10:45 abc3,11:42 what syntax this? this possible, if database backend postgresql . here how can done: meeting.objects.order_by('club', 'time').values('club', 'time').distinct('club') look documentation distinct

javascript - Calling same function in multiple object's context? -

i have object structure so; { this.parent = undefined; this.children = []; } all values in children have same structure above except parent would reference object has child. how can iterate on children of children etc in child's object context? i know how can loop children 1 object obj.children.foreach(function(child) { }); but how can iterate children of children, when children 10-20-30 deep heirachy? use recursion . function deepforeach(node, fn) { fn(node); node.children.foreach(function(child) { deepforeach(child, fn); }); } deepforeach(obj, function(obj) { console.log(obj); }); the way works becomes evident if state in plain english: if there no children, call callback node. (base case) if there children, first deal ourself, , whole procedure each child. this type of recursion called preorder traversal .