Posts

Showing posts from July, 2012

php - Declaring a variable outside a function in CodeIgniter -

i'm new codeigniter. i'm trying output view again after clicking submit view has variable controller, when tried it, doesn't work. <?php class site extends ci_controller{ public $data1['value'] = "what insert"; public function index(){ $this->load->view('home',$this->data1); } public function get_product(){ $data = array( 'product_name' => $this->input->post('prod_name') ); $this->site_model->insert_product($data); $this->load->view('home',$this->data1); } } ?> here's view: <div id="container"> <h1><?php echo $data1;?></h1> <?php echo form_open('site/get_product'); ?> <p> <label for="product">product name </label> <input type="text" id=&q

django - OneToOneField QuerySet returning empty dict -

i have 2 models called manufacturer , car . car model has foreignkey manufacturer mean many cars can belong single manufacturer. in model manfacturer , onetoonefield called showcase allows manufacturer have single car showcase, how can show manufacturers have car showcase mean , show manufacturer onetoonefield objects. i tried manufacturer.objects.filter(showcase=true) return empty dictionary [] class manufacturer(models.model): user = models.foreignkey(user) name = models.charfield(max_length=55) showcase = models.onetoonefield('car',related_name='car',blank=true) class car(models.model): user = models.foreignkey(user) manufacturer = models.foreignkey(manufacturer,blank=false,related_name='manufacturer') try manufacturer.objects.exclude(showcase=none) also, in model try add null=true next to blank=true in showcase attribute of model.

apache - index.php appending to url -

i have magento site has index.php appended url click on. googled lot find solution , did find.to clear my doubts uploaded htaccess file fresh copy magento copy , made url rewrite in configuation>system>web yes , clear cache still put index.php in url.i have double checked secure , unsecure link see if contain index.php doesn't can can research , applied no change. can or can wrong? the steps describe should right: system > configuration > web > use web server rewrites set yes (also check store view level value, because scope not global) .htaccess present in document root clear magento cache additional things check: system > configuration > web > (un)secure base url does apache take consideration .htaccess (allowoverride) how did clear cache the scope settings system > configuration > web > use web server rewrites

ruby on rails - Select2 nested json parsing not working Rails3 -

i'm trying make select2 working ajax loaded json data nested attributes. wanna http://ivaynberg.github.io/select2/#multi . eaxmple json: [{ id: 1, name: "groupname", users: [{id: 1, name: 'username'}, {id: 2, name: 'seconduser}] }] on site use <optgroup label="groupname"><option value="1">username</opyion></optgroup> , getting right result. in case displays nesting properly, can select groupname , need select nested username , make grouoname unselectable, gor informational purposes. code: $('#user_tokens').select2({ placeholder: "search user", minimuminputlength: 0, tags: true, multiple: true, ajax: { url: "messages/users_data.json", datatype: 'json', quietmillis: 100, data: function(search, page) { return { q: search, per: 3, page: page }; }, results: function(data, page) { retur

html - CSS position: relative; children do not ignore each other -

i used float. recognized maybe not best way go. trying around position relative. why children of mydiv not ignore each others top ? because not inline-block ? <div class="mydiv"> <div class="mydiv1"></div> <div class="mydiv2"></div> <div class="mydiv3"></div> <div class="mydiv4"></div> </div> .mydiv { float: left; margin-left: 10px; margin-top: 10px; width: 100px; height: 100px; background-color: grey; } .mydiv1 { background-color: green; width: 10px; height: 10px; position: relative; top: 10px; left: 10px; } .mydiv2 { background-color: red; width: 10px; height: 10px; position: relative; top: 0px; left: 30px; } .mydiv3 { background-color: blue; width: 10px; height: 10px; position: relative; top: 0px; left: 50px; } .mydiv4 { background-color: yellow;

google play services - Android creating geofence -

i working on geofence api launched in google i/o 2013. creating , monitoring geofences there method in example given in above link follows: public void creategeofences() { ........ mgeofencelist.add(muigeofence1.togeofence()); mgeofencelist.add(muigeofence2.togeofence()); } this method inside onactivityresult of activity , in same activity have button save geofence , call mlocationclient.connect() -> it's same addgeofences() method of example. @override private void onconnected(bundle databundle) { ... switch (mrequesttype) { case add : // pendingintent request mtransitionpendingintent = gettransitionpendingintent(); // send request add current geofences mlocationclient.addgeofences( mgeofencelist, pendingintent, this); ... } } in method mgeofencelist empty should not since has been updated in onactivityresult method before. problem: v

iphone - Getting Seconds interval between NSDate, but get always zero seconds -

i want diff seconds between nsdate. used [nsdate timeintervalsincedate] methods, returns zero. below code. nslog(@"sent date : %@", message.sentdate); nslog(@"prev: %@", _previousshownsentdate); nslog(@"%d", [message.sentdate timeintervalsincedate:_previousshownsentdate]); in here, message.sentdate, _repviousshownsentdate nsdate object. but in logs, difference seconds zero. [1363:907] sent date : 2013-05-16 01:36:22 +0000 [1363:907] prev: 2013-05-16 01:36:17 +0000 [1363:907] 0 [1363:907] sent date : 2013-05-16 01:36:25 +0000 [1363:907] prev: 2013-05-16 01:36:17 +0000 [1363:907] 0 the third log line must 5 (01:36:22 , 01:36:17). zero. i don't understand mistake. because " %d " integer , value returned " timeintervalsincedate: " double (nstimeinterval). use " %4.2f " in third " nslog " line.

Call procedure inside trigger in mysql -

i want update counter table when user table modofied. i have created trigger cal procedure. procudeure not creating. please tell me error in procedure. create procedure barproc(in id int,in val int) begin declare @total_products int; set @total_products=(select count(*) user a=id , status='active') if(@total_products>0) update counter set b=val = id , status='active'; end if; try delimiter $$ create procedure barproc(in id int, in val int) begin if (select count(*) `user` = id , `status` = 'active') update counter set b = val = id , `status` = 'active'; end if; end$$ delimiter ;

ios6 - iOS, url schemes for app store both for specified developer's apps and for his concrete app to update in iOS 6? -

this question answered in ios 6 these solutions doesn't work. current solutions doesn't work too: https://itunes.apple.com/us/artist/developer_name/developer_id https://itunes.apple.com/us/app/app_name/app_id the problem in ios 6.0.1, no error ios 6.1 this works on end (xcode 5 - ios 7 - device !): for app itself: itms-apps://itunes.apple.com/app/idyour_app_id code snippet (you can copy& paste it): #define your_app_store_id 545174222 // change app id static nsstring *const ios7appstoreurlformat = @"itms-apps://itunes.apple.com/app/id%@"; [nsurl urlwithstring:[nsstring stringwithformat: ios7appstoreurlformat, your_app_store_id]]; // contain right link for developer can use this: https://itunes.apple.com/artist/idyour_artist_id you can your_artist_id itunes connect or link on 1 of apps (there "view more developer" , copy number after "id" on link itself).

php - I have my Dynamic Page, how to add active class on current pages? -

i have 4 php pages, homepage.inc.php, about.inc.php, contact.inc.php , heres index.php <div id="menu"> <nav> <a id="home" target="_self" href="index.php">home</a> <a id="about" target="_self" href="index.php?p=about">about us</a> <a id="contact" target="_self" href="index.php?p=contact">contact</a> </nav> </div> <div id="content"> <?php $pages_dir = 'pages'; if (!empty($_get['p'])) { $pages = scandir($pages_dir, 0); unset($pages[0], $pages[1]); $p=$_get['p']; if(in_array($p.'.inc.php', $pages)){ include($pages_dir.'/'.$p.'.inc.php'); }else { echo 'sorry, page not found.'; } }else{ include($pages_dir.'/home.inc.php'

Cannot create a .Net object in PowerShell -

i beginner in powershell scripting. have tried create .net object executing following command fails : [system.collections.generic.list<system.string>]$mylist = new-object system.collections.generic.list<system.string> an error message informs me type [system.collections.generic.list] has not been found. error message informs me should check if assembly containing type loaded. i guess have load assembly containing type [system.collections.generic.list] not know how it. i want know .net framework version can use types in powershell. any appreciated wrong syntax. types , type parameters delimited square brackets, not angled ones. $mylist = new-object 'system.collections.generic.list[system.string]'

apache - Can I have two separate web servers/application servers accessing the same database, mysql -

i have apache tomcat application server , wamp(apache) installed in machine(localhost). php application runs on wamp, , webservices(soap) based on java, need make changes mysql database. possible both wamp/apache(port 80) , java services/tomcat(port 8888) access same mysql database.. sure! can have multiple programs access database, same database , @ same time. fundamentally @ database level, doesn't care incoming connections from, can have many , (up resource limits configured or capability of server keep up). great thing databases.

jquery - right position and scroll bar in Firefox -

if animate div position right makes strange movement. happens in firefox, if have div positioned right, , if there scroll bar. why happen , how can solve it? only firefox right position with scrollbar here example simplified check: http://jsfiddle.net/lhaeh/1/ html: <div id="blue"></div> <div id="red"></div> css: #red { position: fixed; bottom: 20px; right: 25px; width:80px; height:50px; cursor:pointer; background:red; } #blue {/*this div create scroll*/ margin:0 auto; width:80px; height:500px; background:blue; } jquery: $(function(){ $("#red").click(function() { $("#red").animate({bottom:'-80px'},1000); }); }) try position: absolute; . additional explanation: assume jquery's animate() changes position absolute before starting animation, causes firefox move object bit, instead of leaving was.

Scheduled Executor in Scala -

in java can use scheduled executor schedule tasks run after given delay. can use in scala wonder if there scala api that. is there scala api (as opposed scheduled executor in java) schedule tasks? akka has similar schedulers: http://doc.akka.io/api/akka/2.1.4/#akka.actor.scheduler you can obtain 1 actor system: val actorsystem = actorsystem() val scheduler = actorsystem.scheduler val task = new runnable { def run() { log.info("hello") } } implicit val executor = actorsystem.dispatcher scheduler.schedule( initialdelay = duration(5, timeunit.seconds), interval = duration(10, timeunit.seconds), runnable = task) if using akka or based on it, play, way go.

django - Authenticate user using email and password -

i have form allow users login via username . decided allow user login via email instead of username. first, not duplication of question relating logging via email because in scenario, validate , authenticate user in forms.py before proceed final login in views give me chance raise error incorrect login passwords etc. the issue i'm facing modified forms.py raise error if email doesn't exist works wouldn't let user login via email. def loginrequest(request): form = loginform(request.post or none) if request.post , form.is_valid(): user = form.login(request) if user: login(request, user) return httpresponseredirect(reverse('hello')) return render(request, 'login.html',{'form': form}) this original code allow users login via username class loginform(forms.form): username = forms.charfield() password = forms.charfield( widget=forms.passwordinput(render_valu

Retrieving CLOB objects from JDBC ResultSet taking lot time -

we have standalone application connecting using jdbc oracle datatbase. retrieving values past 1 month, resultset may vary 25,000 100,000 records per month. when iterating resultset, retrieving 3 string(varchar) columns , 3 clob columns. when resultset 25,000 records, iterating resultset taking around 6 hours of time. when comment clob objects retrieval time taken few minutes, 25,000 records. tried both ways of retrieving clob objects using java.sql.clob , oracle.sql.clob, both take same amount of time. ways of enhancing performance, please suggest. java version : 1.6 oracle :10g ojdbc14.jar

collections - Java/ Remove a Integer value from a list -

this question has answer here: properly removing integer list<integer> 9 answers i have following lists of integer whattoremove = {2, 3, 8}; and list lst = {4, 6, 8} i want remove whattoremove elements lst . i trying use lst.remove(whattoremove.get(i)) , trying remove index, , not value. how can that? list<integer> whattoremove = arrays.aslist(2, 3, 8); list<integer> lst = new arraylist<integer>(arrays.aslist(4, 6, 8)); lst.removeall(whattoremove);

Replace JavaScript's function keyword -

is possible replace function keyword smaller void , sub etc ? i've seen being used in libraries these two: sweet.js processing.js you can use "typescript" these things. typed superset of javascript compiles plain javascript. javascript lots of new features. created microsoft. typescript official webpage

Android Runnable not working on android 2.3? -

i have following code: btn.setontouchlistener(new ontouchlistener() { @override public boolean ontouch(view v, motionevent event) { if (event.getaction() == motionevent.action_down) { v.post(pressed); // put runnable 'pressed' in // asynchrone message queue } return false; } }); private runnable pressed = new runnable() { @override public void run() { if (btn.ispressed()) { sky.draweverything(); btn.postdelayed(pressed, 10); } } }; this works charm android 4.1.2, if try on android 2.3 runnable seems stay untriggered. i'm using api 1 or above, why doesn't work? what alternative way of archieving same result , making work on older android versions? he not sure :) code works on 4+ , in 2.3.6 tested having issues line if(btn.is

MySQL Hierarchical Structure -

every single user has say, 3 of group_a, 10 group_b's per group_a, , 20 group_c's per group_b. , each of 20 group_c's involve lots of inserts/deletes...and every piece of data unique 1 groups/users. i'm not expert, i've done research it's theoretical @ point of course, , don't have hands on experience implementation that's sure. think options 'adjacency lists' or 'nested sets'? any guidance right direction appreciated! (i posted on dba stackexchange i'd appreciate if more opinions , community!) i know trivial solution have simple tables foreign keys parent 'container' i'm thinking in long term, in event there's million users or so. i know trivial solution have simple tables foreign keys parent 'container' i'm thinking in long term, in event there's million users or so. i go approach. long number of hierarchy levels remains fixed, resulting scheme scale because trivial. fancy

javascript - Change Page Title After a Certain Time -

i trying dynamically change title of page after 2 seconds (2000 ms). here code have tried: <!doctype html> <html> <head> <title>before</title> </head> <body onload="updatetitle"> <script> var title = document.getelementsbytagname('title'); function updatetitle() { //here kind of delay (of 2 seconds). have tried settimeout(), setinterval() , delay() title.innerhtml = "after"; </script> dummy content body </body> </html> how might modified after 2 seconds, page title changes? for changing title, should rather using window.title window.title = 'after'; in case, absolutely must use document.getelementsbytagname , note returns array of elements, first of need make use of. i.e. document.getelementsbytagname('title')[0].innerhtml = 'after'; of course, if page not have <title> element, above result in error. first 1 ( window.alert ) work in ei

java - What's the difference between the following two ways to create an executable JAR? -

i reading on how-to create jar file in java , way : jar cmf mainclass.txt example.jar *.class i curious why use *.class rather saying example.class ? have directory many class files, how know 1 use? here how directory looks. thanks! edit: lot created new directory , saved 50% bytes! * wildcard shell , expands match files end .class in current directory. if don't want ... instead list specific .class files want add. typically use *.class because .class files in directory make project, , of them needed in .jar .

Shellcode in C program -

the link http://hackoftheday.securitytube.net/2013/04/demystifying-execve-shellcode-stack.html highlights way write execve shellcode. #include<stdio.h> #include<string.h> unsigned char code[] = "\x31\xc0\x50\x68\x6e\x2f\x73\x68\x68\x2f\x2f\x62\x69\x89\xe3\x50\x89\xe2\x53\x89\xe1\xb0\x0b\xcd\x80"; main() { printf("shellcode length: %d\n", strlen(code)); int (*ret)() = (int(*)())code; ret(); } what line int (*ret)() = (int(*)())code; do? int (*ret)() = (int(*)())code; ~~~~~~~~~~~~ ~~~~~~~~~~~~~~ 1 2 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3 it defines ret pointer function has no parameter () , returns int . so, () indicates definition of parameters of function. it's casting code pointer function has no parameter () , returns int . casts code function , assigns ret . after can call ret(); .   unsigned char code[] = "\x31\xc0\x50\x68\x6e\x2f\... it sequence of

try catch - Paypal Error "return to your homepage and restart your activity. Try again in 30 min -

i wish can me. have used paypal classic api connect paypal gateway. working before on sandbox environment. connected live paypal test connection (no transaction) , start following error on both (sandbox, , live). please meeeeeeeeeeeeeeeee :(::: error below: "if making purchase or sending money, recommend check both paypal account , email transaction confirmation after 30 minutes. if came page website, please return site (don't use browser's button) , restart activity. if came paypal's website, click paypal logo in upper-left corner return our home page , restart activity. might have log in again. dispatch error, please check logfile more information" ============================================================ end of error many dears, ray

my PHP code will NOT insert records into my SQL dabase table -

i have following php code/file on website ungodly reason not insert records typed in user mysql database table required to. can tell me why is? so far can tell code correct don't know why happening... please help...code below... <html> <head> </head> <body> <form action="register_development_file_1.php" method="post"> email: <input type="text" name="email"><br /> date: <input type="text" name="date"><br /> time: <input type="text" name="time"><br /> <input type="submit" name="submit"> </form> <?php if (isset($_post['submit'])) { $con = mysql_connect("localhost","username","password"); if (!$con) { die("could not connect database: " . mysql_error()); } mysq

c++ - QT Creator - Unable to build HTML5 application -

i installed qt creator 2.7.0 [based on qt 5.0.1 (64 bit)] on ubuntu 13.04 end. tried creating sample html5 application , when try run it, issues encountered. here's output of build process. 23:16:22: starting: "/usr/bin/qmake" /home/res/git/test/first/first.pro -r -spec linux-g++-64 config+=debug config+=declarative_debug config+=qml_debug 23:16:22: process "/usr/bin/qmake" exited normally. 23:16:22: starting: "/usr/bin/make" make: circular <- first dependency dropped. copying application data... g++ -m64 -o first main.o html5applicationviewer.o moc_html5applicationviewer.o -l/usr/x11r6/lib64 -lqt5webkitwidgets -lx11 -lxslt -lrt -lgio-2.0 -lgstapp-0.10 -lgstinterfaces-0.10 -lgstpbutils-0.10 -pthread -lgstvideo-0.10 -lgstbase-0.10 -lgstreamer-0.10 -lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lxml2 -lglib-2.0 -lsqlite3 -l/build/buildd/qtdeclarative-opensource-src-5.0.1/lib -l/usr/lib/x86_64-linux-gnu -l/usr/lib/x86_64-linux-gnu/x86_64-linux-gnu

windows 7 - difference between process explorer and task manager -

Image
below screen capture of process explorer(left) , task manager(right) in windows 7. process list in task manager sorted pid. can see processes(csrss.exe, wininit.exe, services.exe...) missing in task manager window. can explain why? thank in advance. by default, windows 7 's task manager shows processes running under logged on user. click on show processes users button below see system processes well.

c - Closing stdin stdout and stderr the ptunnel way -

i intrigued way ptunnel closes stdin, stdout , stderr: if (daemonize) { ... freopen("/dev/null", "r", stdin); freopen("/dev/null", "w", stdout); freopen("/dev/null", "w", stderr); } is way close them? confused because freopen open file descriptor, not closed in case. no. it's not entirely safe. it assumes freopen() reuses same file descriptors not guaranteed. if freopen() uses different file descriptor, example, stdout other 1 subsequent write() 's using file descriptor not work expected. because posix read/write functions use *_fileno defined as: /* standard file descriptors. */ #define stdin_fileno 0 /* standard input. */ #define stdout_fileno 1 /* standard output. */ #define stderr_fileno 2 /* standard error output. */ for respective io operations. instead do: #include<unistd.h> fd = open("/dev/null",o_rdwr); dup2(fd,0);

java - Cannot print out result -

i try print out text: aloha prints nothing out while if delete loop right above text, prints. can explain me? in case, if want keep loop (for(s=5; s<0;--s)), how can make work? thanks import java.io.*; public class email13 { static boolean isvalidemailcharacter(char c){ boolean result = false; if((c>='a'&&c<='z')||(c>='a'&&c<='z')||(c>='0'&&c<='9')||(c=='.')||(c=='-')||(c=='+')) result = true; return result; } public static void main(string[] args) throws exception{ bufferedreader cin, fin; cin = new bufferedreader(new inputstreamreader(system.in)); //description system.out.println("programmer: minh nguyen"); system.out.println("description: program start final project."); system.out.println(); string namein, nameout, dein, deout;

scala - Syntax highlighting for *.sbt files in IntelliJ IDEA -

i'm working on potential module lift web framework using scala, sbt 0.12, , intellij idea 12.1, , have syntax highlighting *.sbt files in idea (code awareness bonus). i have sbt-idea plugin sbt builds idea project. have sbt plugin idea, allows me run sbt commands run configurations in idea. when associate *.sbt files scala file type, idea shows kinds of errors in sbt script. is working on *.sbt file type syntax highlighting or code awareness? if so, how use it? thanks! scala plugin intellij idea 13 comes highlighting .sbt files. see built-in sbt support in intellij idea 13 : today happy announce built-in support sbt projects here. newest version of scala plugin intellij idea 13 (0.23.308) comes following list of features: import sbt project auto-import sbt projects highlighting .sbt files

How to determine multipart/form-data filetypes using Ruby? -

i'm using griddler gem in rails 3.2 app handle incoming emails attachments. the documentation indicates attached files multipart/form-data files. is there easy ruby way interrogate these files , determine filetype? need handle different filetypes using different methods. according rails guide under section 5 'uploading files' the object in params hash instance of subclass of io. depending on size of uploaded file may in fact stringio or instance of file backed temporary file. in both cases object have original_filename attribute containing name file had on user’s computer , content_type attribute containing mime type of uploaded file. so interrogate uploaded_io.content_type , use different methods work whatever content_type is. hope gets started in right direction

linux - Bubble Sort Time C program -

the test create array of size 10000. initialize values 10000 down 1 , use bubble sort reverse order.as bubble sort 1 of worst possible sorts, should take long time. however, resolution of timing limited. the solution put task inside loop repeats thousand or million times—whatever takes numbers can deal with. getting errors in code. please see code below. the following commands run on linux: gcc -o sort sort.c -o2 time ./sort gcc -m32 -o sort sort.c -o2 -march=pentium4 time ./sort #include <stdio.h> void bubblesort(int numbers[], int array_size) { int i, j, temp; (i =0; <array_size; i++) { (j =0; j<array_size-1; j++) { if (numbers[j] > numbers[j+1]) { temp = numbers[j]; numbers[j] = numbers[j+1]; numbers[j+1] = temp; } } } } int main(void) { int array[10000]; int i; for(i=10000;i!=0;i--) { array[i-1]=i; } bubb

javascript - Insert data into one page app for initial load? -

i'm serving 1 page app. app needs request initial data server once it's loaded. is there anyway dynamically serve data initial asset load of css/html/javascript, without rendering in html? sending js object data don't need ping server? inserting script tag? adding dynamically created js file asset load? a little bit lost, appreciated. in opinion, best way serve dynamic content node.js server client use socket.io . if don't wanna use socket.io, can try create dynamic page acts different on node.js server, , use xmlhttprequests receive data.

PHP PDO transaction automatic rollBack -

i refining code on 1 of applications converted using php adodb library pdo lately. in adodb once launched transaction automatically rolled if exception should arise queries between begin , commit commands. does pdo this. if method has query it fails between begin , commit in pdo trsaction automatically rollback or need implicitly called? you have call rollback (and commit) yourself, pdo won't you. this: $pdo = new \pdo(/* ... */); $pdo->begintransaction(); try { // stuff.. } catch(\exception $e) { $pdo->rollback(); throw $e; } $pdo->commit();

java - Matching of images according to two points -

Image
i have pattern image set of points , second tested image set of points. know coordinates x,y of points. points have names (numbers), know numbers of points in pattern image , in tested sample know numbers of 2 points. want rotate tested image according these 2 known points fit tested image on pattern image (i don´t want scale it). want calculate distances of pattern points tested points. want write algorithm in java, idea how that? hava @ java.awt.geom.affinetransform, you'll find tutorials that, too. seems want map blue 0 onto red 0, i'd start translating both groups such 0 in origin of coordinate system. see affinetransform.gettranslateinstance. next i'd inspect vectors points 1 in blue , red group. can find angle respect x axis (arctan(y/x)). difference of 2 angles angle want rotate blue group points 1 point same direction. see affinetransform.getrotateinstance. matching pairs of points seems difficult part...

angularjs - Angular: How To Introduce External Domain Objects Into A Controller? -

my application has number of domain model objects i've built , unit tested. there nothing angular-specific them, have no angular dependencies, , use them if had selected other framework besides angular. my question proper way use them within angular. need use them in controller. i'm including them before angular controller code, defined , can refer them. i'd know if there better way? should using angular's dependency injection system inject them? if so, how? thanks. you should stick them in service. can injected / mocked / tested / di-is-fun-ed easily. before: var superbigthing = { isawesome: true; }; after: myapp.factory('superbigthing', function() { var superbigthing = { isawesome: true }; return superbigthing; }); myapp.controller('thingctrl', function($scope, superbigthing) { });

api - Unable to cancel a Servicestack Facebook authentication proccess -

when accessing "/api/auth/facebook" i'm redirected facebook ouath dialog, when trying cancel, keep getting redirected same facebook ouath dialog. this means cannot cancel process. bug? i fixed issue little while back. https://github.com/servicestack/servicestack/pull/850

local storage - retrieving last key in javascript localstorage -

i doing uni assignment please excuse coplete lack of knowledge here. have been tasked creating web based app "client" requires me open invoice after have completed details, far have form working fine, can save localstorage without issue , can retrieve information in format want. the issue if have multiple "orders' can retrieve first string saved localstorage , cannot figure out how make display newest/last one. the key randomly generated number derived date had assume large quantity of orders. have attached code below if can appreciate it. cannot use jquery or json or that. have been told not able use these. cannot use server (php etc). thanks steve <script> var = 0; var itemkey = localstorage.key(i); var values = localstorage.getitem(itemkey); values = values.split(";"); var name = values[0]; var company = values[1]; var contactnumber = values[2]; var email = values[3]; var address1 = values[4]; var address2 = values[5]; var suburb = val

java - Android : How to synchronized resource in right way -

my application should read , write file. , work might happen in multithread, should synchronize resource. here code : // write file fileoutputstream fos = openfileoutput("data.dat", context.mode_private); synchronized (fos) { objectoutputstream writer = new objectoutputstream(fos); // continue write } // read file fileinputstream fis = openfileinput("data.dat"); synchronized (fis) { objectinputstream reader = new objectinputstream(fis); // continue read } does above code safe ? means "data.dat" can read or write, , in 1 thread ? if wrong, please correct me. thanks :) use file locking: http://en.wikipedia.org/wiki/file_locking tell other threads output file in use. if output file exclusively used app synchronized should prevent other threads doing portion of code @ same time. or, finally, can consider using intentservice queue requests , handle them 1 one

XML Reader and IDN urls in PHP -

i have idn url. if put xmlreader is, 2 warnings warning: xmlreader::open(http://www.джумла-тест.рф/master/article-category-blog?format=feed&type=rss): failed open stream: http request failed! in c:\program files (x86)\easyphp-12.1\www\joomla-cms2\libraries\joomla\feed\factory.php on line 44 warning: xmlreader::open(): unable open source data in c:\program files (x86)\easyphp-12.1\www\joomla-cms2\libraries\joomla\feed\factory.php on line 44 **error. feed not retrieved.** if urlencode one warning: xmlreader::open(): unable open source data in c:\program files (x86)\easyphp-12.1\www\joomla-cms2\libraries\joomla\feed\factory.php on line 44 **error. feed not retrieved.** if change punycode works, right way? update: want add think maybe problem earlier, in query not returning correct idn url. i'd still know if xmlreader in php can handle idn urls assuming can them database correctly. after discussion other developers, seems answer "yes need send request

Self compiling python script? -

so designing program want able recompile script inside program. possible? in addition want able recompile regardless if python installed on machine. insight or recommendations appreciated. for first part of question: save file called "hello_world.py" import os print "hello world" os.system("python hello_world.py") of course, python doesn't compile. for second part of question, use cx_freeze , py2app , py2exe , pyinstaller , etc.

playframework 2.1 - play framwork JsRoutes ajax form submit -

im trying submit form via jsroutes , ajax , dont think im getting controller .... this routes post /submit controllers.application.submit() and jsrouts function: $('#submit').click(function() { jsroutes.controllers.application.submit().ajax({ data : $("#contact-form").serialize(), url: '@{application.submit()}', success : function(data) { alert("succsses"); }, error : function(err) { alert("error"); } }); }); this im sendig server http://localhost:9000/?name=ajax&lastname=aaa&email=miko5054%40hotmail.com&phone=453534 what im doing wrong here ??? the @{application.submit()} code incorrect. should @{routes.application.submit()} . but if use javascript router jsroutes.controllers.application.submit() , don't need specify url inside ajax() call. can remove url:... line , should work fine.

perl - CGI-ExtDirect-2.02 can't call method "result" on an undefined value -

i working on converting interface of perl web application ext , intended use cgi-extdirect-2.02 library. i encountered problem though, which, after many hours of struggling, still remains unresolved. in simplest use case problem is: when adding following lines action method, example, demo/testaction/getgrid , error occurs in router.pm . same error appears both when executed under apache or using included library p5httpd.pl server. when remove while(<file>) loop, error goes away , else works fine. system configuration is: sunos 5.10, apache 2, perl 5.12.1. lines add: open(file, "</tmp/test.txt") or die("can't open file: $!"); while (<file>) { ; } close(file); error: 5571 17:58:08 server started on port 5000. 5571 17:58:08 5571 17:58:08 point browser @ http://localhost:5000 5571 17:58:11 <- localhost: /direct-grid.html http/1.1 5571 17:58:11 -> 200 ok /direct-grid.html: 803 bytes sent text/html 5571 17:58:11 <

ruby on rails - object existence not found in console but found when called in view? -

in application have user model has many relationship status_updates model. currently, database has 1 user , 0 status_updates saved. what bizarre when search status_updates or relationship between these objects in consol, affirms nil status_updates in database. statusupdate.count (0.2ms) select count(*) "status_updates" => 0 statusupdate.any? (0.1ms) select count(*) "status_updates" => false user.status_updates.count (0.2ms) select count(*) "status_updates" "status_updates"."user_id" = 1 => 0 user.status_updates.any? (0.2ms) select count(*) "status_updates" "status_updates"."user_id" = 1 => false so, that's clear me. but, when in application write following, status_update object returned! def end_date if self.status_updates.any? == false return self.status_updates.any? elsif self.status_updates.any? == true return self.status_updates.first en

http - save a webpage with VBS -

when use firefox " https://twitter.com/search?q=vbs ", works , see tweets (without ever logging on). but, when try use simplest vbs-scripting way xmlhttp, seems declared mobile user twitter , don't search results. so, how can change vbs code below make work? in principle, seems should able set objxmlhttp property spoof browser, again, microsoft wouldn't give me freedom easily. comments great! strfileurl = "https://twitter.com/search?q=vbs" strhdlocation = "c:\users\me\webpages\saved_tweets.html" set objxmlhttp = createobject("msxml2.xmlhttp") objxmlhttp.open "get", strfileurl, false objxmlhttp.send() if objxmlhttp.status = 200 set objadostream = createobject("adodb.stream") objadostream.open objadostream.type = 1 objadostream.write objxmlhttp.responsebody objadostream.position = 0 set objfso = createobject("scripting.filesystemobject") if objfso.fileexists(strhdlocation) objfso.deletef

Java. Checking the type of an Anonymous Implementation of an Interface -

i'm working wicket, building set decoupled components. while using event driven mechanism let components communicate, i'm keeping set in class "genericcomponent". basic idea send event, "someevent.class" payload extends igenericevent. in onevent method genericcomponent class, go through events added set. if class matches payload, event should executed. now code: genericcomponent public class genericcomponent<t> extends genericpanel<t> { //... protected set<igenericevent>eventset = new hashset<igenericevent>(); //... public void addevent(final igenericevent event) { boolean result = eventset.add(event); if (!result) { throw new illegalargumentexception("event added ..."); } } @override public void onevent(final ievent<?> event) { (igenericevent e : eventset) { if (e.getclass().equals(event.getpayload()))

How to store decimal in MySQL? -

i've tried using decimal (2,2) won't let me use this. i want store number, example 7.50 or 10.50. need keep both numbers after decimal though when refresh database resets values 0.99. suggestions? the first digit of decimal declaration total digits. want use decimal (4, 2) . allows 2 digits before decimal , 2 after. documentation: https://dev.mysql.com/doc/refman/5.7/en/precision-math-decimal-characteristics.html

android - error: Binary XML file line#3: You must supply a layout width attribute -

i'va read answers related these questions , i'm sure none solves problem, i'm getting crazy error, please appreciated <linearlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:padding="5dip" android:orientation="vertical" > <textview android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/title_scaned_value"/> <textview android:id="@+id/scanedformat" android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center" android:text="@string/title_scaned_value_empty"/> <textview android:id="@+id/scanedvalue" android:layout_width="match_parent"

image processing - Cropping out Extreme Distortion from a Homography -

i have picture of checkerboard taken arbitrary camera angle. find 2 vanishing points corresponding 2 sets of lines form checkerboard grid. these 2 vanishing points, compute homography checkerboard plane image plane. i apply inverse homography re-render checkerboard top view. however, images, re-rendered top view large. is, due camera angle, inverse homography stretches parts of image (i.e. regions of image close 1 of vanishing points) large. this takes unnecessarily large amount of memory, , of region becomes highly stretched stuff not need. so, when applying inverse homography, avoid rendering regions of image highly stretched. way this? (i coding in matlab) if need render checkerboard, without background, extract 4 corners of checkerboard , compute homography maps them 4 corners of square. then can obtain rectified image of checkerboard warping input image homography, paying attention render needed region (ie square on map checkerboard).

ruby - Stack Level Too Deep Error In Rails -

i'm getting error in rails , there's no other information me figure out why. systemstackerror in usercontroller#students stack level deep my user controller follows class usercontroller < applicationcontroller before_filter :authenticate_user!, :except => [:show, :students, :mentors] ... def students @users = student.where(:verify_code => 'verified') end end even when remove @users line error persists. edit: error seems happen every single route aside devise_for :users , to_root, means user controller. user model require 'json' require 'socket' class user < activerecord::base serialize :roles devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable validates :ign, :server, :roles, :presence => true validate :summoner_exists validate :valid_roles attr_accessible :email, :password, :password_confirmation, :remember_me, :ign, :server, :tier, :roles,

c++ - How sort unique on a std::vector of Eigen::Vector? -

the compiler can't figure out less operator type. i've tried lambda , predicate function. #include <eigen/dense> typedef eigen::vector3f vec3; inline bool operator<(const vec3 &lhs, const vec3 &rhs) { return lhs.x() < rhs.x() && lhs.y() < rhs.y() && lhs.z() < rhs.z(); } inline bool cmpvecs(const vec3 &lhs, const vec3 &rhs) { return lhs.x() < rhs.x() && lhs.y() < rhs.y() && lhs.z() < rhs.z(); } inline void removeduplicates(std::vector<vec3> &con) { std::sort(con.data(), con.data() + con.size()); auto itr = std::unique(con.begin(), con.end(), cmpvecs); con.resize(itr - con.begin()); } void init(std::vector<vec3> &verts) { removeduplicates(verts); } vs 2012 error: algorithm(3618): error c2678: binary '<' : no operator found takes left-hand operand of type 'eigen::matrix<_scalar,_rows,_cols>' (or there no acceptable co

c# - OnPropertyChanged method is not firing -

in wp8 app, have few controls bind foreground color changing in codebehind. onpropertychanged not firing when user event happened. i have defined binding "controlforeground" in textblock , radiobutton data template controls in it. trying change foreground color whenever user presses button. new color assignment not updating ui. missing here? in xaml, <textblock x:name="lbltilecolor" textwrapping="wrap" text="selected color:" foreground="{binding controlforeground, mode=twoway}"/> <textblock x:name="lbltilecolor2" textwrapping="wrap" text="app bg:" foreground="{binding controlforeground, mode=twoway}"/> <radiobutton x:name="accentcolor" ischecked="true" borderbrush="white" foreground="{binding controlforeground, mode=twoway}"> <radiobutton.contenttemplate> <datatemplate>

android - FragmentAdapter doesn't hold the good reference of the fragment -

i'm trying work fragment, i'm stuck issue can't solve. i have 1 activity, holds 4 different fragment. activity, launch asynctask goes web , different data need, , send fragments. but, when app gets killed , opened again, or when change orientation, fragments apparently recreated , custom fragmentadapter doesn't hold reference fragment. here code of main activity. public class mainactivity extends fragmentactivity { mypageradapter fgsadapter; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); //... fragmentmanager fm = super.getsupportfragmentmanager(); fgsadapter = new mypageradapter(fm,this); viewpager mypager = (viewpager) findviewbyid(r.id.home_pannels_pager); mypager.setadapter(fgsadapter); mypager.setcurrentitem(0); } @override protected void onresume() { super.onresume()