Posts

Showing posts from September, 2015

php - JSONP response download as a file? -

when call webservices , response convert jsonp format, @ time response come correctly download file. file format not displayed. download file. try below code. $result = array( 'result'=>'error', 'errormessage'=>'please enter valid data ); header('content-type: application/jsonp'); return json_encode($result); i try echo , print replace of return keyword. $result = array( 'result'=>'error', 'errormessage'=>'please enter valid data ); $this->output->set_content_type('application/json')->set_output(json_encode($result ));

swift - How to retrieve the last message from Quickblox in iOS? -

i send message chat dialog not able retreive last messages. how the last messages chat dialog id , and forwards recipient ios? if have been joined room, access lastmessagetext directly: dialog.lastmessagetext or last message id using qbrequest : qbrequest.messageswithdialogid("id", extendedrequest: ["sort_desc" : "date_sent", "limit" : 1], forpage: nil, successblock: { (response, messages, page) -> void in println(messages) }, errorblock: { (response) -> void in println(response) } )

objective c - AFNetworking GET parameters with JSON (NSDictionary) string contained in URL key parameter -

this json string has sent: { "dashboard": "compact", "theme": "dark", "show_side_bar": "yes" } to rest api using get method in format (since server retrieves data php code $_get["setting"] ) afhttprequestoperationmanager , such equivalent url becomes: http://www.examplesite.com/api/change_setting?setting={ "dashboard" : "compact", "theme" : "dark", "show_side_bar" : "yes" } when create nsdictionary of parameters in afhttprequestoperationmanager 's get:parameters:success:failure: adds url key parameter parameter dictionary this: { "setting": { "dashboard": "compact", "theme": "dark", "show_side_bar": "yes" } } in short only json string must encapsulated in setting parameter not object of setting in json string. edit: here's code: afhttpreq

why I can't swap unicode characters in python -

why can't swap unicode characters in code? # -*- coding: utf-8 -*- character_swap = {'ą': 'a', 'ż': 'z', 'ó': 'o'} text = 'idzie wąż wąską dróżką' print text print ''.join(character_swap.get(ch, ch) ch in text) output: idzie wąż wąską dróżką expected output: idzie waz waska drozka you need encode text first decode characters again : >>> print ''.join(character_swap.get(ch.encode('utf8'), ch) ch in text.decode('utf8')) idzie waz waska drozka its because of python list comprehension doesn't encode unicode default,actually doing : >>> [i in text] ['i', 'd', 'z', 'i', 'e', ' ', 'w', '\xc4', '\x85', '\xc5', '\xbc', ' ', 'w', '\xc4', '\x85', 's', 'k', '\xc4', '\x85', ' ', 'd', 'r&#

javascript - node.js upload and download pdf file -

framework : node.js/express.js/busboy/gridfs-stream(mongodb) i using busboy upload files , use gridfs-stream store files in mongodb gridfs. req.pipe(req.busboy); req.busboy.on('file', function (bus_fieldname, bus_file, bus_filename) { var writestream = gfs.createwritestream({ filename: bus_filename, }); bus_file.pipe(writestream); writestream.on('close', function (file) { res.redirect('/xxxxx/'); }); }); download simple: use gridfs-stream's createreadstream read contents mongodb , use following code send browser. gfs.findone({_id: attachmentid}, function (err, file) { if (err || !file){ res.send(404); }else{ var filename = file.filename; var readstream = gfs.createreadstream({_id: attachmentid});

Android : Making Listview full screen -

<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:orientation="vertical" tools:context=".mainactivity"> <edittext android:layout_margintop="5dp" android:layout_width="match_parent" android:layout_height="50dp" android:background="@drawable/location_edittext" android:id="@+id/locationeditext" android:textsize="15sp" android:textcolor="#999" android:paddingleft="15dp" /> <com.example.ravi_gupta.slider.viewpagercustomduration android:layout_width="wrap_content" android:layout_height="0dp" android:id="@+id/viewpager" android:scrollbarstyle="outsideoverlay" android:layout_weight="0.5&quo

swagger - Choose a tools to documents REST API -

i use doxygen document php rest application , discover apiary & swagger witch seem tools document api...i want know if there way generate documentation automatically using 1 of tools (apiary or swagger ) based on code comments? using swagger-php can generate documentation automatically collection of php scripts documented using annotations. swagger-php decently documented here: http://zircote.com/swagger-php/ working example can found on github: https://github.com/zircote/swagger-php/tree/master/examples/petstore regarding generation of json file containing documentation check answer here: https://stackoverflow.com/a/31178997/2853903

java - How to get phone contact without country code? -

i can contact number phone. want know how remove country code it. if user has phone number country code(+91-9876543210), need phone number without prefixed country code(9876543210). thanks in advance. i'd suggest use libphonenumber parse phone numbers easily. can split country code , phone number in way. try { // phone must begin '+' phonenumberutil phoneutil = phonenumberutil.getinstance(); phonenumber.phonenumber numberproto = phoneutil.parse("+91-9876543210", ""); int countrycode = numberproto.getcountrycode(); long nationalnumber = numberproto.getnationalnumber(); log.i("code", "code " + countrycode); log.i("code", "national number " + nationalnumber); } catch (numberparseexception e) { system.err.println("numberparseexception thrown: " + e.tostring()); }

modulo - VB6 Mod function gives incorrect values with negative values -

i have step in script in vb6 failing. code follows output = ((azmnum + steps ) mod 16777216) the values variables in function -850344 = (5184326 + -6034670) mod 16777216) all variables long numbers. other programs enter these values (python , excel) return 15926872. can't figure out why modulo being ignored. mod not same in languages, negative numbers. vb6 (and whole load of other compilers c, c++, c#, java) takes fortran interpretation remainder after dividing. mathematically, wrong interpretation if number negative. have is 5184326 + -6034670 = -850344 -850344 mod 16777216 = -850344 python , excel take correct interpretation of modulo result positive. takes step i.e. -850344 + 16777216 = 15926872

javascript - ng-attr not changing to true -

i have input looks this: <input type="text" autocomplete="off" name="itemcode" ng-model="item.itemcode" class="form-control" ng-attr-existing-item-validator="mode=='add'" required> which called existing-item-validator directive if mode not equal 'add', tried <input type="text" autocomplete="off" name="itemcode" ng-model="item.itemcode" class="form-control" ng-attr-existing-item-validator="isaddmode()" required> however, isaddmode never executed on scope. if change input ng-attr-existing-item-validator="{{isaddmode()}}" execute, existing-item-validator directive still getting called though isaddmode() returning false. am doing wrong ng-attr attribute? expect directive not called if equal false. setting directive parameter false doesn't mean directive not created, means passing variable directive can r

python - Optimizing this dynamic programming solution -

problem: you given array m of size n , each value of m composed of weight w , , percentage p . m = [m 0 , m 1 , m 2 , ... , m n ] = [[m 0 w , m 0 p ], [m 1 w , m 1 p ], [m 2 w , m 2 p ], ..., [m n w , m n p ] ] so we'll represent in python list of lists. we trying find minimum value of function: def minimize_me(m): t = 0 w = 1 in range(len(m)): current = m[i] t += w * current[0] w *= current[1] return t where thing can change m ordering. (i. e. rearrange elements of m in way) additionally, needs complete in better o(n!) . brute force solution: import itertools import sys min_t = sys.maxint min_permutation = none permutation in itertools.permutations(m): t = minimize_me(list(permutation), 0, 1) if t < min_t: min_t = t min_permutation = list(permutation) ideas on how optimize: the idea: instead of finding best order, see if can find way compare 2 given values in m , when know st

angularjs - Angular convention for $http / CRUD -

what angular convention or standard using $http hit api. performing crud within controller , getting fat. common move factory or common perform these actions in controller? if using api pure rest can use ngresource or restangular , if not better use services that.below link why should thin slice controller , have more business logic in services or factory http://toddmotto.com/rethinking-angular-js-controllers/

java - The sum of all the multiples of 3 or 5 below N -

i have find sum of multiples of 3 or 5 below n. example if have list natural numbers below 10 multiples of 3 or 5, 3, 5, 6 , 9,the sum of these multiples 23. now problem left want able read numbers display sum, reads 1 number , display sum right after it, ideas? import java.io.bufferedreader; import java.io.ioexception; import java.io.inputstreamreader; public class solution{ public static void main(string[] args) throws ioexception { bufferedreader br = new bufferedreader(new inputstreamreader(system.in)); string line = br.readline(); int nbr = integer.parseint(line); for(int j=0; j<nbr;j++) { bufferedreader br2 = new bufferedreader(new inputstreamreader(system.in)); string line2 = br2.readline(); string[] numbers = new string[nbr]; numbers[j]= line2; system.out.println(somme(long.parselong(numbers[j]))); } } public static long somme(long nn) { long s = 0;

android - Different text color each item of listview when populating using simple adapter -

Image
i'm trying set different text color of each item inside listview when populating item pict below, can't make work, the idea if number of "rata-rata" exceed 75 text color set black, if below set red. here's code, i'm overriding getview method : calonsiswa.add(map); list = (listview) findviewbyid(r.id.list); listadapter adapter = new simpleadapter(seleksinilai.this, calonsiswa, r.layout.activity_seleksi_nilai_single_item_view, new string[] { tag_no_urutan, tag_no_pendaftaran, tag_nama_lengkap, tag_jurusan, tag_rata_rata_nilai, tag_cara_seleksi }, new int[] { r.id.nomorurutan, r.id.nopendaftar, r.id.namapendaftar, r.id.jurusanpendaftar, r.id.rataratanilai, r.id.caraseleksi }) { @override public view getview(int position, view convertview, viewgroup parent) { view view = super.getview(position, convertview, parent); float ratarata = float.parsefloat(rata_rata);

html - Can the href of a link be changed dynamically inside a twig temple in Symfony 2 -

i've been working on menu in site while , i've been asking lot of question menu. idea menu have select project , clicking modify or delete button while do¸what needs selected project. so far, found 2 possible ways this: -do form select , 3 buttons (add, modify, delete) -do link each button , generate select in twig loop i think more logical option second one, problem link must send id of selected project. since twig generate html you, once it's generated, twig cannot again, can't twig change link according selected project! i know there must way solve javascript, but, really, rather prefer using form insteed, heaven if seems kind of weird in situation, because form knows project selected , it's easy use controller redirect on next page modify button , delete project. if link page change, need change javascript wouldn't happen oder sollution. so, there other way still make want links without javascript? if not, i'll take other solution.

c# - Specify IP End Point in FiddlerCore -

i'm using fiddlercore on server multiple network cards/ip's. how can specify ip end point fiddlercore should use? i'm looking interface similar bindipendpointdelegate, shown in sending httpwebrequest through specific network adapter . did digging , found setting, in fiddler called egressip. general documentation: http://fiddler.wikidot.com/egressip in fiddlercore set preference using code this: fiddlerapplication.prefs.setstringpref("fiddler.network.egress.ip", "127.0.0.1"); you can read more managing fiddler preferences here: http://fiddler.wikidot.com/prefs

logging - Supervisord does not show stdout from processes -

trying capture logs of app supervisor in docker. here's supervisord.conf: [supervisord] logfile=/dev/null nodaemon=true [program:autofs] command=automount -f redirect_stderr=true stdout_logfile=/dev/stdout stdout_logfile_maxbytes=0 [program:split-pdf] command=bin/split-pdf-server directory=/root/split-pdf redirect_stderr=true stdout_logfile=/dev/stdout stdout_logfile_maxbytes=0 after starting container works, , can see result of app running (it creates pdf files on network share) but log shows no output app: 015-07-02 00:39:26,119 crit supervisor running root (no user in config file) 2015-07-02 00:39:26,124 info supervisord started pid 5 2015-07-02 00:39:27,127 info spawned: 'split-pdf' pid 8 2015-07-02 00:39:27,130 info spawned: 'autofs' pid 9 2015-07-02 00:39:28,132 info success: split-pdf entered running state, process has stayed > 1 seconds (startsecs) 2015-07-02 00:39:28,132 info success: autofs entered running state, process has stayed >

java - How can I use my global variable inside an Adapter class? Android -

hi i'm trying pass value using global variable . have created class file extended application , add on manifest . public class myapplication extends application {} after had created adapter class extended baseexpandablelistadapter , i've search on how set , global variable i've created , found ((myapplication) getactivity().getapplication()).setmy_id(my_id); and able value use this integer my_id = ((myapplication) getactivity().getapplication()).getmy_id(); in fragments , can use getmy_id() method when putting inside baseexpandablelistadapter , i'm having error in getactivity(). tried using this still says cannot resolve method getapplication() , there other way value of global variable. i'm doing because i'm trying use cursor listview . wanted create expandable listview data database , cursor have parameter it's where condition data in global variable used. the reason why i'm using global variable because use data in differen

java - Using inner join on hibernate returning token uknown -

i'm having trouble hibernate. i'm trying create query return number of consults foreach medical ward, run sql on pgadmin , well, when tried create same sql on hibernate, has return erros. here code. sql: select a.cod_ala ,count(cod_consulta) max consulta c inner join medico m on m.cod_medico = c.cod_medico inner join ala on a.cod_ala = m.cod_ala group a.cod_ala java: public void getconsultasala() { string sql = "select a.cod_ala, count(cod_consulta) max consulta c" +" inner join medico m on m.cod_medico = c.cod_medico" +" inner join ala on a.cod_ala = m.cod_ala" +" group a.cod_ala"; query query; system.out.println(sql); this.session = generalcontroller.getsession(); query = this.session.createquery(sql); list list = query.list(); int = 0; while(list.iterator().hasnext()) { system.out.println(list.get(i++)); } } errors: jul 01, 2015 8:43:14

sharepoint 2010 - Target js files for specific version of IE with ~sitecollection token -

i working on sharepoint 2010 publishing site, have make fixes internet explorer 7 , 8, using following tags target ie version. <!--[if lt ie 9]> <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> <script src="/_catalogs/masterpage/mysite/scripts/respond.min.js"></script> <link href="/_catalogs/masterpage/mysite/css/iefix.css" rel="stylesheet" type="text/css"> <![endif]--> and working fine want add "~sitecollection" token make sure works under site collection url, have used following tag <!--[if lt ie 9]> <sharepoint:scriptlink language="javascript" name="~sitecollection/_catalogs/masterpage/mysite/scripts/respond.min.js" ondemand="false" runat="server" localizable="false"/> <![endif]--> but looks sharepoint control not work if condition, can see javascript file in vers

php - JavaScript: Uncaught TypeError: jQuery.toJSON is not a function -

i have tournament bracket found , import our vbulletin software. the script works outside of vbulletin, when import receive above error. function savefn(data, userdata) { var json = jquery.tojson(data); $.post("?tid="+ retparam("tid") +"&secretmode="+retparam("secretmode"), {'data':json}); } it's been driving me crazy, believe vbulletin in strict mode can't seem find problem. working: http://doghousesocial.com/area51/brackets.php?tid=1&secretmode=inlanadminmode you should use native json functions available in modern browsers ( https://developer.mozilla.org/en-us/docs/web/javascript/reference/global_objects/json ) switch this, eliminate error: var json = json.stringify(data); i'm not sure why jquery.tojson(data) work outside $.tojson not function of jquery. why error came up.

google chrome extension - Communicate between Native Messaging Host and C# app -

i have chrome extension can communicate native messaging host created in c#. however, how can communicate between native messaging host , c# app. think via native messaging host input/output streams, haven't been able find how this. i couldn't find way of using process.standardinput because chrome launches native messaging host. instead used wcf. here code: private static object syncroot = new object(); static string returnvalue = null; [servicecontract] public interface igetchromestring { [operationcontract] string getstring(string value); } public class cgetchromestring : igetchromestring { public string getstring(string value) { openstandardstreamout(value); // wait until openstandardstreamin() sets returnvalue in main thread lock (syncroot) { monitor.wait(syncroot); } return returnvalue; } }

android - Backup Restore Data include Application -

i make android application backup-restore data google drive. can me? please... if not google drive, want sdcard there load of documentation worth going through here: https://developers.google.com/drive/android/intro also github link: https://github.com/googledrive/android-demos/ remember need authorise app in google developer console - can debug key, needs changed release key when app published. documentation tells in authorize requests section.

html - Can somebody tell me how I am using the class selector incorrectly? -

html file: <html> <head> <link rel=“stylesheet” type=“text/css” href=“style.css” /> </head> <body> <p>red</p> </body> </html> css file: p { color: red; } the word 'red' not change red text when open page in browser. if know why css file isn't linking html file appreciated. files in same directory. the code have provided has no errors. fiddle: https://jsfiddle.net/9n97lz69/ please copy & paste following code html file , verify works: index.html: <style> .menu p { color: red; } </style> <div class="menu"> <p>this sentence should red.</p> </div> fiddle: https://jsfiddle.net/21umj65u/ then move css mystyle.css , verify works: index.html: <head> <link rel="stylesheet" type="text/css" href="mystyle.css"> </head> <div class="menu"> <p>thi

c++ - Different overloads with std::function parameters is ambiguous with bind (sometimes) -

i have 2 overloads of function foo take different std::function s results in ambiguity issue latter when used result of std::bind . don't understand why only ambiguous. void foo(std::function<void(int)>) {} void foo(std::function<int()>) {} void take_int(int) { } int ret_int() { return 0; } when using int() bind function ambiguity error foo(std::bind(ret_int)); // error with gcc-5.1 error (and similar clang) error: call 'foo' ambiguous foo(std::bind(ret_int)); ^~~ note: candidate function void foo(std::function<void(int)>) {} ^ note: candidate function void foo(std::function<int()>) {} however of following work foo(std::bind(take_int, _1)); foo(take_int); foo(ret_int); foo([](){ return ret_int(); }); struct takeint { void operator()(int) const { } }; struct retint { int operator()() const { return 0; } }; foo(takeint{}); foo(retint{}); looking @ std::function constructor template< class f > functio

ios - Calling cellForRowAtIndexPath from within heightForRowAtIndexPath — alternate? -

i'm trying call cellforrowatindexpath within heightforrowatindexpath in order assign height based on cell's type (i'm subclassing uitableviewcell ). trivial, right? well, calling there causes loop. can't quite seem figure out why be. placing breakpoints in both methods doesn't yield anything—the delegate method cellforrowatindexpath never gets called. take look: func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { switch indexpath.row { case 0: return subclasscelltypeone() default: return subclasscelltypetwo() } } func tableview(tableview: uitableview, heightforrowatindexpath indexpath: nsindexpath) -> cgfloat { // calling cellforrowatindexpath here causes loop let cell = tableview.cellforrowatindexpath(indexpath)! if cell subclasscelltypeone { return uitableviewautomaticdimension } else { return 100 } } any idea why that's h

c++ - How do you remove row numbers for a QTableView in Qt -

this question has answer here: removing index numbers in qtablewidget 1 answer i using qtableview display instructions low level emulator. however, rows index 1 whereas instructions index 0. either need remove row numbers , add column can fill 0 indexed instruction number of change row numbers index 0. i cannot see how either, being blind? try: yourtable->verticalheader()->setvisible(false); to hide row numbers.

python - Running Hadoop mapreduce Django apps on a Heroku dynamo -

is readily possible integrate hadoop client python (django) mapreduce apps/scripts remotely (on heroku dynamos or from free cluster ) done locally in these examples: http://www.michael-noll.com/tutorials/writing-an-hadoop-mapreduce-program-in-python/ http://blog.matthewrathbone.com/2013/11/17/python-map-reduce-on-hadoop---a-beginners-tutorial.html hadoop , django, possible? this heroku addon led me believe might possible: https://devcenter.heroku.com/articles/treasure-data . app isn't free , learning-curve-to-cost ratio not obvious investment me. my motivation cross heroku/django/hadoop bridge upgrade current django apps social media mining features. i doubt can install hadoop on heroku, if can what's point? hadoop makes distributed computing easy, if going run in heroku free tier have cluter of one, maybe 2 dynos. harness power of hadoop need more hardware. heroku dynos have 512 mb of ram....

java - two problems with mean med mode method -

so here completed code calculates mean, median, mode, standard deviation, min, max, q1, q2, , 5 number summary supposed returned array. array formatted knowledge, odd reason return array spitting out 5 number summary:[d@689af4 , don't life of know why or how fix it. mode outputting 22 when need out put -1. there 1 can @ , tell me wrong , can fix these issues? import java.util.arrays; class statistics { public static void main(string[] args) { int[] = new int[]{22,44,66,55,33}; bubblesort(a); double mean; double median; int mode; int max; int min; double sd; int q1; int q3; double[] vals; mode = calcmoe (a); median = calcmed (a); mean = calcmean (a); max =calcmax (a); min =calcmin (a); sd =calcsd (a); q1=calcquart1 (a); q3=calcquart3 (a); vals=calcnum

javascript - jQuery - Simple math returning NaN -

i trying simple math, using below function. function called onchange : var exposure = $('#exposure').find(":selected").val(); var budget = $('.budget').val(); var ppc = $('.ppc').val(); var value = budget/ppc; var total2 = math.floor(value*0.95); if(exposure == 2){ var dref = 0.0005; }else if(exposure == 3){ var dref = 0.005; }else if(exposure == 4){ var dref = 0.001; } if(exposure > 1){ var add = dref+ppc; var value2 = budget/add; var total2 = math.floor(value2*0.95); } $("#sum").text("" + total2 + " clicks"); my problem is, if exposure > 1 , total2 value in #sum return nan what doing wrong? do parseint(value,10) intergers or parsefloat(value) float. javascript appends values if data type not number. like: budget = parseint(budget,10);

How does a CPU know if an address in RAM contains an integer, a pre-defined CPU instruction, or any other kind of data? -

the reason gets me confused addresses hold sequence of 1's , 0's. how cpu differentiate, let's say, 00000100 (integer) 00000100 (cpu instruction)? first of all, different commands have different values (opcodes). that's how cpu knows what do. finally, questions remains: what's command, what's data? modern pcs working von neumann -architecture ( https://en.wikipedia.org/wiki/john_von_neumann ) data , opcodes stored in same memory space. (there architectures seperating between these 2 data types , such harvard architecture ) explaining everything in detail totally beyond scope of stackoverflow, amount of characters per post not sufficent. to answer question few words possible (everyone working on level kill me shortcuts in explanation): data in memory stored @ addresses. each cpu advice consisting of 3 different addresses (not values - addresses!): adress what do adress value adress an additional value so, assuming addition shoul

c# - How do I find a customer's files using SuiteTalk? -

i attempting create .net program calls netsuite web services return list of files associated customer. i have set shopperjoin customer i've searched for, web call still returns files in file cabinet. filesearch file = new filesearch(); customersearchbasic custbasic = new customersearchbasic(); custbasic.entityid= new searchstringfield(); custbasic.entityid.@operator = searchstringfieldoperator.contains ; custbasic.entityid.operatorspecified = true; file.shopperjoin = custbasic; file.basic = new filesearchbasic();custbasic.entityid.searchvalue = "id"; searchresult result = _service.search(file); i using 2015 suitetalk wsdl https://webservices.na1.netsuite.com/wsdl/v2015_1_0/netsuite.wsdl have checked if customer id , folder id same? (just hunch)

android - ImageView setImageDrawable results in a blank image being drawn -

the code in oncreate() applicationinfo app = getpackagemanager().getapplicationinfo(getintent().getstringextra("app"), 0); ((textview) findviewbyid(r.id.textview2)).settext(app.loadlabel(getpackagemanager())); ((imageview) findviewbyid(r.id.imageview2)).setimagedrawable(app.loadlogo(getpackagemanager())); the image set third line should draw app icon, instead draws blank. note, app in question not app, app on phone. so, i've passed applicationinfo directly activity , through package name now, don't think that's issue. i've set dummy image in xml , commented third line , image displays correctly. doing wrong? the xml <imageview android:layout_width="50dp" android:layout_height="50dp" android:id="@+id/imageview2" /> you have chosen strange way set image in opinion. have tried setting by ((imageview) findviewbyid(r.id.imageview2)).setimageresource(r.drawable.your_image_name_here) or ((imag

php - Laravel 5 - Change all values in a Column of a table -

i have table column called "estado" , want change column in 1 shot. this right method? faster one? $vendedor = vendedor::with('produtos')->find( $idvendedor ); foreach ( $vendedor->produtos $produto ) { $produto->pivot->estado = $novoestado; }; the column want change "estado". there's way without foreach? the simplest use query builder (instead of model) db::table('table_name')->where('vendedor_id', $idvendedor)->update('estado', $novoestado);

c++ - Adding this instance variable to the header of a C++11 file drives the compiler up the wall. Why? -

i've been trying artificial intelligence program (written in c++11) stop spewing out error messages larger terminal record. i've withered away methods 1 @ time until message went away, , have hence found precise line makes computer go bonkers. here's pertinent part of code: #include <iostream> #include <vector> #include <algorithm> #include <math.h> class h { public: h(int); int get_val(); private: int val; }; class hvote { public: hvote() : error(1.0) { } std::vector<h&> hs; double error; }; int main() { hvote hvote; return 0; } to me, looks reasonable. however, compiler (g++) disagrees. error messages long terminal doesn't bother saving beginning, don't know true length. however, they're pretty repetitive. last page, instance, reads: /usr/include/c++/4.8/bits/stl_vector.h: in instantiation of ‘class std::vector<h&>’: hvote.h:16:25: req

php - On local works, on server shows 404 -

i need don't understand. i developing website customer. doing on local, , every day upload server changes , new things. last done create simple way extract section, parameters , values url. like: http://mywebsite.com/product/color/red really not shop, example shows want tell you. the idea have folder sections (product.php, home.php, contact.php, ...) , section on url says file use. this working on computer. but i've uploaded files (literally) server , not working. shows me 404 error. i think problem .htaccess , php versions (i works on php 5.5.10 on local, , server runs on 5.4.16). this .htaccess: <ifmodule mod_rewrite.c> rewriteengine on # send would-be 404 requests craft rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{request_uri} !^/(favicon\.ico|apple-touch-icon.*\.png)$ [nc] rewriterule (.+) index.php?params=$1 [qsa,l] </ifmodule> i don't know if need more information this. if want, , show you

Java Jackson : Can I hold in a json the type to deserialize it to? -

the usual way serialize json , is: string catstr = mapper.writevalueasstring(cat); cat catout = mapper.readvalue(catstr, cat.class); is there way add (maybe annotation ) type json on serialization , let mapper take value when deserialize it? so can following object obj = mapper.readvalue(catstr); and later... cat catout = (cat)obj; thanks. sort of. can add property serialization indicate class is. , when deserializing it, jackson deduces class automatically. but cannot deserialize object, need base class/interface objects want behave this. , interface needs use @jsontypeinfo annotation, signalling jackson when deserializing base class use property class distinguish type. example: @jsontypeinfo(use = jsontypeinfo.id.class, include = jsontypeinfo.as.property) private abstract class base { } private class extends base { private final int i; @jsoncreator public a(@jsonproperty("i") int i) { this.i = i; } } when seri

hibernate - I get a Runtime Exception while executing servlet on server -

severe: servlet.service() servlet [s1] in context path [/newwebsite] threw exception org.hibernate.boot.registry.classloading.spi.classloadingexception: unable load class [com.mysql.jdbc.driver] @ org.hibernate.boot.registry.classloading.internal.classloaderserviceimpl.classforname(classloaderserviceimpl.java:245) @ org.hibernate.engine.jdbc.connections.internal.drivermanagerconnectionproviderimpl.loaddriverifpossible(drivermanagerconnectionproviderimpl.java:200) @ org.hibernate.engine.jdbc.connections.internal.drivermanagerconnectionproviderimpl.buildcreator(drivermanagerconnectionproviderimpl.java:156) @ org.hibernate.engine.jdbc.connections.internal.drivermanagerconnectionproviderimpl.configure(drivermanagerconnectionproviderimpl.java:95) @ org.hibernate.boot.registry.internal.standardserviceregistryimpl.configureservice(standardserviceregistryimpl.java:111) @ org.hibernate.service.internal.abstractserviceregistryimpl.initializeservice(abstractserviceregi

c# - Google API won't recognize my ip -

Image
so have google api project. i've written c# program connect using public access api key. when api key not restricted particular ip address, program works. however, when restrict api key ip address of server, so: i ip blocked error, so: i confirmed ip of machine in 2 ways. went whatsmyip.com , got this: and wrote little php program on server , called via console app remote_addr: according every method know check, ip address ###.###.###.197. when put ip in key server applications says ip not allowed. i've run same program other computers , put computers' ip addresses in server key , program worked. why google api not recognizing ip address of machine @ ###.###.###.197 though permitted ip in api key? one idea: can modify google api project tell client ip address google sees? have never worked google api saw can geolocation , stuff that, assume google-side code should able access info. if google api project sees .197 ip address, it's time conta

cypher - Neo4j versioning graph/nodes/relationships, checkpointing -

we keep snapshots/versions of graph(or versions of specific node). want switch version (like in git repo). we tried using graphaware's changefeed doesn't solve our purpose. we have found github project: https://github.com/dmontag/neo4j-versioning . outdated. are there plugins can in achieving this?

Get url parameters and redirect to specific url with javascript -

how can redirect specific url appear in url parameter? example: http://www.mywebsite.com/code_id.tv/stream.php i want code_id , redirect specific url. the result url this: http://www.mynewwebsite.com/tv.php?id=code_id thanks to split path code_id: var url2process = window.location.pathname; var patharray = url2process.split( '/' ); // remove '.tv' or '.movie' or '.whatever' end var code_id_array = patharray[1].split('.'); var code_id = code_id_array[0]; // redirect window.location = 'http://domain.com/rb/play.php?id=tt' + code_id;

autolayout - iOS Layout - Whats the best solution? -

Image
for ios app working on, need manage controls displayed on screen based on type of device app running on. i try explain theoretical example (the actual numbers used below not important, interests me best method achieve desired result). example: in case of app in screenshots, button overlaps uiimageview should not displayed @ or displayed in place on screen. so far i've worked autolayout , , figure, there's no way xcode like: hey, class size "compact width / compact height" , want hide these buttons...but show them "regular width / compact height" . i did googling , saw people talk using different storyboards based on device; thinking, add/remove buttons dynamically based on device type , think it's not pleasant have add of constraints hand (programatically is). so resume, appreciate suggestion of 'best' way , best meaning combination of 'not hard' + ' not long'. also, code example (or links) highly appreciated.

javascript - Error handling loading pdf in object tag -

i dynamically displaying pdf object tag based on name, there chance name added without pdf getting added. handle , @ least display text rather leaving blank space when pdf isn't found. this have: document.getelementbyid("someid").innerhtml = "<object data=\"" + somename + ".pdf\" type=\"application/pdf\" width=\"500\" height=\"500\">you don't have pdf plugin browser.</object>"; is there way can use use html or javascript when file doesn't load? also, need support ie7.

javascript - jQuery Datatable header and body width mismatch withcollapsed sidebar -

Image
i have datatable , collapsible sidebar. table has table-layout:fixed , defined of columns width in css. table looks perfect when sidbar collapsed, if sidebar opened, column , header misaligned. when open firebug, see datatables_scrollheadinner has width: 1558px; datatables_scrollbody has width: 1343px . have no idea why header isn't getting resized along body. codes below (the html being generated dynamically , big paste here): javascript: $(document).ready(function () { var selector = "#artist_datatable"; var defaults = { "language": { "processing": "processing...", "lengthmenu": "show _menu_ entries", "zerorecords": "no matching records found", "info": "showing _start_ _end_ of _total_ entries", "infoempty": "showing 0 0 of 0 entries", "sinfofiltered": "(filtered _max_ total entries)", "infopostfix":

python 2.7 - UnboundLocalError: local variable 'lead_x' referenced before assignment -

def gameloop(): gameexit = false lead_x_change = display_width/2 lead_y_change = display_width/2 lead_x_change = 0 lead_y_change = 0 while not gameexit: event in pygame.event.get(): if event.type == pygame.quit: gameexit = true if event.type == pygame.keydown: if event.key == pygame.k_left: lead_x_change = -block_size lead_y_change = 0 elif event.key == pygame.k_right: lead_x_change = block_size lead_y_change = 0 elif event.key == pygame.k_up: lead_y_change = -block_size lead_x_change = 0 elif event.key == pygame.k_down: lead_y_change = block_size lead_x_change = 0 if lead_x >= display_width or lead_x < 0 or lead_y >= display_height or lead_y < 0 : gameex