Posts

Showing posts from May, 2011

php - MySQL InnoDB AUTO_INCREMENT secondary column -

i making system users can upload file want, , not use execute kind of code. part of that, rename every file, , store original name in mysql table. table contains id of user uploaded it, , unique id of upload. doing this: create table `uploads` ( `user_id` int(11) not null, `upload_id` int(11) not null auto_increment, `original_name` varchar(30) not null, `mime_type` varchar(30) not null, `name` varchar(50) not null, primary key (`user_id`, `upload_id`) ) engine=myisam; this means have unique combination of user_id , upload_id, , every users first upload has id of 1. want use foreign key user_id, if delete user, uploads deleted. means have in innodb. how go that, since above setup works in myisam. my users table (wich user_id from) looks this: create table `".database."`.`users` ( `user_id` int not null auto_increment primary key, `username` varchar(30) not null, `email` varchar(50) not null, `password` char(128) not null...

php - Multiple SQL inserts (number of inserts depending on number of user input) -

i have module on website allows admin add users group. it build (with selectboxes), can select multiple users 1 group: users: group: - user 1 - group 1 - user 2 - group 2 - user 3 - user 4 - user 5 inside php, looks this: $user_id = $_post["user_id"]; //this can array $group_id = $_post["group_id"]; if (count($user_id) == 1) { $sql = "insert ignore users_groups (user_id, group_id) values ($user_id[0],$group_id)"; } elseif (count($user_id) == 2) { $sql = "insert ignore users_groups (user_id, group_id) values ($user_id[0],$group_id), ($user_id[1],$group_id)"; } elseif (count($user_id) == 3) { $sql = "insert ignore users_groups (user_id, group_id) values ($user_id[0],$group_id), ($user_id[1],$group_id), ($user_id[2],$group_id)"; } elseif (count($user_id) == 4) { $sql = "insert ignore users_groups (user_id, group_id) values ($user_id[0],$grou...

javascript - Find Typescript version in the Atom editor and update TypeScript if necessary -

how find version number of typescript installed on windows computer? i'm using atom editor , have atom-typscript package installed. if not date version, how update current version of typescript? since you're using atom-typescript package need update package (on atom's settings->updates screen) newer typescript build. more info can found in faq . the version driven package.json

Node.js alongside .Net libraries -

i'm not sure if question has either been asked or in correct stack site. - let me know if isn't , i'll gladly remove it. i'm .net-stack developer; more specifically, web. enjoy many of tools , frameworks .net has offer. i develop lot javascript, , various frameworks such angular. on last couple of years. as develop more js i'm finding myself intrigued node.js , strengths has. admit, don't know great deal node.js other of typical hello world examples out there. now, rather not have learn whole bunch of other frameworks replace of ones use in .net - such entity framework example. so lead me wonder - there available bridges gap between node , .net. perhaps thought process isn't working correctly, though achieve be: front end angular calling node.js rest api node reaching out business layers built .net i figure this, would/could speed , scale-ability node.js offers keep in many years of experience have .net between rest service , databas...

regex - Replace all text within two strings on different lines using Perl -

i web developer. agency work uses dreamweaver templating/library item features. library items come in handy updating nav bar or piece of content thats same on every page. work static html of time. change menu item, use dreamweaver library item, update item once, press update, , changes across every html page in project. make perl script can run command line instead of opening gui, faster. so example, lets have menu coded this: <!--menuitems--> <li><a href="products.html">products</a></li> <li><a href="about_us.html">about us</a></li> <li><a href="commercial.html">commercial</a></li> <li><a href="contact.html">contact</a></li> <!--menuend--> i store the li items code in own file: nav.lbi: <li><a href="products.html">products</a></li> <li><a href="about_us.html">about u...

c# - MSTest unit test passes when in "debug" mode, but fails final assertion in "run" mode -

hi have unit test goes attaches event , updates counter based on property of eventargs in handler so: protected void updatecounts(object sender, eventargs eventargs) { lock (lockobject) { counts[eventargs.target]++; } } counts static dictionary resource unit tests in class share. assert @ end of test assert count 6 value of target (target enum). when debug through test, passes final assertion, however, when run without breakpoints, count value of target can 7 or 8, never 6. i realize many threads trying access entry in dictionary may present race condition, why placed lock around increment. have testinitialize method runs before every test gets run looks this: [testinitialize] public void inittest() { foreach (targettype x in enum.getvalues(typeof(target))) { counts[x] = 0; } } does have insight going on here? almost every time have run issue boils down race condition less occur when debugging since slowing execution down step through code. ...

Ruby Upgrade permission error(Errno::EACCES) -

i had ruby v1.9 installed ( , running few rails applications, e.g: redmine). wanted install gitlab, required ruby >2.0. installed ruby following this guideline( compiled source). after gitlab installation finished restarted apache, redmine has stopped working. tried running gem install bundler , bundle install both of them gave following error: error: while executing gem ... (errno::eacces) permission denied @ rb_sysopen - /usr/local/lib/ruby/gems/2.1.0/gems/bundler-1.10.5/.gitignore i guessing cannot run them cause in folders root can access. anyway, running sudo didn't solve problem. apache log shows following error: [ 2015-07-22 13:51:30.0223 377/7f2ed6b49700 age/cor/req/checkoutsession.cpp:252 ]: [client 1-82] cannot checkout session because spawning error occurred. identifier of error f16d292b. please see earlier logs details error. app 4932 stderr: *** error ***: cannot execute /usr/bin/ruby1.9.1: no such file or directory (2) app 4932 stdout: [ 2015-07-2...

Copy/rename google sheet, share & get share id with script in form -

is possible script copy/rename (unrelated) google spreadsheet, share given email (preferably testing existence of google account associated given email first), , save shared url? have spent hours , can't find part of answer this: nothing on copying/renaming, nothing on share id. may missing keyword or something. realize i'll downvoted general question, google script support out there, think. if give me thread, i'll follow it. so: had figure out, , hired code snippet me, here's got. works pretty great me. did tiny bit of customization. here's requirement: given 2 google sheets, gtemplate & gtracker (these 2 separate spreadsheets, not tabs in same spreadsheet). create form (that reports tab/sheet in gtracker) user (anyone) fills in online email "useremail", , string "userid". upon submission: 1) make copy of gtemplate, , rename "gtuserid" (if gtuserid exists, name gtuserid1, 2, or whatever) 2) check submitted email has ...

similarity - what is the best way to process multi files in storm -

i new apache storm, want use storm similarity of files. want cosine of of file in folder "a" of file in folder "b". can me show way result. much. i did not understand meant 'cosine of files', in general, can think of each folder 'stream'. can have spouta read-understand-format-emit files in foldera , spoutb same folderb 2 tuple streams (i assuming there differences between 2 folders encoding, formatting etc.). processing bolt can 'subscribe' streams. e.g., bolt.fieldsgrouping(spouta, streamname, new fields("field_in_stream")); bolt.fieldsgrouping(spoutb, streamname, new fields("field_in_stream")); if on other hand, meant 2 different instances of same spout read different folders not great idea, because number of spout executors tied #folders have. not scalable. load distribution pretty bad. if still want it, can use task-index of spout have different spout executors different behavior (different m...

scala - Sequencing both Scalaz WriterT and Either with for-yield -

if have: import scala.concurrent._ import scalaz._, scalaz._ type z = list[string] type f[α] = future[α] type wt[α] = writert[f, z, α] implicit val z: monoid[z] = new monoid[z] { def 0 = nil def append (f1: z, f2: => z) = f1 ::: f2 } implicit val f: monad[f] = scalaz.std.scalafuture.futureinstance i can write code this: def fooa (): wt[int] = writert.put[f, z, int] (f.point (18))(z.zero) def foob (): wt[int] = writert.put[f, z, int] (f.point (42))(z.zero) def foolog (msg: string): wt[unit] = writert.put[f, z, unit] (f.point (()))(msg :: nil)) def foo (): wt[int] = { _: unit <- foolog ("log #1") a: int <- fooa _: unit <- foolog ("log #2") b: int <- foob _: unit <- foolog ("log #3") } yield + b suppose define: type wtt[α] = writert[future, z, throwable \/ α] def flakeyint (i: int): throwable \/ int = new java.util.random().nextboolean match { case false => i.right case true => new exception (...

java - Retrofit GSON Parsing Arraylist Inside of Object -

i have json object this: { products:[ { name:prod1, quantity:3 }, { name:prod2, quantity:1 } ] } i have gson object so: public class product{ @serializedname("name") public string name; @serializedname("quantity") public int quantity; } when set retrofit this @get("/products") void getproducts(callback<arraylist<product>> c); it fail, obviously, because array isn't root object. there simple way force dig down json 1 level before parsing arraylist, or going have create whole gson adapter accomplish this? i accomplished creating , using own custom deserializer. code simpler full gson adapter, accomplishes need. https://google-gson.googlecode.com/svn/trunk/gson/docs/javadocs/com/google/gson/jsondeserializer.html

How to make java TicTacToe table? -

how create 3x3 without changing given method? i need create 4 methods beside main method, stuck on display board. do need create variable or represent each number can use update board each time after user enter move? it's supposed this: 1 2 3 4 5 6 7 8 9 the following main method can't changed. public class tictactoe { public static void main (string args[]) { char[] board = {'1', '2', '3', '4', '5', '6', '7', '8', '9'}; char move = 'o'; displayboard(board); while (!checkwinner(board, move)){ move = changemove(move); makemove(board, move); displayboard(board); } from code provided, looks given board . it is: char[] board = {'1', '2', '3', '4', '5', '6', '7', '8', '9'}; what want turn in 3x3 display. this simple as: int k =0; char[] ...

python 2.7 - Loading treebank corpus with brown's tagset -

i have wsj treebank corpus nltk. want load tagset of brown corpus. possible? import nltk wsj = nltk.corpus.treebank.tagged_sents(tagset ='universal') # universal tags wsj2 = nltk.corpus.treebank.tagged_sents() # treebank specific tags according discussion in thread not possible. so far nltk provides possibility map specific tagsets universal tagset. maybe 1 of suggested solutions in discussion can help: this apparently not supported in nltk yet, see dan zeman's interset tool or script @ https://gist.github.com/nschneid/6476715

ios - Everything goes up when adding iAd banner [SWIFT] -

all labels, textfields , etc... go when add iad banner(at bottom of screen). or can add somehow without moving stuff? sounds you're implementing adbannerview using self.candisplaybannerads = true . implementing adbannerview in manner resize uiview fit adbannerview on bottom of devices screen. if you'd avoid can implement adbannerview programmatically or through interface builder. check answer here programmatic example started. don't forget remove self.candisplaybannerads = true when implementing own adbannerview .

osx - Setting initial position of NSWindow only works the first time -

Image
i'm trying set nswindow in center of screen, i'm noticing when quit , reopen app, takes position window in when app closed. expected behavior? if selected "restorable" window behaviour it's correct behaviour. you can disable behaviour unchecking restorable , leave autosave name empty. your application saves state "~/library/saved application state/com.identifier.appname.savedstate" folder , loads on launch also 1 hidden hack help: - (void)applicationdidfinishlaunching:(nsnotification *)anotification { [[nsuserdefaults standarduserdefaults] setobject:@no forkey:@"nsquitalwayskeepswindows"]; }

Format dynamic text in a Flash HTML5 Canvas Project -

i building simple flash html5 canvas project has recipes. i load text dynamic text fields variables , format text html tags. the text needs word wrap , have line breaks. to frustration can not seem make work. suggestions? thanks in advance.

vb.net - Button images, transparency, MouseOver colors -

i have button have made flat, no border when there image in it, seamless looking. the image want add button unfilled rectangle (png file). when mouse on button, have backcolor change red. when does, rectangle image not change red..it stays whatever color image. i wanted know if there way add image, who's actual backcolor transparent (i suppose?). the image blue rectangle very light brown background. when mouse on entire button's backcolor red, maintain blue rectangle. right when mouseover can see size of image itself. i'd rather not draw graphics button. (in actuality image outline of computer monitor...but it's rectangle case) is there way image or backgroundimage properties? put image in resources (project/properties/resources/images/add resource , dropdown menu choose add existing file...). then use code : private sub form1_load(byval sender system.object, byval e system.eventargs) handles mybase.load button1 .text = ...

r - Using different font styles in annotate (ggplot2) -

Image
i'm using code below generate simple chart annotations: require(ggplot2); data(mtcars) ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point() + annotate("text", x = 4, y = 25, label = "this should bold\nand not", colour = "red") + geom_vline(xintercept = 3.2, colour = "red") on chart apply bold font first part of phrase in text annotation: this should bold but wish remaining part of text remain unaltered respect font face , style. how using plotmath syntax parse = true : ggplot(mtcars, aes(x = wt, y = mpg)) + geom_point() + annotate("text", x = 4, y = 25, label = 'atop(bold("this should bold"),"this should not")', colour = "red", parse = true) + geom_vline(xintercept = 3.2, colour = "red")

php - What is the correct way to redirect a request in middleware? -

i trying implement (in)famous improved persistent session middleware in slim microframework. there places in algorithm described application should check user's cookie , redirect user if cookie has expired or invalid. unfortunately, impossible redirect user within middleware, 2 reasons: slim's redirect can used within named routes; redirect create entirely new request, restarting slim application. same conditions triggered redirect before re-triggered, creating infinite loop. problem 1 can solved clever use of hooks, not sure problem 2. notice some middleware solves using custom exception, catch slim's error handler, , call redirect: // handle possible 403 middleware can throw $app->error(function (\exception $e) use ($app) { ... if ($e instanceof httpunauthorizedexception) { return $app->redirectto('login'); } ... }); but not best way it. there other ways can accomplish this? what listed above fine w...

c - Get the FUSE version string -

is there function returns fuse version string? fuse_common.h has int fuse_version(void) , returns major version, multiplied 10, plus minor version; both of derived #define values. (e.g., returns 27 on platform). i'm looking for, however, char* fuse_version(void) return 2.7.3 . as said yourself, version defined in fuse_common.h . if don't want use helper_version , @alexguitar said may write small program -- seems 2 first numbers (major , minor) available: #include <fuse/fuse.h> #include <stdlib.h> #include <stdio.h> char* str_fuse_version(void) { static char str[10] = {0,0,0,0,0,0,0,0,0,0}; if (str[0]==0) { int v = fuse_version(); int = v/10; int b = v%10; snprintf(str,10,"%d.%d",a,b); } return str; } int main () { printf("%s\n", str_fuse_version()); exit(exit_success); } note: should include fuse/fuse.h , not fuse_common.h ; also, may need pass -d_file_offs...

python - How to trigger a callback function when a button is pressed for a long time -

how can create callback long-time-pressed button? example, want save new value when press button more 2 seconds. there way this? b3=tkinter.button(frames, text='1',font='agency 50', relief='groove',bd=5,width= 3, height=1) b3.bind("<button-1>", savep1) b3.bind("<buttonrelease-1>",savep11) def savep1(event): dur() if duration > 2: update1() clock[0]=time.time() else: connection=sqlite3.connect('joimax.db') cursor=connection.cursor() sql = "select * speicherplatz name='save1'" cursor.execute(sql) dsatz in cursor: scv.set(str(dsatz[2])) direction.set(dsatz[1]) connection.close() grafik() print(' speed: ', str(dsatz[2])) just said, tried judge duration of 2 actions. there errors. exception in tkinter callback traceback (most recent call last): file "c:\python34\lib\tkinter\__init__.py", line 1533, in ...

javascript - bug with database values in leaflet pop ups -

i building project using leaflet , meteor user can enter text , have text displayed in popup when click on map. can text display initially, text display lost on refresh. var markers = new meteor.collection('markers'); meteor.subscribe('markers'); template.map.rendered = function() { map = l.map('map', {doubleclickzoom: false}).locate({setview: true, maxzoom: 16}); //adds markers on dblclick map.on('dblclick', function(event) { currentlatlng = event.latlng; markers.insert({latlng: event.latlng}); }); var query = markers.find(); query.observe({ added: function (document) { var marker = l.marker(document.latlng).addto(map) .on('dblclick', function(event) { map.removelayer(marker); markers.remove({_id: document._id}); }); //display user input in popup var value; value = $("#txt_name").val(); markers.insert({txt: value}); marker.bindpopup(markers.findone({txt: value}).txt).openpopup...

Having trouble displaying an array in javascript -

hey guys i'm having trouble code. i'm trying loop through array whenever do, program show blank in firefox. appreciated. thanks! <!doctype html> <html> <body> <p id="demo"></p> <script language="javascript" type="text/javascript"> var finished1 = ["firex";"enrique";0;0]; var finished2 = ["detector";"chris";0;0]; var finished3 = ["hpvv";"diana";0;0]; var info= new array ( ); info[0] = var info1 = ["firex"; "enrique"; 6; 20,000]; info[1] = var info2 = ["detector"; "chris"; 7; 35,000]; info[2] = var info3 = ["hpvv"; "diana"; 12; 10,000]; info[3] = var info4 = ["firex"; "enrique"; 4; 25,000]; info[4] = var info5 = ["detector"; "chris"; 3; 15,000]; info[5] = var info6 = ["hpvv...

symfony1 - How are the "cache" files generated by PHP Symfony? -

i new symfony, have experience other web frameworks eg ruby on rails. i'm trying modify web page, , traced template particular file: cache/backend/dev/modules/autousers/templates/indexsuccess.php if update file, web page updated. however, file not in git repository. , given top directory called cache , surmise file generated symfony. modifying file directly not right solution. i'm trying understand how cache file generated, how can find places of real source files make change. can explain please? after make changes, how can regenerate cache file? or handled automatically symfony/php? thanks you. probably refer version 1 of framework. the default implementation of crud module generated in folder named cache . if want modify file (and don't want lost modified version) must copy in module , action folder. in case, must put file in specified folder: apps/backend/modules/users/templates/indexsuccess.php more info in section templates customiza...

voxel - AABB vs AABB collision detection and response -

in c++ implemented small collision detection , response system in small voxel game. aabb vs voxel (the voxel cube it's aabb, too). actually works fine 1 special exception, if player (aabb) moving in 45 degrees edge of voxel player glitching little in , out fastly. on images down can see it. now wondering causing problem can't find logical error!? here how in pseudo code currently: float xnew = xcurrent + xvelocity * deltatime; float ynew = ycurrent + yvelocity * deltatime; float znew = zcurrent + zvelocity * deltatime; float xcorrected = xnew; float ycorrected = ynew; float zcorrected = znew; // if player moving right side. if (xnew < xcurrent) { %do following each of 4 corners of player aabb,% %on right face, until 1 collision occurs% { float x = xnew; float y = ycurrent + %corner_y_offset%; float z = zcurrent + %corner_z_offset%; if (getvoxelat(x, y, z).issolid()) { xcorrected = (unsigned int)x + ...

graphics - Doubts on some results: from raytracing to distributed raytracing -

Image
i have simple ray tracer did time ago. trying improving , transforming in distributed ray tracer. first thing doing shooting bunch of rays instead of single ray through each pixel. each ray of bunch jittered center of relative pixel. final color of pixel decided average of results given rays. want ask if results having correct , reasons why correct or if there wrong. below can find pics: normal raytracing: distributed raytracing 10 rays through each pixel: distributed raytracing 10 rays through each pixel , light increased: so questions are: 1) normal need increase intensity of light when switch 1 10 rays? 2) result in third picture reasonable one? i guess wrong reason: have similar result if instead of using 10 rays use 1, jittered center. see picture below: thanks in advance! distributed raytracing isn't shooting multiple rays per pixel. pixel small, shooting 10 rays through has no significant effect on image. in distributed raytracing, multip...

java - SonarQube Multi-Module Code Coverage -

i have multi-module project can't seem accurate unit test code coverage report on sonarqube. use buildr , jacoco test coverage generation. file heirarchy similar below. project --module1 ----reports ------jacoco --------jacoco.cov (jacoco execution file, used .exec) --module2 --reports ----jacoco (generated html, csv, , xml report files) ----junit (junit xml report) at time, no unit tests exist module2. problem believe overall coverage on sonarqube reflects module1 , ignores module2 completely. makes coverage appear higher whole project. have thoughts on this? thank input. if problem correctly looking force coverage 0% when there no coverage file generated. have set correct parameter behaviour : sonar.jacoco.reportmissing.force.zero=true see documentation more details : http://docs.sonarqube.org/display/plug/usage+of+jacoco+with+java+plugin

Output from two processes on shell (Python,Linux) -

my python script executes program sends output on shell. however, script should simultaneously execute own commands have output on shell. possible that? see output both script , process? here process has output on shell: s.exe_cmd('./upgrade') so, able write print "my output..." and see on shell to? assuming you're using subprocess - print both on console. import subprocess p = subprocess.popen("sleep 1 && echo inside subprocess", shell=true) print("will print asynchronously") p.wait() this example program can try out

java - Why do the same values get put into my LinkedHashMap Array? -

i using linkedhashmap array. way 'put' , 'get' values? in linkedhashmap<integer, integer[]> have: key 1 -> integer array {5,6,2,4} key 2 -> integer array, {7,2,6,1} .... goes on here code snippet use store values // has store data order received linkedhashmap<integer, integer[]> hparamval = new linkedhashmap<integer, integer[]>(); // temprory integer array store number received integer[] iarrynoofparam = new integer[inoofscalar]; (irow = 0; irow < inoofblocks; irow++) { (icol = 0; icol < inoofarrval; icol++) { bbuffgenstr = arrays.copyofrange(buffrecv, istartloc, ioffset); gendataval oparamval = datastruct.readgenvalue(bbuffgenstr); bbuff4genstr = oparamval.getvalue(); // store integer array received iarrynoofparam[icol] = bytebuffer.wrap(bbuff4genstr) .order(byteorder.little_endian).getint(); istartloc = ioffset; } // store array of integer every key hparamval.put...

c# - Typescript with d3js with definitlyTyped -

so, first day typescript. i ran trouble code: var x: d3.scale.ordinal = d3.scale.ordinal() .rangeroundbands([0, +this.params.width], .1) .domain(data.map(function (d) { return d.dayname; })); i want x of type ordinal scale, reason error: generic type 'ordinal<domain, range>' requires 2 type argument(s). and sure enough in code definitlytyped can see following : interface ordinal<domain extends { tostring(): string }, range> { (x: domain): range; domain(): domain[]; domain(values: domain[]): ordinal<domain, range>; range(): range[]; range(values: range[]): ordinal<domain, range>; rangepoints(interval: [number, number], padding?: number): ordinal<domain, number>; rangeroundpoints(interval: [number, number], padding?: number): ordinal<domain, number>; rangebands(interval: [number, number], padding?: number, o...

Marshalling struct containing an enum in C# -

brief : have got .dll function i'm trying use in c# application. 1 of function doesn't work , returns "invalid arguments" status. i guessed marshalling issue. here .dll header : typedef unsigned char uint8; typedef unsigned short uint16; typedef unsigned long long uint64; typedef signed char int8; typedef signed short int16; typedef signed long long int64; #ifndef _msc_ver typedef unsigned char bool; #endif #ifdef __x86_64__ typedef unsigned int uint32; typedef signed int int32; #else typedef unsigned long uint32; typedef signed long int32; #endif typedef enum i2c_clockrate_t{ i2c_clock_standard_mode = 100000, /* 100kb/sec */ i2c_clock_fast_mode = 400000, /* 400kb/sec */ i2c_clock_fast_mode_plus = 1000000, /* 1000kb/sec */ i2c_clock_high_speed_mode = 3400000 /* 3.4mb/sec */ }i2c_clockrate; /* channel configuration in...

gruntjs - How to add metadata to html by grunt? -

i need add head in html reference js , css files. how can add metadata html grunt? plugin should use , way? it depends on use. use similar purposes grunt-file-creator powerful, need knowledge of node using it. if use copy task can set process function, e.g. here . if use concat / uglify tasks can use banner option. sorry if answer not clear, question broad.

html - How should I link a PHP login script to a mysql database for verification? -

i new php programming language , working on first site using language having trouble linking log in page mysql database in order carry out account verification , create cookies. how should go code below has trouble being executed. <?php $connection = mysql_connect("localhost","root",) or die("couldn't connect server!"); mysql_select_db("irrigation",$connection) or die("couldn't connect server!"); if ($_post['login']){ if ($_post['username'] && $_post['password']){ $username = mysql_real_escape_string($_post['username']); $username = mysql_real_escape_string(hash("sha512",$_post['password'])); $user = mysql_fetch_array(mysql_query("select * 'users' 'username' = '$username'")); if ($user == '0'){ die("that username doesnt exist! try making <i>$username</i>...

docusignapi - how to give one anchor string to all the checkboxes? -

i using check boxes tab in docusign. want put check boxes based on anchor string. example if want 2 check boxes give 1 anchor string check boxes. when give if check 1 check boxes checking. how give 1 anchor string check boxes?. you want different anchor strings different checkboxes. because docusign has pre-population feature tags of same label pre-populate same value (check or unchecked). see community post here

javascript - Knockout with not creating property -

i have little problem. fiddle http://jsfiddle.net/lkqtu/25524/ js var hellovm = function() { var vm=this; vm.obj1=ko.observable({}); vm.obj2=ko.observable({}); vm.test = function() { alert("fffff"); alert("obj 1 name "+vm.obj1().name); alert("obj 2 name "+vm.obj2().name); }; }; ko.applybindings(new hellovm(), document.getelementbyid('foo')); html <div id="foo"> <div> <input type="text" data-bind="value:obj1().name" /> </div> <div data-bind="with:obj2()" style="margin-top:2px"> <input type="text" data-bind="value:name" /> </div> <button data-bind="click:test">test</button> </div> first case binding unexisting property of object directly , second case binding unexisting property of object via "with" bi...

machine learning - Logistic Regression Scikit-Learn Getting the coefficients of the classification -

i doing multiclass classification , applying logistic regression on it when fitted data calling logistic.fit(inputdata,outputdata) the estimator "logistic " fits data. now when call logistic.coef_ prints 2d array 4 rows(i had 4 classes) , n columns(one each feature) this saw on scikit learn site: coef_ : array, shape (n_features, ) or (n_targets, n_features) estimated coefficients linear regression problem. if multiple targets passed during fit (y 2d), 2d array of shape (n_targets, n_features), while if 1 target passed, 1d array of length n_features. now query : why different coefficients there different classes need 1 hypothesis predict output. as have multiclass case (>2 cases) one-vs-rest strategy applied. sklearn creates 4 classiefiers, not 1. hence have 4 hypothesis , 4*coefficents. note: have no clue logistic regression classifier, how sklearn svm work.

How to write a PIP extension in Java running on the WSO2 Identity Server -

found reference article how write xacml pip extension in wso2 under link http://blog.facilelogin.com/2011/04/xacml-policy-information-point.html is list of prerequisites still valid wso2 identity server version 5? article mentions 2 .jars required, org.wso2.carbon.identity.entitlement-3.2.0.jar , sun-xacml-2.0.1.wso2v1.jar. there newer set available? could please confirm obtain jar files or give updated link documentation. thanks in advance support. regards, claude yes. there newer versions org.wso2.carbon.identity.entitlement jar. org.wso2.carbon.identity.entitlement-4.2.0.jar , org.wso2.carbon.identity.entitlement-4.2.2.jar. you can find org.wso2.carbon.identity.entitlement-4.2.0.jar [1]. org.wso2.carbon.identity.entitlement-4.2.2.jar available in /repository/components/plugins. you can find sun-xacml-2.0.1.wso2v1.jar [2]. [1] http://maven.wso2.org/nexus/content/repositories/wso2maven2/org/wso2/carbon/org.wso2.carbon.identity.entitlement/4.2.0/ [2] htt...

php - Laravel PDO Settings? -

i return int integers database. @ moment values loaded strings. database mssql 2012 , use pdo driver (for v5.6). trying set properties here (as shown here on fideloper.com , don't know if that's still possible): 'sqlsrv' => [ 'driver' => 'sqlsrv', 'charset' => 'utf8', 'prefix' => '', ...... 'options' => array( pdo::attr_stringify_fetches => false, pdo::attr_emulate_prepares => false, ), ], but getting error: sqlstate[imssp]: given attribute supported on pdostatement object. how can set settings pdo driver return int integers , not strings. this still not working: $pdo = db::connection()->getpdo(); $pdo->setattribute(pdo::attr_stringify_fetches, false); $pdo->setattribute(pdo::attr_emulate_prepares, false); .. orm query bringing same error. maybe can me? i believe is...

java - How to solve "It is indirectly referenced from required .class files" error in android? -

i building android application using chat model. there website name quickblox server side part handle them. using application.they provide sample android code too, have import sample code , add lib , jar need run project. now problem in 1 of class there error of "it indirectly referenced required .class files" dose mean , how solve can 1 me in solving issue. below class code - public class usersadapter extends baseadapter { private list<qbuser> datasource; private layoutinflater inflater; private list<qbuser> selected = new arraylist<qbuser>(); public usersadapter(list<qbuser> datasource, context ctx) { this.datasource = datasource; this.inflater = layoutinflater.from(ctx); } public list<qbuser> getselected() { return selected; } @override public int getcount() { return datasource.size(); } @override public object getitem(int position) { return datasource.get(position); } @override public long getitemid(int pos...

swing - Tips to Keep a Responsive User Interface in Java -

what best way keep buttons , others components in swing responsive. use "new thread(){public void run(){}}.start();" on every action listener don't know how stop or cancel thread without using "thread.stop()" suggestions or tips? my rule of thumb start thread if it's very long running task. , long running mean practically same life of application. therefore never start own threads. starting thread each little operation bad idea because threads expensive spin up. usual solution use threadpool reuse threads , take headache away you. but it's swing, there option of swingworker run on background pooled thread , give easy way update ui results in correct thread. from https://docs.oracle.com/javase/8/docs/api/javax/swing/swingworker.html final jlabel label; class meaningoflifefinder extends swingworker<string, object> { @override public string doinbackground() { return findthemeaningoflife(); } @override ...

multidimensional array - Spark scala how to count values in rows -

i new both spark , scala...and have read data file , count value contained in both columns , rows. data set structured this: 0 0 2 0 2 2 0 2 0 2 0 0 0 0 0 0 1 0 in order count number of "2" in each column: i imported file: val ip = sc.textfile("/home/../data-scala.txt") i created array save results var arraycol = array.ofdim[long](3) val cols = ip.map(line => line.split(" ")) (i <- 0 2) { arraycol(i) = cols.map(col => col(i)).filter(_.contains("2")).count() } and counted number of "2" contained in each column. now same each row. have suggestion? cols.map(r => r.count(_ == "2")) or shell example: scala> val cols = sc.parallelize(list("0 1 2", "2 0 2")).map(_.split(" ")) scala> cols.map(_.count(_ == "2")).collect() res1: array[int] = array(1, 2)

php - How to create Table Dynamically with existing table fields in mysql -

currently i'm using table sample1. how can create table sample2 sample1's field dynamically? you can way. create table `sample2` select * `sample1`; another alternative is if table structure same can use: insert `sample2` select * `sample1`;

javascript - OnClick event for div inside lots of container Divs -

i have app i'm developing , need onclick() event fired when <div> clicked. so in other words, <div id="panda"></div> $("#panda").click(function () { console.log("some text"); }); so statement works lets have, <div id="panda"> <lots of children> <div id="koala"> </div> </lots of children> </div> $("#koala").click(function () { console.log("doesnt work"); }); now see life of me can't koala clickable. click event on parents works fine, , click evens empty divs use buttons work fine, reason cant filled child <div> clickable. any ideas case be? i tried this, $('#panda').click(function(e){ if ($(e.target).is('#koala')) { console.log("koala"); } }); but logs every click on parent. one option listen di...

c# - How should I remove objects from a list when a cancel dialog result is returned? -

i writing c# forms application have many list<t> lists. have many forms can add , remove objects these lists. if users presses cancel button, , dialog result returned cancel, how best way remove data added lists form? should take 'snapshot' of lists beforehand, , restore lists, or there better approach? all lists inherit icustomobject interface, , these lists stored in 1 place. not specific each form, each form can add , edit items in lists. thanks. i'd create backup of lists , revert changes if user press cancel. var list1 = new list<int>() { 1, 2, 3}; var list2 = new list<string>() { "abc", "def", "ghi"}; object[] tempdata = new[] { list1.tolist(), list2.tolist() }; //... user changes in list1, list2 ... list1.add(12); list1.remove(3); list2.remove("def"); if(cancel) { list1 = tempdata[0] list<int>; list2 = tempdata[1] list<string>; }

angularjs with restfull webservice -

is possible communicate restfull webservice using angularjs.my application located in c://higi folder , have created restfull webservice in eclipse using return $http.get('http://localhost:8080/restfulandangularjs_server/rest/product/findall') .success(function(response){ $window.alert('success') }); code connecting restfull webservice possible or not if http://localhost:8080/restfulandangularjs_server/rest/product/findall endpoint accessible in general, should accessible via angular $http service. you can test whether server pasting url in browser. depending on how server side code set regard content negotiation, might error (which error depend on used build web service, @ least you'll know it's up). if it's should able call angular $http service. if not, make sure its' running starting whatever server using in eclipse. if you're sure server , running, call should work. might consider handling error callb...

c# - join data in linq if only data for object is available from view model - ASP.net -mvc5 -

i have viewmodel extract of multiple model classes. binding data , passing razor partial view show data getting error if 1 of model object null. in business process expected question can use if condition linq--joins i.e. join result if data exist in database or there better way it. public studentdetailedprofileviewmodel getstudentdetailedprofilebystudentid(int _studentid) { try { using (var _uow = new studentprofile_unitofwork()) { studentdetailedprofileviewmodel studentprofileobject = new studentdetailedprofileviewmodel(); var _profile = (from _student in _uow.student_repository.getall() join _contactdetail in _uow.contactdetail_repository.getall() on _student.studentid equals _contactdetail.studentid join _addressdetail in _uow.address_repository.getall() on _student.studentid equals _addressdetail.studentid ...

sql - How to turn a order items into a column list of products -

i trying list of products order listed columns. tried pivot table dont want column names of product static names product 1, product 2 , row have product sku , quantity. same products should go in same column. sku1 in product1 column etc example. order , orderitems table. output like header: orderid,product1, quantity1,product2 quantity2,product3,quantity3 rows: 1 , sku1,3, sku2,4, sku3,5 2 , sku1,2, sku2,5, sku3,1 i have created sql fiddle: http://sqlfiddle.com/#!3/d993a/4/0 example of structure , select. my last thought table variable revant columns , insert still cant see best option. thanks in advance..... select b.quantity, case when b.productname='product 1' b.sku end 'product1', case when b.productname='product 2' b.sku end 'product2', case when b.productname='product 3' b.sku end 'product3', case when b.productname='product 4' b.sku end 'product4', case when b.productname='produ...

python 2.7 - Import error web "no module named web" -

i did web application using web.py , after while realize python compiler configure use python2 instead of python3 (both installed). python2 application working got string in unicode try execute code using python3: python3 mycode.py but different kind of error, lib urlparse not found (this problem cause new name in python3 urllib) got problem with: import web the return error is: importerror: no module named 'web' i can't figure out problem come from. maybe have installed web in python2 lib have none in python3 lib... check out