Posts

Showing posts from May, 2012

socket.makefile issues in python 3 while creating a http proxy -

from socket import * import sys # create server socket, bind port , start listening tcpsersock = socket(af_inet, sock_stream) serverport = 12000 tcpsersock.bind(('', serverport)) tcpsersock.listen(1) print ("server ready") while 1==1: # start receiving data client. e.g. request = "get http://localhost:portnum/www.google.com" tcpclisock, addr = tcpsersock.accept() print ('received connection from:', addr) request = str(tcpclisock.recv(1024).decode()) print ("requested " + request) # extract file name given request filename = request.split()[1] print ("file name " + filename) fileexist = "false" filetouse = "/" + filename print ("file use: " + filetouse) try: # check wether file exist in cache. open fail , go "except" in case file doesn't exist. similar try/catch in java f = open(filetouse[1:], "r") outputdata = f...

php - array to string conversion error in codeginiter in controller -

$data = array('first_name' => $this->input->post('fname'), 'middle_name' => $this->input->post('mname'), 'last_name' => $this->input->post('lname'), 'email_name' => $this->input->post('email'), 'pwd_name' => $this->input->post('pwd'), 'cno_name' => $this->input->post('cno'), 'gender_name' => $this->input->post('gender'), 'country_name' => $this->input->post('country'), 'lang_name' => $this->input->post('lang') ); echo $data; i want echo or print $data, showing error severity: notice message: array string conversion method 1 foreach($data $key => $val) echo($key.' => '.(is_array($val)?implode(',', $val):$val).'<br>'); method 2 var_dump($data); method 3 print_r($data); ...

Running multiple Gradle commands in parallel on Linux shell -

please note: although 2 primary techs in question spring boot , gradle, think linux/command-line question @ heart, involving fore- , background processes! i'm trying spring boot app run in hot swap ("dev") mode via gradle . after reading this interesting dzone article , takes few easy steps: make minor tweaks build.gradle open terminal , run ./gradlew build --continuous ; wait finish/start up open second terminal , run ./gradlew bootrun voila! can make code changes jvm classes , hot-recompiled on fly , picked spring boot app. hooray fast dev cycles! however i'm trying improve upon wee bit. i'd run single shell script (e.g. rundevmode.sh ) , have both these processes spun me in correct order. tried: ./gradlew build --continuous & ./gradlew bootrun && fg i put inside rundevmode.sh , ran sh rundevmode.sh . see both tasks starting without errors, when make code changes java classes, don't see changes picked up. ideas i'm go...

How to hide the number on the constellation points in MATLAB? -

Image
this how plot constellation: hmod = comm.rectangularqammodulator('modulationorder',32, ... 'symbolmapping','binary'); constellation(hmod) but how hide numbers above each constellation point? i looked on mathworks website did not find looking for. the following code job: hmod = comm.rectangularqammodulator('modulationorder',32, ... 'symbolmapping','binary'); constellation(hmod) delete(findobj(gca,'type','text')); its output is:

Compare each pair of dates in two columns in python efficiently -

i have data frame column of start dates , column of end dates. want check integrity of dates ensuring start date before end date (i.e. start_date < end_date).i have on 14,000 observations run through. i have data in form of: start end 0 2008-10-01 2008-10-31 1 2006-07-01 2006-12-31 2 2000-05-01 2002-12-31 3 1971-08-01 1973-12-31 4 1969-01-01 1969-12-31 i have added column write result to, though want highlight whether there incorrect ones can delete them: dates['correct'] = " " and have began check each date pair using following, dataframe called dates: for index, row in dates.iterrows(): if dates.start[index] < dates.end[index]: dates.correct[index] = "correct" elif dates.start[index] == dates.end[index]: dates.correct[index] = "same" elif dates.start[index] > dates.end[index]: dates.correct[index] = "incorrect" which works, taking really ...

Read xml content into ListView items -

i wanna read out written texts in xml file. these texts should displayed in listview item. example: my xml-file contains wanna displayed first item this text should read out , put item. is there simple solution or tutorial? thanks!

Bundle prebuilt Realm files from Xamarin -

Image
i've seen few posts detailing how bundle prebuilt realm files ios (obj-c/swift) , android (java), can't find information on bundling xamarin pcl or shared project; possible? i believe require per-project *.realm file (e.g. copied single source @ compile time) due nuances of how files distributed in each platform, that's small price pay able access prebuilt data shared code on both platforms. my objective avoid initial download process when launching app first time. you can add pre-populated .realm database application ios bundle resource ( bundleresource build action) , raw asset android asset directory ( androidasset build action). using xamarin.forms -based journal example realm can add populated database linked item each native project , copy @ application startup. example: in ios "native" project of xamarin.form solution/application, update finishedlaunching method copy pre-populated database if users database not exist (i.e. firs...

java - JDialog/OptionPane with big custom buttons with icons -

Image
i relatively new java , i'm struggling in following picture, background colors of buttons not matter, colored show different: the layout gridlayout (with spacing set in constructor). create jpanel use grid layout in. add panel jdialog . job done.

android - Google Play publish app -

this first time going publish app android in google play store , can imagine green. question after submitting app aproval published straight away if aproved or have option submitt app on time store? reason have database feeds app needs updated before go live website know if app aproved or not can plan timming. hope experienced developers shine light on this... many thanks. for timed publishing can go through following steps. publish timed publishing step 1: turn on timed publishing go google play developer console. select app. near top of screen, select publishing mode drop-down drop-down arrow. default, you'll see "standard publishing." select turn on timed publishing. review details timed publishing, click turn on. after you've made update,click submit update. update processed usual. can take few hours. to review update, click view change log. step 2: publish app update once update has been processed , you're ready publish, sel...

javascript - Create d3.js graph from data on mongodb server -

Image
how can create d3.js graph data on mongodb server using node.js? d3.js includes ways request non-local data either json or text (csv) via urls , such. in setup not security sensitive (like local development or demo environment) directly use mongo rest api if enable it, give json output objects. or write build simple http server (like in python , perl or go ) execs ( python (also subprocess ), perl (also backticks , qx{} ), go ) mongoexport tool right parameters provide csv output mongo. if have data in mongo, , you've got node setup, maybe that's want use: ⇒ ⇒ if so, there's someone out there that's used node.js® npm modules mongodb® drive d3.js® visualization.

javascript - Remove spaces between drawn images on canvas -

Image
when place set of images in canvas, there empty lines between them: and noticed lines may or may not disappear depending on zoom level. images 64x64 , placed on y 0, 32, 64 , subsequently , scaled 32x32 .

unexpected output using regex on sed in unix -

echo "abc123" | sed s/[a-z]*/text/g for above command output text1text2text3text should not texttexttext123 ? it because using quantifier * matches 0 or more of [a-z] . first matches abc , due use of g (global) mode matches empty text after 1 , 2 , 3 well. however if tweak regex removing * using; echo "abc123" | sed 's/[a-z]/text/g' then wil get: texttexttext123

Ninject for Web Api 2 is not working in ASP.NET MVC -

i developing asp.net mvc application. in application, need provide rest api. added web api 2 existing mvc application. before added web api 2, using ninject dependency injection. installed via nuget package. whole website developed , working. problem started when added web api 2 project. ninject mvc cannot used web api. installed ninject web api 2. ninjectwebcommon class has been changed after installed it. this ninjectwebcommon file in app_start folder [assembly: webactivatorex.preapplicationstartmethod(typeof(ayardirectory.web.app_start.ninjectwebcommon), "start")] [assembly: webactivatorex.applicationshutdownmethodattribute(typeof(ayardirectory.web.app_start.ninjectwebcommon), "stop")] namespace ayardirectory.web.app_start { using system; using system.web; using microsoft.web.infrastructure.dynamicmodulehelper; using ninject; using ninject.web.common; public static class ninjectwebcommon { private static reado...

html - Issue with white space -

i have no idea why there white space between contact , data under it. tried 0px margin everywhere white space still there. idea how solve? css: http://pasted.co/7d58de85 thanks a screenshot of part reffering to <header> <section id="logo"> <img src="logo2.png" id="logoimg" alt="logo"> </section> <nav> <ul> <a href="#top"><li>home</li></a> <a href="#agenda"><li>about me</li></a> <a href="#hettheater"><li>projects</li></a> <a href="#edge2"><li>contact</li></a> </ul> </nav> <footer> <p id="contactgegevens"> xxxxxx xxxxxxx xxxxxxxxx@hotmail.com tel: x...

java - JavaFX css class style -

how can set css style class extends javafx object? public class diagrampane extends scrollpane implements idiagrameditor { // .... methods go here } i've tried following ways in main method: public class diagrampane extends scrollpane implements idiagrameditor { diagrampane() { this.setstyle("-fx-background-color: #f8ecc2;-fx-font-size: 8pt;"); setstyle("-fx-background-color: #f8ecc2;-fx-font-size: 8pt;"); } } add these lines css file .diagram-pane { -fx-background-color: #f8ecc2; -fx-font-size: 8pt; } and set diagrampane instance use diagram-pane style class diagrampane.getstyleclass().clear(); diagrampane.getstyleclass().add("diagram-pane");

android - error while connecting kivy app with bluetooth. -

i'm using windows 7 , python 2.7, i'm trying connect kivy app bluetooth i'm getting error message. please explain. *traceback (most recent call last): file "bluetooth.py", line 15, in <module> bluetoothadapter = autoclass('android.bluetooth.bluetoothadapter') file "build\bdist.win-amd64\egg\jnius\reflect.py", line 154, in autoclass file "jnius\jnius_export_func.pxi", line 25, in jnius.find_javaclass (jnius\jnius.c:16263) jnius.javaexception: class not found 'android/bluetooth/bluetoothadapter'* the code you're showing you'd run on android access bluetoothadapter class. windows doesn't have (or of rest of android api), fails. if want use bluetooth on windows, find windows platform specific way of doing (this unlikely involve pyjnius).

angularjs - Angular - Use $sanitize on every input -

on server side sanitise coming in. on angular app client side i've done same in instances e.g. contact forms thinking shouldn't apply every input field? so i've seen $sanitize('some string') there way apply @ top app level rather having enter every instance input fields is? (assuming wise thing - if not keen hear suggestions). thanks. you can create directive call "input", apply inputs of app. inside directive can add parser $ngmodel apply automatically $sanitize when value changes. it looks this: myapp.directive('input', function($sanitize) { return { restrict: 'e', require: '?ngmodel', link: function (scope, element, attrs, ngmodel) { if(ngmodel !== undefined){ ngmodel.$parsers.push(function(value){ return $sanitize(value); }); } } }; });

regex - Why the following variations of s/g from command line are wrong? -

i have small file follows: $ cat text.txt vacation cat test this command substitutes occurrences of cat cat correctly wanted: $ perl -p -i -e ' s/cat/cat/g; ' text.txt but why following 2 mess file up? following deletes contents of file $ perl -n -i -e ' $var = $_; $var =~ s/cat/cat/g; ' text.txt and 1 not substitution correctly $ perl -p -i -e ' $var = $_; $var =~ s/cat/cat/g; ' text.txt $ cat text.txt cation cat test why? messing here? -p prints out each line automatically (the contents of $_ , contains current line's contents), re-populates file (due -i flag in use), -n loops on file -p does, doesn't automatically print. have yourself, otherwise overwrites file nothing. -n flag allows skip on lines don't want re-insert original file (amongst other things), whereby -p , you'd have use conditional statements along next() etc. achieve same result. perl -n -i -e ' $var = $_; $var =~ s/cat...

c++ - OpenCV image recognition - setting up ANN MLP -

i new in opencv world , neural networks have coding experience in c++/java. i created first ann mlp , learned xor: #include <opencv2/core.hpp> #include <opencv2/imgcodecs.hpp> #include <opencv2/highgui.hpp> #include <opencv2/imgproc/imgproc.hpp> #include <opencv2/ml/ml.hpp> #include <iostream> #include <iomanip> using namespace cv; using namespace ml; using namespace std; void print(mat& mat, int prec) { (int = 0; i<mat.size().height; i++) { cout << "["; (int j = 0; j<mat.size().width; j++) { cout << fixed << setw(2) << setprecision(prec) << mat.at<float>(i, j); if (j != mat.size().width - 1) cout << ", "; else cout << "]" << endl; } } } int main() { const int hiddenlayersize = 4; float inputtrainingdataarray[4][2] = { ...

c# - Xamarin.Android Service doesnt restart on Reboot "App Stopped" Message -

i using service alarmmanager every 30 minutes triggers "service receiver" used scheduling notification.for purpose of testing have lowered interval.my app , service runs fine , able deliver notifications.however after reboot service stops abruptly , message delivered saying "app stopped working". i have written code inspired here , here , many other questions , have been trying solve issue past 12 hours.i suspect issue in rebootreceiver or manifest. code simple , works others. my app manifest : <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="namaz_pro.namaz_pro" android:versioncode="1" android:versionname="1.0" android:installlocation="preferexternal"> <uses-sdk android:minsdkversion="17" /> <uses-permission android:name="android.permission.access_fine_location" /...

python - SQLalchemy - 'AppenderQuery' object has no attribute 'serialize' -

so, i'm making json return property in 1 of classes, error when trying use 1 of properties: class posts(base): __tablename__ = 'posts' post_id = column(integer, nullable = false, primary_key = true) text = column(string, nullable = false) date = column(datetime(timezone=true), server_default=func.now()) deleted = column(integer, default = 0) owner = column(integer, foreignkey('users.id')) owner_rel = relationship('users') comments_rel = relationship('comments', cascade='all, delete-orphan', lazy='dynamic') @property def serialize(self): # returns data object in proper format return { 'postid': self.post_id, 'text': self.text, 'date': self.date, 'owner': self.owner, 'postowner': self.owner_rel.serialize, 'comments': self.comments_rel.serialize } ...

Terraform lookup not working -

i trying lookup map variable gives error. here few snippets of code. variables.tf variable "count" { default = 2 } variable "providers" { default = { "0" = "aws" "1" = "aws.west" } } main.tf resource "aws_key_pair" "default" { count = "${var.count}" provider = "${lookup(var.providers, count.index)}" .... .... } output of terraform apply error configuring: .. error(s) occurred: .... * aws_key_pair.default: provider ${lookup(var.providers, count.index)} couldn't found .... .... how can resolve ? nothing wrong syntax here, looks provider not valid parameter aws_key_pair resource, valid pamams (key_name , public_key). https://www.terraform.io/docs/providers/aws/r/key_pair.html

clock - Modulo algorithm proving elusive -

i have color-wheel maps color each hour on 24-hour clock. given hour of day, want map colors 12-hour clock such colors 5 hours before , 6 hours after current hour used. gets bit tricky b/c 0th index of result has 0th color or 12th color of 24 color-wheel. for example, given colors24 array of 24 colors , hour time of 5 final color12 array map colors24's indexes as: {0,1,2,3,4,5,6,7,8,9,10,11} if hour 3, then: {0,1,2,3,4,5,6,7,8,9,22,23} and if hour 9, then: {12,13,14,15,4,5,6,7,8,9,10,11} bonus points if algorithm can generalized 2 arrays regardless of size long first evenly divisible second. if hours total number of hours (24), length number of colors displayed @ time (12), , hour current hour, generic algorithm indexes color array: result = []; add = hour + hours - (length / 2) - (length % 2) + 1; (i = 0; < length; i++) { result[(add + i) % length] = (add + i) % hours; } here javascript implementation (generic, can used other ranges 24/12...

mysql - How to modify my query for the below requirement? -

this query can order_seq_num 2 want value column test_group_id t_patient_mhc_step_group_mapping selected order_seq_num if order_seq_num selected row value 2 in t_patient_mhc_step_mapping . select if((labrep.lab_status_id = 2 && labrep.mhc_status = 'mhc'), min(stepmap.order_seq_num) + 1, min(stepmap.order_seq_num)) step_order_seq_num `t_patient_mhc_step_group_mapping` stepgroup inner join t_patient_mhc_step_mapping stepmap on stepgroup.step_id = stepmap.step_id , stepmap.mhc_step_status = 1 inner join `t_patient_mhc_mapping` mhcmap inner join `t_lab_test_report` labrep on labrep.op_ip_appt_id = mhcmap.appt_id mhcmap.appt_id = 81

c# - EntityType 'Worker' has no key defined. Define the key for this EntityType -

my code in solution.models.worker : using system; using system.collections.generic; using system.linq; using system.web; using system.data.entity; namespace solution.models { public class worker { public int asmenskodas { get; set; } public string vardas { get; set; } public string pavarde { get; set; } public datetime gimimodata { get; set; } public string adresas { get; set; } public bool aktyvumopozymis { get; set; } } public class workerdbcontext : dbcontext { public dbset<worker> worker { get; set; } } } i changed web.config file adding <connectionstrings> <add name="workerdbcontext" connectionstring="data source=(localdb)\mssqllocaldb;attachdbfilename=|datadirectory|\workers.mdf;integrated security=true" providername="system.data.sqlclient"/> </connectionstrings> and when try add controller "mvc 5 controller ...

javascript - JQuery custom calendar -

i kind of want create calendar can see here: http://fullcalendar.io/ i want have time x-axis , different names y-axis. created own version using jquery ui slider: http://rockaholics-cologne.de/root/timetable.php using slider doesn't feel optimal approach. not asking code here. maybe can tell me for. want create these resizeable bars seen in first link , have them in layout seen in second link. i can't find right keywords google maybe have idea? thanks! :d this fiddle here give groundwork resizable divs http://jsfiddle.net/nick_craver/bx2mk/ think looking . enter code here $("#resizable").resizable({ handles: 'e, w' }); #resizable { width: 150px; height: 50px; padding: 0.5em; } #resizable h3 { text-align: center; margin: 0; } <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/overcast/jquery-ui.css" rel="stylesheet"/> <script src="https://ajax.googleapis.com/ajax/lib...

URL Fetch Google Compute Engine from App Engine (Standard Env) -

i have application running on app engine standard environment (java) , elasticsearch running on compute instance both belonging same project. how can access instance in "secure way", e.g internal ip. enabled tcp:9200 port in firewall rules. thanks in advance! if open cloud console, , navigate app-engine's instances page, there can find internal ip each instance. you can via command line if have gcloud installed. gcloud compute instances list this ip internal project , can accessed other compute engine instances in project.

c# - SQL Server weirdest error ever -

the c# code: sqlconnection c; string str = "data source =(localdb)\\mssqllocaldb;"; str += "attachdbfilename=|datadirectory|\\dinodata.mdf;"; str += "integrated security= true"; c = new sqlconnection(str); if (session["connect"] != null) { if ((bool)session["connect"]) { logdiv.visible = false; usernamec.innerhtml = (string)session["curentuserid"]; connected.visible = true; sqlcommand exp = new sqlcommand("select xp from[user] username = @username", c); exp.parameters.addwithvalue("@username", (string)session["curentuserid"]); c.open(); session["exp"] = exp.executereader(); c.close(); int b = (int)session["exp"] / 2; string = b + "px"; xp.style.add("width", ((string)session["exp"])+"%"); } else { connected.visibl...

input - sc.textFile scala error -

i trying read file path i've written file at. following documentation using following line of code: val data = sc.textfile(path) this give compilation error: not found: value sc. i found solutions involve commands should given in terminal, in case using eclipse. there way resolve issue importing library or this? thank you! you need create spark context first. for example: val conf = new sparkconf().setappname(appname).setmaster(master) val sc = new sparkcontext(conf) when using spark shell there no need create spark context, because created you, in variable called sc. you can read more spark context initialization there .

c# - Blocking a user in ASP.NET using timeout -

i trying make login page using asp.net. want block user 5 minutes after 3 failed login attempts. didn't use login control in page,so guess can't use membership provider. want following: set counter 0 , bool called accept_login true every time validatepassword function returns 0,the counter increments when counter 's value 3, set accept_login on false,reset counter , start timeout 5 minutes below code wrote without implementing these things. me integrate them? thanks! using system; using system.collections.generic; using system.linq; using system.web; using system.web.ui; using system.web.ui.webcontrols; using system.data.sqlclient; using system.configuration; using system.data; using bcryptlibrary; using system.web.security; namespace bootstrapregisterlogin { public partial class login : system.web.ui.page { protected void page_load(object sender, eventargs e) { ...

Python buffer copy speed - why is array slower than string? -

i have buffer object in c++ inherits std::vector<char> . want convert buffer python string can send out on network via twisted's protocol.transport.write. two ways thought of doing (1) making string , filling char char: def scpychar(buf, n): s = '' in xrange(0, n): s += buf[i] return s and (2) making char array (since know how big buffer is), filling , converting string def scpyarr(buf, n): = array.array('c','0'*n) in xrange(0, n): a[i] = buf[i] return a.tostring() i have thought (1) has make new string object every time s += buf[i] called, , copy contents of old string. expecting (2) quicker (1). if test using timeit, find (1) twice fast (2). i wondering if explain why (1) faster? bonus points more efficient way convert std::vector<char> python string. cpython can optimize string += in-place if can determine no 1 keeping reference old string. algorithm (1) triggered optimizati...

Python 3.5 convert values during re-write to new csv -

i have csv file writing file, in process want change values based on greater or less than. example, in column in new file (row 2 old one) want transform data number word, depending on value in column. actual data has more columns, , thousands of lines, not exceeding 10k lines. example below: input.csv duck,35,35 car,100,502 baseball,200,950 gun,500,495 taco,300,300 guitar,100,700 barbie, 200,25 gum,300,19 desired output.csv duck,35,35,order car,100,502,order next month baseball,200,950,no order necessary gun,500,495,order next month taco,300,300,order next month guitar,100,700,order next month barbie, 200,25,order urgent gum,300,19,order urgent this code far, i'm having trouble conversion of amount new value. think need use enumerate, haven't found examples in research of csv conversion method. please assist. import csv open('interim results.csv', 'r') source: rdr = csv.reader(source) open('interim results fixed.csv', 'w', n...

c# - ASP.NET repository get id after insert -

how can id after insert() command. here code. private readonly irepository<shoppingcart> _shoppingcartrepository; public shoppingcartbl(irepository<shoppingcart> shoppingcartrepository) { _shoppingcartrepository = shoppingcartrepository; } public int createnewshoppingcart(shoppingcart item) { if(item==null) throw new argumentnullexception("shoppingcart variable"); this._shoppingcartrepository.insert(item); return this._shoppingcartrepository.table.last().id; } this part gives error: return this._shoppingcartrepository.table.last().id; i need id of inserted item. thanx after have inserted entity should updated property maps primary key in database has new pk value. like in case item.id give new id

Typescript: Specify type in object declaration -

var = { b:null, } i want specify type of a.b (num:number) => void while still setting null . is possible without using class or interface? this should work: let = { b: <(number) => void> null }; or can use type declaration make special function explicit: declare type myfun = (number) => void; let = { b: <myfun> null }; although it's not necessary, tend make use of type declarations in code when there function has semantics not caught in type signature, can specified in name.

python - I can't access QuerySet in Manager's init method in Django -

i'd queryset of model in manager's __init__ method setup pagination queryset results. reason why want setup pagination in __init__ method because have lots of simple methods in manager getpage , getnumberofpages etc. simplify abstraction , don't want duplicate code setup paginator across these methods. for example, let's there article model, has custom articlemanager , looks this: class articlemanager(models.manager): def __init__(self): super(articlemanager, self).__init__() allobjects = super(articlemanager, self).get_queryset() self.articlepaginator = paginator(allobjects, 10) class article(models.model): # blah blah # model fields everywhere objects = articlemanager() fourth line of code super(articlemanager, self).get_queryset() returns attributeerror exception: attributeerror: 'nonetype' object has no attribute '_meta' i guess should have done more initialize manager, i'm not sure...

html - I made a webpage but have excess white space at the bottom, how do I get rid of this? -

screen shot of webpage excess white space @ bottom i have created webpage there excess white space @ thee bottom not know how rid of. feel though has width , height of either body or main section in css file not sure. here code css file. body { background: url('black_gradient.png')repeat-x; text-align: center; height: 800px; } #main{ width: 1000px; height: 1000px; background: url('brown gradient.jpg')repeat-x; margin: 25px auto; border: solid 2px #ff3819; border-bottom: solid 0px; padding: 10px; } h1{ text-align: center; font-family:"times new roman"; font: 24pt; color: #000000; } hr { height: 2px; color: #000000; } p { font-family:"calibri"; font-size: 12pt; text-align: left; text-indent: 48px; color: #000000; } remove height body , #main or set them auto

java - Blank screen when running cocos-2d empty example -

Image
first here versions running cocos2d-x-3.11 android sdk (5.1.1 or 3.1.1 have same effect) ant 1.9.7 eclipse java 1.8 ndk r10c python 2.7.5 i trying sample projcet located in cocos2d-x-3.11/tests/cpp-empty-test work. believe when running (by looking @ code) should pop generic "hello-world" program, on device shows blank screen. steps did project running open eclipse import directory in c:\androidprogramming\cocos\cocos2d-x-3.11\cocos\platform\android\java import proj.android c:\androidprogramming\cocos\cocos2d-x-3.11\tests\cpp-empty-test project->build all click cpptest->debug->as android application then project loads onto device. no console errors or anything, screen black. then eclipse shows me wierd thing, , idk, breakpoint new ide me. see no console indication or anything. , app not crash.

c++ - How could you write the "if - then" logic for the game Yacht? -

https://en.wikipedia.org/wiki/yacht_(dice_game) i created 5 dice in c++ program , each roll random numbers 1-6. if 1's simple. it's just: if (dice1 == 1 && dice2 == 1 && dice3 == 1 && dice4 == 1 && dice5 == 1) { int total = 50; } also, summing dice easy too. how write if-statement "if 2 4 dice same sum dice"? there simple way that? try use tables , make variable count 1 in table. u can compare it.

Algorithm for creating a "relative" priority queue? (c/c++) -

i want make queue using linked lists. there numerous algorithms out there that. i'm curious in how make relative priority queue. maybe there special name type of queue, don't know it, , haven't had luck googling solution. anyways, let's have struct, represent node of list. struct node { int value; node* next; } if want create priority queue (where element least value first), when insert example 5 7 1 8 2, list should this: 1 -> 2 -> 5 -> 7 -> 8 it's not hard implement that. want - when insert first element, other elements should have value relative previous element. so, in example, list/queue contain following values: 1 -> 1 -> 3 -> 2 -> 1 i'm not sure how implement that? following idea applicable: in node struct add field, represent original value. find position of node i'm inserting same way when creating ordinary linked list, , say temp->value = temp->originalvalue - previous->originalvalue;...

linux - while read bash array (not into) -

i'm trying use array while read , entire array output @ once. #!/bin/bash declare -a arr=('1:one' '2:two' '3:three'); while read -e ; echo $it done <<< ${arr[@]} it should output each value separately (but doesn't), maybe while read isn't hot ticket here? for case, easier use for loop: $ declare -a arr=('1:one' '2:two' '3:three') $ in "${arr[@]}"; echo $it; done 1:one 2:two 3:three the while read approach useful (a) when want read data file, , (b) when want read in nul or newline separated string. in case, however, have data in bash variable , for loop simpler.

windows phone 7 - Upload image using ASP.NET WebAPI using a model -

i trying upload image windows phone 8 app sql server database using webapi. using model class images, consists of id belonging item image for, name of image , byte array hold image itself. use webclient object access webapi method. when try upload image, throws exception shown below. have idea why errors? also, open other methods of storing image sql database. having look! code private memorystream photostream; ... private void upload() { try { images image = new images(); image.imagesbytes = photostream.toarray(); image.imagesid = 3; image.imagescaption = "this test"; string jsondata = jsonconvert.serializeobject(image); webclient webclient = new webclient(); webclient.headers["content-type"] = "application/json"; webclient.encoding = encoding.utf8; uri uri = new uri(...

html - Align three divs -

i trying align 3 divs across page 1 staying center , others of equal spacing apart. have think of code need cant seem spacing work. #partnerships div { height: 600px; width: 100%; margin-left: 10px; margin-top: 10px; padding: 10px; float: left; background-color: #000000; color:#ffffff; border-radius: 15px 15px 15px 15px; } #robe {float:left; width:100px;} #avolites {float:right; width:100px;} #ukproductions {margin:0 auto; width:100px;} <div id="partnerships div"> <div id="robe"> <h1>robe</h1> <p></p> <a href="http://www.robe.cz/" target="_blank"> <img src="" alt="robelogo" height="100" width="200" > </a> </div> <div id="avolites"> <h1>avolites</h1> ...

vb.net - VB net and postgres : Getting "An operation is already in progress" using npgsql -

i'm using following code retrieve list of objects (products) , list (sizes) inside of them. dim l new list(of entidades.producto) dim c new npgsqlcommand("select id, name product", cn) dim r npgsqldatareader = c.executereader while r.read dim p new entidades.product p.id = r.item("id") p.name = r.item("name") l.add(p) >>> had other loop here having same issue tried put reader outside of loop. loop r.close() each p in l c = new npgsqlcommand("select t.id id, t.name nombre productsize pt join size t on t.id = pt.sizeid productid = :productid order ord", cn) c.parameters.addwithvalue("productid", pgsqltypes.npgsqldbtype.integer, p.id) c.prepare() <---- here error dim rt npgsqldatareader = c.executereader while rt.read dim t new size t.id = rt.item("id") t.nombre = rt.item("name") p.size.add(t) loop next re...

algorithm - Dijkstra with Parallel edges and self-loop -

Image
if have weighted undirected graph no negative weights, can contain multiple edges between vertex , self-loops, can run dijkstra algorithm without problem find minimum path between source , destination or exists counterexample? my guess there not problem, want sure. if you're going run dijkstra's algorithm without making changes graph, there's chance you'll not shortest path between source , destination. for example, consider s , o. now, finding shortest path depends on edge being being traversed when want push o queue. if code picks edge weight 1, you're fine. if code picks edge weight 8, algorithm going give wrong answer. this means algorithm's correctness dependent on order of edges entered in adjacency list of source node.

IDE, Framework, code manager tool, thing that supports Java and C++ in one Project -

i have inherited else's code. used cmake build fragments c++ , fragments java/android. cannot believe have used notepad , windows explorer manage package/class structure , implementation. there code manager tool or ide allows put java code in 1 package , c++ in package? cmake scripts build projects separately, of course. cmake build tool. you can use ide write code , use different tool build it. eclipse supports both java , c++, wouldn't recommend either.

php - Get the id of a WooCommerce category, by name -

i have wp template assign pages. template ie. display woocommerce products have same master category name pages name itself. by far have tried using code, no output: $idobj = get_category_by_slug($pagename); $id = $idobj->term_id; echo ": ". $id; unfortunately, echo not display anything. echoing $pagename works, , returns me slug of page. any way make work? with custom taxonomy recommended use get_term_by() instead : $category = get_term_by( 'slug', $pagename, 'product_cat' ); $cat_id = $category->term_id reference: get category id category slug…

JavaScript OOP: classical implementation odd -

ok, i've revised of techniques implement inheritance in javascript oop. java programmer, i'm interested in classical approach here's problem; want create animal class (i know it's not real class, let me use term) this: function animal(name){ this.name = name; } animal.prototype.getname = function() { return this.name; } it important note concrete class in first intention, want instantiate it, not use superclass. may create several animal instances, each 1 own name. a possible way extend class following: function cat(name, owner) { this.name = name; this.owner = owner; } // alternative 1: cat.prototype = object.create(animal.prototype); // alternative 2: cat.prototype = new animal('lola'); // end of alternatives cat.constructor.prototype = cat; cat.prototype.jump = function() { alert(this.name + " jumping"); } with alternative 1 inherit methods of superclass, in fact need redefine name property in cat....

angular 2 does not trigger callback function after successful google login -

import {component,directive,oninit,ngzone} 'angular2/core'; declare const gapi:any; declare const $:any; @component({ selector: 'mysite', templateurl:'./app/template.html' }) export class test{ userauthtoken; userdisplayname; constructor(private zone: ngzone){ gapi.load('auth2',this.initnow); this.zone.run(() => { console.log(this); $.proxy(this.ongoogleloginsuccess, this); }); } initnow(){ gapi.auth2.init({client_id:'9511021809-qqke9m46imnmrged8u7u66ilj168bi9t.apps.googleusercontent.com'}); } ngafterviewinit() { gapi.signin2.render( this.googleloginbuttonid,{ "onsuccess": this.ongoogleloginsuccess, "scope": "profile", "theme": "dark" }); } public ongoogleloginsuccess(loggedinuser) { this.userauthtoken = logge...

c# - Populate Listbox using DateTimePicker -

i'm trying populate listbox information access, doing right? or missing few things. because when search listbox isn't being populated. i'm using datetimepicker search specific dates , information relating displayed. try { connection.open(); oledbcommand command = new oledbcommand(); command.connection = connection; string query = "select *from booking date=" + datetimepicker1.text + ""; command.commandtext = query; oledbdatareader reader = command.executereader(); while (reader.read()) { listbox1.items.add(reader["cid"].tostring()); listbox1.items.add(reader["vehiclenumber"].tostring()); listbox1.items.add(reader["date"].tostring()); listbox1.items.add(reader["time"].tostring()); } connection.close(); } catch (exception ex) { messagebox.show("error" + ex); } you need proper format string expression of date value: ...

php - What is wrong with my FeatureContext? -

i believe not clear on behatcontext versus minkcontext , not sure why inherit 1 or other in app. not clear on why have instantiate new client object in every function. should able use $this since have goutte loaded in behat.yml file. any tips please? <?php namespace main\referralcapturebundle\features\context; use main\referralcapturebundle\features\context\featurecontext; use symfony\component\httpkernel\kernelinterface; use behat\symfony2extension\context\kernelawareinterface; use behat\minkextension\context\minkcontext; use behat\minkextension\context\rawminkcontext; use behat\behat\context\behatcontext, behat\behat\exception\pendingexception; use behat\gherkin\node\pystringnode, behat\gherkin\node\tablenode; use goutte\client; // // require 3rd-party libraries here: // require_once 'phpunit/autoload.php'; require_once 'phpunit/framework/assert/functions.php'; // /** * feature context. */ class featurecontext extends rawminkcontext /...