Posts

Showing posts from May, 2014

web services - Databases in a microservices pattern/architecture -

i'm trying understand layout of microservices pattern. given each microservice run on over vm (for sake of example) how database fit architecture? would each service, in turn, connect consolidated database read/write data? thanks insight there's no 1 size fits solution. the general principle each microservice should make right decision in terms of right persistence architecture should be. might connected central sql database, or using filesystem, or using nosql data store, or memcached, or whatever. (this why people talk eventual consistency lot microservices.) you want way capture benefits of microservices. you want each microservice independently shippable, you're not blocked on anything. stronger coupling centralized infrastructure reduces independence of microservice. persistence requirements highly variable. if you're running search microservice, don't need acid semantics of typical sql database. if you're doing payments, need acid...

regex - Change index.php in urls with .htaccess -

i want replace index.php in urls my url example: http://example.com/index.php/blog/foo i need be: http://example.com/my.php/blog/foo or http://example.com/name/blog/foo http://example.com/shop/blog/foo ... you can use code in document_root/.htaccess file: rewriteengine on rewritebase / rewriterule ^[^/]+/(blog/.+)$ index.php/$1 [l,nc]

I've downloaded zip from ARC welder app. When I upload it to chrome webstore, it's status remains PROCESSING -

Image
i want publish android apk chrome web store. i've downloaded zip arc welder app. when launch app welder app, it's working expected. but, when upload chrome webstore developer dashboard, it's status remains processing. doesn't change. however, docs edit page appear within seconds after upload. what's wrong? can extract zip download app welder - change manifest file , add icon images - zip again - upload web store? the error met known bug developer dashboard ui , has affected many developers currently. google chrome engineer team working on , may have fix soon. best can trying upload via publish api : https://developer.chrome.com/webstore/using_webstore_api

visual studio - Why is codelens spamming my code in VS2015? -

Image
i see how codelens can cool far it's been disrupting. makes actual code hard read. possible somehow group codelens appearances or reset them becuse i'm pretty sure bug: this expected behavior, can change @ options -> text editor -> codelens

node.js - Is Scala Truly Asynchronous -

these days looking scala writing non-blocking restful api. have done couple of projects in node.js , curious scala time around. my findings till have been impossible write 100% asynchronous code in scala of underlying code blocking. can find tutorials on how use jdbc in scala application database connectivity. jdbc being blocking means application using can't work in single threaded environment queue other requests while waiting db response.play framework recommends increasing thread pool when using blocking apis means going started. as node.js, available modules have been written asynchronously. specially of database connectors , file handlers read/write asynchronously keeping in mind nothing can block when have single thread. yet see people favoring scala on node.js type safety , computation power while being asynchronous. asynchronous behavior doesn't reflect in of tutorials , resources available online. my question is, me failing understand or there confusion in j...

javascript - Website Ads are opening external links when they load -

i'm using ads adtech , pubmatic on site, of them trying open external protocols on mobile devices when load. so far tried without success: get solution ad providers. toggle sandbox attribute of iframe loading app in order restrict popups when iframe loads. override window.open function. look adblock source ideas. has faced similar problem? there possible solution? thanks in advance.

c++ - Boost.Asio: Is it a good thing to use a `io_service` per connection/socket? -

i want create application implements one-thread-per-connection model. each connection must stoppable. have tried this boost.asio example implements blocking version of want. after little bit questioning i've found out there no reliable way stop session of example. i've tried implement own. had use asynchronous functions. since want make thread manage 1 connection , there no way control asynchronous job employed thread, decided use io_service each connection/socket/thread. so approach, know better approach? my code here can examine , review it: #include <boost/asio.hpp> #include <boost/bind.hpp> #include <boost/array.hpp> #include <boost/thread.hpp> #include <boost/scoped_ptr.hpp> #include <list> #include <iostream> #include <string> #include <istream> namespace ba = boost::asio; namespace bs = boost::system; namespace b = boost; typedef ba::ip::tcp::acceptor acceptor_type; typedef ba::ip::tcp::socket socket_ty...

Kibana (Elasticsearch) dev environment -

i want embed 1 specific chart in dahsboard of kibana. need inject js kibana source. have followed instructions https://github.com/elastic/kibana/blob/master/contributing.md provide test environment, have obtained error after "./kibana --dev" let _ = require('lodash'); ^^^ node.js:201 throw e; // process.nexttick error, or 'error' event on first tick ^ syntaxerror: unexpected strict mode reserved word @ module._compile (module.js:429:25) @ object..js (module.js:459:10) @ module.load (module.js:348:32) @ function._load (module.js:308:12) @ array.0 (module.js:479:10) @ eventemitter._tickcallback (node.js:192:41) can me start environment, or advice. probably, moving wrong way...my general goal (inject js code kibana) can reached approach. thanks i have reached general goal, , if right - place here approach. (also, answer above question) when seeking ways how implement want (my own custom metrics in dashboard....only train...

c# - linq query group by in a list of strings -

this question has answer here: remove duplicates list<t> in c# 21 answers i new linq query c#. have list of strings , new list or delete double strings. list<string> zipcodes = new list<string>(); zipcodes.add("1234"); zipcodes.add("1234"); zipcodes.add("1234"); zipcodes.add("4321"); zipcodes.add("4321"); list<string> groupbyzipcodes = (from zip in zipcodes group zip zip newgroup select newgroup.tolist()); cannot implicitly convert type 'system.collection.generic.ienumarable<system.collections.generic.list<string>' 'system.collections.generic.list<string> . explicit conversion exists (are missing cast?) you can use distinct keyword in linq: var dedupedlist = zipcodes.distinct().tolist(); for more see https://msdn.microsoft.com/en-us/librar...

playframework - in play 2.4 logback configurations, where is ${application.home} defined? -

the link here shows how configure custom logger. https://www.playframework.com/documentation/2.4.x/settingslogger i wondering ${applicaation.home} defined, seems not have been defined in production environment. as indicated @user316607, play should define application.home in logger.configure method . if seeing value application.home_is_undefined instead, , you're using compile-time dependency injection , you'll need call logger.configure in applicationloader explained in this blog post : class myapplicationloader extends applicationloader { def load(context: context) = { new mycomponents(context).application } } class mycomponents(context: context) extends builtincomponentsfromcontext(context) { // have call logger.configure manually or logback won't work logger.configure(context.environment) // ... rest of app initialization code ... }

osx - No bag entry - Cocoa -

Image
i working on app written in swift mac . using xcode 6.4 on osx 10.10.4 i noticed weird messages regarding in app purchases. when run app method request:didfailwitherror of skproductsrequestdelegate invoked seen below func request(request: skrequest!, didfailwitherror error: nserror!) { println("failed: \(error.localizeddescription)") } this code snippet prints failed: no bag entry further, solve cleaned project remove old binary. when try execute newly build binary finder says after clicking on sign in nothing happens. questions what no bag entry ? why alert (present in image) saying have purchased app, although testing in app store sandbox ? note the reason executing app finder(outside xcode) mac applications required executed outside xcode first time, can fetch receipt apple server mac app store kept logged out through entire process this error popped out reason. pretty sure has done outside xcode. update apple has u...

javascript - Coffescript compile constructor with wrong argument name -

i'm trying use first time coffeescript angularjs. i want define new service dependence service $http here i'm expecting: var myservice = function($http) { this.$http = $http; }; myservice.prototype.call = function(url, data) { this.$http(url, data); }; myapp.service("webservice", myservice) this normal way register service shown in angularjs documentation. after reading article working coffeescript , angularjs, have tried this: myapp.service "webservice", class constructor : (@$http) -> call : (url, data) -> @$http url, data but result of compilation give javascript: myapp.service("webservice", (function() { function _class(_at_$http) { this.$http = _at_$http; } _class.prototype.call = function(url, data) { return this.$http(url, data); }; return _class; })()); the problem coffeescript compiler shouldn't replace @$http _at_$http . in case should output javascrip...

Getting data from a join tables tu sub categories in access with SQL -

Image
i created relationship access database when creating query return values dont data. how can data tube , tmc tables projecttype or projectid ? so should query query generated access not working select project.projectname, projectsubtypesid.projectsubtypesid, tube.tubename, tube.duration, tmc.tmcname tmc inner join (tube inner join (project inner join projectsubtypesid on project.projectid = projectsubtypesid.projectid) on tube.tubeid = projectsubtypesid.tubeid) on tmc.tmcid = projectsubtypesid.tmcid; try this: select project.projectname, projectsubtypesid.projectsubtypesid ( (projectsubtypes inner join project using (projectid) ) inner join tube using(tubeid) ) inner join tmc using(tmcid) group projectsubtypes.projectid, projectsubtypes.tubeid, projectsubtypes.tmcid order projectsubtypes.projectid;

linux - Python daemon doesnt spawn at times -

i have daemon in python spawn using daemonrunner api(a pid file , lock file created). pid file , lock file deleted when daemon stopped. the start/stop works fine except daemon doesn't start. need delete entire folder had pid file up. how debug this? there auto-generated file name host.mainthread-pid. significance of this? here's class start/stop daemon class myrunner(daemonrunner): def __init__(self,appl): self.appl = appl daemonrunner.__init__(self,appl) def start(self): // check if pid file exists.. retval =daemonrunner.start(self) return retval def stop(self): return daemonrunner.stop(self) strace looks similar both successful , unsuccessful usecases.

devtools - R library(qdap) installation error -

i having difficulty installing qdap library, see below: i installed java library first, , qdap library: sys.setenv(java_home='c:\program files (x86)\java\jre7') library(rjava) then devtools library: library(devtools) install_github("trinker/qdapdictionaries") install_github("trinker/qdapregex") install_github("trinker/qdaptools") install_github("trinker/qdap") the other installations before qdap go fine, @ qdap error generated: install_github("trinker/qdap") downloading github repo trinker/qdap@master installing qdap skipping 3 packages ahead of cran: qdapdictionaries, qdapregex, qdaptools "c:/progra~1/r/r-32~1.1/bin/x64/r" --no-site-file --no-environ --no-save --no-restore \ cmd install \ "c:/users/seema/appdata/local/temp/rtmpmdvhcq/devtools101432a84788/trinker-qdap-85cbe87" \ --library="c:/users/seema/documents/r/win-library/3...

instamojo wordpress plugin not working -

i using wordpress 4.2, , looking use instamojo payment gateway, added plugin. when try create short codes, showing fatal errors. can 1 on issue? see error bellow fatal error: uncaught exception 'exception' message 'error in listing offers.' in /home4/ltzone/public_html/directory-listing/wp-content/plugins/instamojo/lib/instamojo.php:274 stack trace: #0 /home4/ltzone/public_html/directory-listing/wp-content/plugins/instamojo/option.php(243): instamojo->listalloffers() #1 [internal function]: instamojo_settings_page->create_admin_page('') #2 /home4/ltzone/public_html/directory-listing/wp-includes/plugin.php(496): call_user_func_array(array, array) #3 /home4/ltzone/public_html/directory-listing/wp-admin/admin.php(226): do_action('settings_page_i...') #4 /home4/ltzone/public_html/directory-listing/wp-admin/options-general.php(10): require_once('/home4/ltzone/p...') #5 {main} thrown in /home4/ltzone/public_h...

PowerShell capture website data using regex and Invoke-WebRequest -

i trying capture playing song on radio station when displayed on website, i'm @ beginning of writing script, far have following code: $webpage = (invoke-webrequest http://www.2dayfm.com.au).content $regex = [regex]"(.*nowplayinginfo.*span)" $regex.match($webpage).value.split(">")[4].replace("</span","") this captures website listed in code, there's 2 things issue. the first thing, when code run, comes loading... reason this, if @ result of this: (invoke-webrequest http://www.2dayfm.com.au).content | clip paste notepad, if search " playing: " has line: <p><span class="listenheading">playing:</span> <span id="nowplayinginfo">loading...</span></p> when run invoke-webrequest in code, captures website @ point in time, , see in real life, navigate in browser http://www.2dayfm.com.au/ , right @ top playing song is, says loading... short time before so...

c++ - cocos2d-x CSLoader how to load selected nodes only -

i'm searching docs on cocos2dx website , on google couldn't find any. problem is, when load csb file cocostudio, loads nodes , resources etc... makes texture memory high. know if there method or solution loading selected nodes scene file of cocostudio. thanks! i had same kind of problem, , stems trying make 1 scene contain need. decided split components layers, loaded own components when needed. as example. in main scene have inventory tray, building area , custom buttons panel. split of these separate layers. inventorytray.csb, buildingarea.csb, buttonpanel.csb , have them seperate in code well, 1 object load each of layouts. overall code lot more maintainable since each class has few lines of code in it. this way can load inventory tray up, , not load buttons panel until user "needs" interact it. same goes fancy pause menu's might include animations , assets may take more texture memory. create separate layer , load when need to. i hope help...

javascript - Uncaught SyntaxError: missing ) after argument list in loop -

i keep getting same error in code on line 21. if(typeof jquery === undefined){ throw "jquery required sapphire work. didn't read readme?"; } (function ( $ ) { $.fn.slider = (function(options,images) { var settings = $.extend({ slidecount: 4, animationtype:"none", slideduration:2000, slidersize:1100, looptimes:300000000000000000000000000000000000000000 },options); for(var = 0; i<options.looptimes; i++){ var j = 0; $("#sapphire-slide").append("<img src='"+images[j]+"'>"); settimeout(function() { if(j<options.slidecount-1) j++; }else if(j===options.slidecount-1){ j=0; } },options.slideduration); } ); })( jquery ); i not sure causing error, , looks fine syntax me. thanks! you've got closing brace if in function you're passing settimeout : if (j < options.slideco...

objective c - How to cancel a completion handler in iOS -

i want array of nearby locations using mapkit framework. when user types in textfield call following function. - (void)searchforlocations:(nsstring *)string { [nsobject cancelpreviousperformrequestswithtarget:self selector:@selector(search:) object:nil]; [self performselectorinbackground:@selector(search:) withobject:string]; } - (void)search :(nsstring *)string { mklocalsearchrequest *request = [[mklocalsearchrequest alloc] init]; request.naturallanguagequery = string; mkcoordinateregion region; mkcoordinatespan span; span.latitudedelta = 0.05; span.longitudedelta = 0.05; region.span = span; region.center = newlocation.coordinate; request.region = region; mklocalsearch *search = [[mklocalsearch alloc]initwithrequest:request]; [search startwithcompletionhandler:^(mklocalsearchresponse *response, nserror *error) { if (response.mapitems.count == 0) { nslog(@...

javascript - JS Dropdown Menu Behavior -

i have dropdown menu working can't figure out how close previous menu onclick. menues stay open need them close when different menu open. please see jsfiddle https://jsfiddle.net/yvhnphp4/ $(document).ready(function(){ // dropdown menu var finddropdowns = document.queryselectorall(".has-dropdown"); for(var = 0; < finddropdowns.length; i++) { if(i == 0) { var dropdownid = "has-dropdown-1"; finddropdowns[i].setattribute("id", dropdownid); }else { var addonetoindex = + 1; dropdownid = "has-dropdown-" + addonetoindex; finddropdowns[i].setattribute("id", dropdownid); } var targetdropdown = document.getelementbyid(dropdownid); targetdropdown.onclick = dropdowntrigger; } function dropdowntrigger(e) { e.preventdefault(); var showhidedropdown = e.target.nextelementsibling; showhidedropdown.setattribute("class", "show"); } }); ...

ios - How can I get int values from the change dictionary in KVO method observeValueForKeyPath:ofObject:change:context:? -

i observing changes in rate property of avplayer calling following method on so: addobserver:sharedplayermanagerinstance forkeypath:@"rate" options:nskeyvalueobservingoptionnew|nskeyvalueobservingoptionold context:0]; the change dictionary observevalueforkeypath:ofobject:change:context: therefore: change = { kind: 1, new: 1, old: 0 } i checked class of each value, , turns out __nscfnumber. however, when try convert [change objectforkey:@"new"] or [change objectforkey:@"old"] int, nsinteger, nsnumber, tried nsstring, etc, works "old", gives me parsing error "new": error: expected type error: 1 errors parsing expression i need compare them, , can't figure out. bug in ios? objective c -(void)observevalueforkeypath:(nsstring *)keypath ofobject:(id)object change:(nsdictionary *)change context:(void *)context{ nsnumber * newvalue = [change objectforkey:nskeyvaluechangenewke...

gdb - Debugging with gdbserver and qemu, how to set watchpoint on a control register, cr3 -

i'm debugging kernel , want know when cr3 register changed. know how set watchpoint on general purpose register eax , others. the problem is, since gdb not have access control registers, setting watchpoint on cr3 not work. so, possible set watchpoint qemu monitor? if yes, how? sorry, there's no way qemu monitor. (if @ target-i386/helper.c:cpu_x86_update_cr3() in qemu sources you'll see doesn't notify cr3 updates, puts new value internal cpu state structure.) the best can sort of thing run 2 debuggers (one connected qemu's gdbstub talk guest, , 1 directly debugging qemu itself). can put breakpoint on cpu_x86_update_cr3() in qemu , see what's going on then. need know fair amount qemu's internals able effectively, though...

mouseevent - Making eyeball look at/follow cursor movement (C#) -

Image
i'm stuck here. want have eyes drawn while 'looking' @ (the angle of) cursor. also, should contained within bigger circle/quadrant (just eyeball). sadly, won't draw eye me @ right position/angle , @ every mouse movement. thing draw ellipse @ (0,0), that's not want. my idea calculate ratio of triangles pythagorean theorem. apply right coordinates (with correct ratio) in drawellipse(); method. should repeated everytime move cursor. you can check image mathematical reasoning. here code, note panel made in designer mode isn't included in code, shouldn't big deal: using system; using system.collections.generic; using system.componentmodel; using system.data; using system.drawing; using system.linq; using system.text; using system.threading.tasks; using system.windows.forms; namespace oogjes2 { public partial class form1 : form { public int mousex; public int mousey; public form1() { initializeco...

lucene - How to query a phrase with stopwords in ElasticSearch -

i indexing text stopwords enabled , search against these using "match phrase" query without slop, looks stopwords still taking in account terms positions. building index: put /fr_articles { "settings": { "analysis": { "analyzer": { "stop": { "type": "standard", "stopwords" : ["the"] } } } }, "mappings": { "test": { "properties": { "title": { "type": "string", "analyzer": "stop" } } } } } add document: post /fr_articles/test/1 { "title" : "tom king of toulon!" } search: post /fr_articles/_search { "fields": [ "title" ], "explain": true, "query": {...

javascript - How to setup Angular validation to work on blur and form submit? -

angular validation works updating on model change. although displaying these validation errors upon keyup not ui friendly. an ideal solution display error messages on blur, along on form submit. once input blurred on first time , error message displayed, input need updated on keyup/model change. i have seen following allows model updated upon blur, not ideal solution since model updated on blur every situation. <input type="text" name="user" ng-model="user" ng-model-options="{ updateon: 'blur' }" required> i came across following solution works on blur , changes keyup after error exists. although validation not apply on form submit. http://plnkr.co/edit/vspoyo16ozq2bkall3n9?p=preview here can have 1 angular scope variable maintain state of form submit submitted or not default variable false . $scope.submitted = false; and 1 scope function validate fields on form submit. keep in mind place name attribute of...

algorithm - why '*' faster than hash find, c++ -

i learnt data structure, can tell me why hash slow, thank you! this problem leetcode: https://leetcode.com/problems/happy-number/ bool ishappy(int n) { unordered_map<int, int> m; m[0] = 0, m[1] = 1, m[2] = 4, m[3] = 9, m[4] = 16, m[5] = 25,\ m[6] = 36, m[7] = 49, m[8] = 64, m[9] = 81; int temp, mark = 0; //temp next n, mark detect circle while(n){ temp = 0; if(n == 1) return true; if(n < 10){ if(mark == n) return false; mark = n; } //calc next n while(n){ temp += (n%10)*(n%10); // 4 ms //temp += m[n%10]; // 8 ms n /= 10; } n = temp; } } why not? hashing efficient because of constant fetch time on average. that's it. there no guarantee it's faster * . note key not directly used key hash table(this called " direct-address table " has own drawbacks). in general, there calcu...

ios - Open Gl ES clipping and Back Face Culling -

i need performance in project back, thought of implementing clipping , later on backface culling. so looking in vertex shader if vertex facing me, if true, render , if not, not. how no render in vertex shader oo same clipping how paint section in vertex shader, or wrong here, quit new open gl , project iphone, opengl es 2.0. vertices don't face front or backward. when 3 or more vertices meet, plan (triangle) make face front or depending on convention (clock/anticlock). you have enable culling , do nothing different in shaders. some apis of interest are: (should more or less same in ios not 100% compliant ogles) gldisable / glenable argument gl_cull_face glcullface argument gl_front, gl_back or gl_front_and_back glfrontface argument gl_cw or gl_ccw

elixir - Start "iex" with loading app, and run command in 1 line -

i want auto build "gulp.js" in node.js. $ iex -s mix -e 'dribbblegif.main' ** (mix) cannot implicitly pass flags default mix task, please invoke instead: mix run i want in 1 line command. load app start "iex" do function (dribbblegif.main) because, want watch file this. chokidar **/*.exs **/*.ex -c 'iex -s mix -e 'dribbblegif.main'' if have other solution auto build, please tell me it. try: iex -s mix run -e "dribbblegif.main"

java - I can't extend Form -

i started using android studio recently, , i'm following this guide can't seen extend form, android studio highlights form in red , gives me option alt+enter. once alt+enter import form, show import java.text.normalizer; but guide show import com.google.devtools.simple.runtime.components.android.form; "alt-enter" give options available on local build. tutorial gives assets , if not placed in project, not work. you should able manually add import: import com.google.devtools.simple.runtime.components.android.form; if fails, assume did not add ".jar" file in tutorial. there several ways add jars (like put in "libs" folder). search , can select works best , should fix problem. once it's imported project, should see import option. if don't manually entering works, maybe restart android studio if happens. either way, should have build @ point, , that's matters.

algorithm - swap two variables. which way is faster? -

let's have 2 integers , b. way faster swapping values? c=a; a=b; b=c;//(edited typo) or a=a+b; b=a-b; a=a-b; or bitwise xor a=a^b; b=a^b; a=a^b; i'll test performance differences when i'll able i'd know now. bitwise? firstly, cannot quantify speed of algorithm independent of program language, compiler , platform on run. algorithm mathematical abstraction. having said that: for typical programming language, and typical compiler, and a typical execution platform, the first version typically faster because typically compile fewer native instructions take less clock cycles execute. first version requires load , save operations. other 2 versions have (at least) same number of loads , saves, , additional arithmetic or bit manipulation instructions. however, not cut-and-dry. the 2nd , 3rd examples performing swap without using temporary variable. might if using temporary variable expensive. might happen on machine didn't provi...

How to fill data in the table when using xml datasource in jasper reports using java? -

i tried finding solutions not find any,and of tables not visible in report. when designing report using ireport gui designer , filling data using java . i have taken jrxml file following location , and have taken xml data source try { jrxmldatasource jrxmlds = new jrxmldatasource("d:\\bhvika\\inputdata11.xml","/xdata/rows/row"); map params = new hashmap(); params.put(jrxpathqueryexecuterfactory.parameter_xml_data_document, document); jasperprint print = jasperfillmanager.fillreport("d:\\bhvika\\jasperrpt3mod11.jasper", params,jrxmlds); jasperexportmanager.exportreporttopdffile(print, "d:\\bhvika\\jasperrpt3mod11.pdf"); jasperviewer.viewreport(print); } catch (jrexception e) { e.printstacktrace(); } by doing getting report every field getting populated in table there no value coming.

vbscript - Read Exit Code from VBS Script through Process in C# -

i'm calling vbs-script c# console application using process class. process script = process.start("cscript", arguments); script.waitforexit() int exitcode = script.exitcode; now want able feedback script tell if got through without problems. i call script using " cscript //b //nologo \path\to\script.vbs " process class. in script, want able return feedback or raise kind of error when database entry not found example. i found out can return error codes using wscript.quit(int) the problem cscript seems return other 0 when can't find file. if file found, process.exitcode 0 when use wscript.quit(1) in script. is there way exit code script or way communicate c# application?

QueryDSL query not cast to object -

i querying querydsl sqlserver. beans generated @ build time using maven. runs fine until try convert results objects themselves. @requestmapping("getabsencecauses") public list<causeofabsences> getabsencecauses() { sqltemplates templates = new sqlservertemplates(); configuration configuration = new configuration(templates); sqlqueryfactory queryfactory = new sqlqueryfactory(configuration, datasource); causeofabsences absence = new causeofabsences("c"); list<causeofabsences> absencecauses = queryfactory.from(absence).list(absence); return absencecauses; } at runtime getting following exception: java.lang.illegalargumentexception: relationalpath based projection can used generated bean types another post says have " need generate bean types described here under bean class generation." but these beans generated maven. there thing can tell maven generate these types? @ moment generating documented: <plu...

c++ - bad access error when pushing back vector -

i have these 2 classes: class card { //class represents card int cardnumber; //the id of card give itse level , suit std::vector<std::string> suits = { "hearts", "spades", "diamonds", "clubs" }; std::vector<std::string> levels { "ace", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "jack", "queen", "king"}; std::string suit; std::string level; public: card(int ncardnumber) { //constructor initiliazes properties of card cardnumber = ncardnumber; level = levels[cardnumber%13]; suit = suits[cardnumber/13]; } void printvalue() { //prints cards level , suit using namespace std; cout << level << " of " << suit << endl; } }; and class hand { //represents hand player holding int playe...

How to align Column Header Text in to left Datagridview Windows Form C# -

Image
[![enter how align header text in left, 1 try playing padding of header , rows: this.columnheadersdefaultcellstyle.padding = new padding(0); this.rowsdefaultcellstyle.padding = new padding(5);

node.js - How to run project based on Nodejs, when getting message like Unresponsive script? -

Image
when run nodejs project, message unresponsive script i got 1 project on git-hub based on angularjs-rickshaw . based on nodejs, bower. project: ngyewch/angular-rickshaw demo of above project: demo i want run above project on local system. installed every thing (nodejs, npm, bower). when type http://localhost:3000/ nothing, new in nodejs, please me on this. correct url? [neelabh@localhost angular-rickshaw]$ node server.js connect.multipart() removed in connect 3.0 visit https://github.com/senchalabs/connect/wiki/connect-3.0 alternatives connect.limit() removed in connect 3.0 server running @ http://localhost:3000/ i getting following type of message if ran 1. http://localhost:3000/ or 2. http://localhost:3000/#/home server.js 'use strict'; var fs =require('fs'); //for image upload file handling var express = require('express'); var app = express(); var port =3000; var host ='localhost'; var serverpath ='/'; var staticpa...

Most efficient palindrome program for python -

this question has answer here: how check palindrome using python logic 27 answers very new programming , trying solve few project euler problems. know python code identifies palindrome , non-palindrome. efficient way this? please show code find efficient problem. you can checking if string input equal reversed (that's palindrome is). def check_palindrome(s): return s == s[::-1] [::-1] reverses string because -1 tells how many steps go , negative go through string in reverse. if need check if integers palindromes, can do: def check_palindrome(s): return str(s) == str(s)[::-1]

php - Slim framework with raintpl -

i have existing project uses raintpl3 template engine. trying port slim framework 2. q1 : there way make slim use $tpl object render views (via di or other similar approach). i have managed hack way configure create template object within external function should return content slim should echo. earlier not configure tpl configured in init file. when use $tpl->draw('index'); saying template index not found. q2: why can't find template ? : my_app_root_/public/index.php require_once "../init.php"; # fire app $app = new slim\slim(); $app->get('/', function(){echo myns\router\apidefault::showhome();}); $app->get('/hello', function() { echo "get route working."; }); # run slim application $app->run(); : my_app_root_/routes/apidefault.php <?php namespace myns\router; class apidefault { private function __construct( $argument) { throw new \exception("error constructor not allowed...

How do I put plus or minus sign as an x-axis label on a Matlab plot? -

for matlab plots, how place plus or minus sign x tick labels in matlab plot? currently, i'm using these lines of code obtain plus-minus sign (±) values preceding numerical value on x tick labels. x_values = ['+/- 1';'+/- 2']; set(gca,'xticklabel',x_values) you can insert special characters text using tex, or latex, docs here , here : \pm used plus/minus

c++ - Creating an int array with a non-const size -

i'm making plugin game , i've got following problem: i want let user choose radius, since c++ doesn't let me create array variable size can't custom radius. this works fine const int numelements = 25; const int arrsize = numelements * 2 + 2; int vehs[arrsize]; //0 index size of array vehs[0] = numelements; int count = get_ped_nearby_vehicles(player_ped_id(), vehs); but dosen't: int radius = someothervariableforradius * 2; const int numelements = radius; const int arrsize = numelements * 2 + 2; int vehs[arrsize]; //0 index size of array vehs[0] = numelements; int count = get_ped_nearby_vehicles(player_ped_id(), vehs); is there possible way of modifing const int without creating errors in int vehs[arrsize]; ? array sizes must compile-time constants in c++. in first version, arrsize compile-time constant because value can calculated during compile-time. in second version, arrsize ...

ios - WhatsApp NSURL returning nil When sharing text - Swift -

i'm trying share text whatsapp nsurl returning nil text encoded right ! take @ code : var msg : nsstring = "to world of none"; var titlewithoutspace = msg.stringbyaddingpercentescapesusingencoding(nsutf8stringencoding) var urlwhats = nsstring(string: "whatsapp://send?text=\(titlewithoutspace)") println(urlwhats) var whatsappurl = nsurl(string: urlwhats string) println(whatsappurl) when printing result string equal : whatsapp://send?text=optional("to%20the%20world%20of%20none") and whatsappurl returning nil : nil stringbyaddingpercentescapesusingencoding: returns optional string that's why urlwhats contains optional("") . avoid need unwrap optional : var msg: nsstring = "to world of none"; var titlewithoutspace = msg.stringbyaddingpercentescapesusingencoding(nsutf8stringencoding) if let titlewithoutspace = titlewithoutspace { var urlwhats = nsstring(string: "whatsapp://send?text=\(titlewithout...

.net - Nuget package for bitly to shorten the links -

i need shorten links using bitly in c#. there nuget package this? can 1 provide me code can use that. check out https://www.nuget.org/packages/bitlyapi/ or make own call bit.ly api. api easy use , work with. public string shorten(string longurl, string login, string apikey) { var url = string.format("http://api.bit.ly/shorten?format=json&version=2.0.1&longurl={0}&login={1}&apikey={2}", httputility.urlencode(longurl), login, apikey); httpwebrequest request = (httpwebrequest)webrequest.create(url); try { webresponse response = request.getresponse(); using (stream responsestream = response.getresponsestream()) { streamreader reader = new streamreader(responsestream, encoding.utf8); javascriptserializer js = new javascriptserializer(); dynamic jsonresponse = js.deserialize<dynamic>(reader.readtoend()); string s = jsonresponse["results"][longurl]...

How to select only this text node using BeautifulSoup and Python? -

i have html stucture : <div class="foo"> <h3>title</h3> <br>some text want retrieve. <br><br> text too. <br> (numbers , position of "br" tag indetermined) , 1 too. <div class="subfoo">some other text don't want.</div> </div> in python script, have written : examplesoup = bs4.beautifulsoup(res.text, "html.parser") elems = examplesoup.select('.foo') print(elems[0].gettext()) as expected whole text : title text want retrieve. other text don't want. how string in div has no tag around ie : "some text want retrieve. text too. , 1 too." ? help. you can use .next_sibling next element in tree. example >>> soup = beautifulsoup(html) >>> print soup.prettify() <html> <body> <div class="foo"> <h3> title </h3> text want retrieve. <div class="su...

xamarin - Could not load type 'Android.OS.BaseBundle" -

i'm using xamarin android. without doing changes project i'm getting error: unhandled exception: 07-18 01:29:39.812 i/monodroid( 1901): system.typeloadexception: not load type 'android.os.basebundle' assembly 'mono.android, version=0.0.0.0, culture=neutral, publickeytoken=84e04ff9cfb79065'. 07-18 01:29:39.812 i/monodroid( 1901): @ android.support.v4.app.fragment.n_oncreateview_landroid_view_layoutinflater_landroid_view_viewgroup_landroid_os_bundle_ (intptr,intptr,intptr,intptr,intptr) <0x0009b> 07-18 01:29:39.812 i/monodroid( 1901): @ (wrapper dynamic-method) object.92b95183-96c6-4c05-8b2f-e6402eece616 (intptr,intptr,intptr,intptr,intptr) <0x0003b> the problem pretty stupid. in visual studio solution have multiple android projects. each project set compile android 4.4. after rebuild xamarin tools decided change version of projects android 5.0. why? because xamarin. that's why. after reverting version android 4.4 worked! ho ...

php - These code working on my local but not working on hosting -

i have coded script main page of filejoker.net. run code on local host (xampp) not working same code on webhost. in local, shows main page source in webhost returns me blank page. codes; <?php function curl($url,$cookie = 0,$post = 0,$header = 1,$follow = 0,$proxy = 0){ $ch = curl_init($url); curl_setopt($ch,curlopt_returntransfer,1); curl_setopt($ch,curlopt_useragent,'mozilla/5.0 (windows nt 6.1; rv:5.0) gecko/20100101 firefox/5.0'); curl_setopt($ch,curlopt_cookiejar,"ck.txt"); curl_setopt($ch, curlopt_referer,$url); curl_setopt($ch,curlopt_cookiefile,"ck.txt"); if($cookie) curl_setopt($ch,curlopt_cookie,$cookie); if($post){ curl_setopt($ch,curlopt_post,1); curl_setopt($ch,curlopt_postfields,$post); } if($header) curl_setopt($ch,curlopt_header,1); if($follow) curl_setopt($ch,curlopt_followlocation,1); curl_setopt($ch, curlopt_ssl_verifypeer, 0); curl_setopt($ch, curlopt_ssl_verifyhost, 0); if($proxy) curl_setopt($ch,curlop...

c# - Writing overloaded web service methods -

i have web service method following signature. [webmethod] public void start(string application, string version){} due additional requirements, method has receive additional parameters @ same time support other clients not have latest version yet. ended writing 2 overloaded methods [webmethod(messagename="start", description="start", enablesession=true)] public void start(string application, string version){} [webmethod(messagename="startv2", description="startv2", enablesession=true)] public void start(string application, string version, string exception){} with scenario, ended writing duplicate code. code in startv2 method same start additional code processing additional parameters. in near future, believe additional parameters added again , need write overload method again. is there way write without duplicating codes? you have single method optional parameters, webmethods can call so: [webmethod(messagename=...