Posts

Showing posts from June, 2010

c# - How can I find the Id property or properties related to a navigational property? -

for project i'm working entity framework , i'd able enumerate navigational properties given object instance (assuming it's object generated ef). there i'd related id property every navigational property. for example, if instance of class person , want able find it's navigational properties called address , boss . 2 navigational properties want "lookup" related id properties called addressid , bossid . i need id properties can run queries on different database not have same foreign keys have same ids. so far have figured out way relationshipmanager random object instance generated ef. , while debugging can foreign key relations via manager's relationships property. can far navigational property name. can see there's fk_person_address related navigational property called address can't find addressid . so question is, how can dynamically (with no knowledge of person class' layout) discover addressid property related address

swing - Java GUI validation -

i have java swing application contains 4 jtextfields, 1 jlabel , 1 jbutton. want user enter integer values in 4 jtextfields , when user presses jbutton sum of integer values should appear in jlabel...now main problem on jbuttons onclicklistener have validate jtextfields , need know jtextfield had invalid entry...i thinking of implementing separate try-catch block each jtextfield , using integer.parseint(string s) in jbutton's onclicklistener way know jtextfield causing problems...but wont implementing separate try-catch block each jtextfield inefficient??? can suggest better approach... but wont implementing separate try-catch block each jtextfield inefficient??? inefficient? that's hardly issue when you're checking 4 jtextfields, , shouldn't part of consideration in instance. instead, i'd concentrate more on gui ease of use , safety. consider preventing user entering in non-numeric data in first place, using jspinner or jformattedtextfield or usi

c# - DataGrid Columns created in xaml - how to fill programmatically? -

i have created datagrid in xaml. code this: <datagrid x:name="mydatagrid" verticalalignment="top" height="305" margin="36,157,-36,0" autogeneratingcolumn="dgoverviewmain_autogeneratingcolumn" loaded="dgoverviewmain_loaded" mouseup="dgoverviewmain_mouseup" borderbrush="{x:null}" background="#ffedfdff"> <datagrid.columns> <datagridtextcolumn binding="{x:null}" clipboardcontentbinding="{x:null}" header="col1"/> <datagridtextcolumn binding="{x:null}" clipboardcontentbinding="{x:null}" header="col2"/> <datagridtextcolumn binding="{x:null}" clipboardcontentbinding="{x:null}" header="col3"/> </datagrid.columns> </datagrid> now want add rows programmatically c#. datarow temprow = dt_source.rows[1]; //get row data

hugo - Can we embed one (or more) post lists in a content page? -

disclaimer: re-post of question went unanswered on hugo forum . if that's not cool, let me know , i'll remove / edit it. i'm trying use hugo (a static site generator) replace corporate marketing site. i'm going wrong, i'll try express desires before hacked solution. my goal for company's website, have several categories of iterative content, "case studies" , "advisors". these categories organized in tree already. i'd create *.md pages allow non-technical content creators customize header , content @ top of page, , below that, i'd add series of sections, each of lists 1 of child directories' posts. an example output might like: <head> <title>about us</title> </head> <body> <!-- marketing content generated /content/about/index.md --> <h1>about us</h1> <!-- leadership team list generated automatically /content/about/leaders/* --> <section>

asp.net - Add custom properties to .tt POCO classes lost on updating model -

i've created 3-tier web application using entityframework database first approach. need add custom properties poco classes not exist in database. when update edmx , run custom tool tt file, classes refreshed per database , lose custom properties created. i need such custom properties in web application only, , can't add them database. there way refresh poco classes without losing custom properties? that's way entity works. classes refreshed when run tool. accomplish trying need add new properties or methods on different file. auto generated classes marked partial reason. here link of situation similar yours http://robbincremers.me/2012/01/31/entity-framework-using-partial-classes-to-add-business-logic-and-validation-to-generated-entities/

Why is my Wordpress plugin trying to update as someone else's? -

i'm writing plugin, based on else's tutorial.. i've been changing parts of i'm building it, such name, names of functions , forth. basics of plugin work expected, , shows in plugin manager ui. however, when activate it, shows custom metadata (plugin name, version, etc), incorrectly displays , "update plugin" message of else's plugin. plugin appears not related tutorial maker (which first suspicion).. seems not directly related plugin name, folder name, or filenames.. can't seem control – other remove whole metadata section, seems illogical. what linking plugin else's plugin, or otherwise causing wrongly identify? thanks in advance the plugin section gathers info online repo, if have named that's there, pull through data. just give unique name: /* plugin name: unique plugin */

apache - boot2docker windows 10, unable to access container via browser -

i trying use docker on windows 10 via boot2docker , vb. boot2docker ssh boot2docker ip => 192.168.59.103 docker run -tip 80:80 tutum/apache-php bash ping 192.168.59.103 host machine it sounds working pretty exepts : via browser, when go http://192.168.59.103 page not found do have idea issue ? thanks. edit : logs docker@boot2docker:~$ docker ps -a container id image command created status ports names ecb75ba8f5f9 tutum/apache-php "/run.sh" 20 minutes ago 20 minutes 0.0.0.0:80->80/tcp ecstatic_galileo docker@boot2docker:~$ docker logs ec ==> /var/log/apache2/access.log <== ==> /var/log/apache2/error.log <== ==> /var/log/apache2/other_vhosts_access.log <== ==> /var/log/apache2/error.log <== [mon aug 17 10:18:25.361931 2015] [mpm_prefork:notice] [pid 1] ah00163: apache/2.4.7 (ubuntu) php/5.5.9-1ubuntu4.11 configured

android - Setting src and background for FloatingActionButton -

Image
when use background , src in android.support.design.floatingactionbutton not set correctly. instead displayed as <android.support.design.widget.floatingactionbutton android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/pink" android:src="@drawable/ic_action_barcode_2" android:layout_gravity="bottom|right" android:layout_marginbottom="16dp" android:layout_marginright="16dp" /> but when use imageview appears correctly <imageview android:id="@+id/fab" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@drawable/pink" android:src="@drawable/ic_action_barcode_2" android:layout_gravity="bottom|right" android:layout_marginbottom="16dp" android:layout_marginright="16dp" /> why floatingactionbutton

python - Reddit API is not working properly -

the ups , downs attribute of praw.objects.comments class not working properly. instead of showing total number of upvotes praw.objects.comments.ups showing difference between upvotes , downvotes. there anyway access information? import praw reddit = praw.reddit("hackers") subreddit = reddit.get_subreddit( "pics" ) top_submissions = subreddit.get_top() top_submission = next(top_submissions) first_comment = top_submission.comments[0] print(first_comment.ups, first_comment.downs, first_comment.score) from post , don't think explicit , down vote counts available public anymore - looks make total score , upvotes same, , leave downvotes @ 0.

Creating a 2D vertex array in C# for use with XNA -

we being directed draw cube, using following rough structure store vertices: vertexpositiontexture[] vert; vert = new vertexpositiontexture[24]; however, thought better organisation, , allow easier manipulation, if broke vertices 2d array this: public class square { public vertexpositiontexture[] vert } square[] cubeside; cubeside = new square[6]; however, can instantiate cubeside, not verts inside each square. i tried creating constructor inside square class, realised have option of new square[] or new square() , not both. have 1 square 4 vertices, or size squares 1 vertex. i have tried vertextpositiontexture[] vert = new vertexpositiontexture[4] in square class, itself, not work either. to add confusion, last time taught xna, teachers drilled arrays had declared @ start, exact number of elements wanted. i.e, can not have vertextpositiontexture[] vert , , instead, should have vertextpositiontexture[4] vert . quite adamant array, once set, never have capacity a

sql - Cassandra - secondary index and query performance -

my schema table : a) create table friend_list ( userid uuid, friendid uuid, accepted boolean, ts_accepted timestamp, primary key ((userid ,accepted), ts_accepted) ) clustering order (ts_accepted desc); here able perform queries like: 1. select * friend_list userid="---" , accepted=true; 2. select * friend_list userid="---" , accepted=false; 3. select * friend_list userid="---" , accepted in (true,false); but 3rd query involves more read, tried change schema : b) create table friend_list ( userid uuid, friendid uuid, accepted boolean, ts_accepted timestamp, primary key (userid , ts_accepted) ) clustering order (ts_accepted desc); create index on friend_list (accepted); with type b schema, 1st , 2nd queries works, can simplify third query : 3. select * friend_list userid="---"; i believe second schema gives better performance third query, won't con

java - Class out of scope? -

in question answer "compilation fails", because in go method h1 out of scope. h1 looks public me, can explain why out of scope? when can method access other variables? public class happy { int id; happy(int i) { id = i; } public static void main(string [] args) { happy h1 = new happy(1); happy h2 = h1.go(h1); system.out.println(h2.id); } happy go(happy h) { happy h3 = h; h3.id = 2; h1.id = 3; return h1; } } this line defines happy h1 = new happy(1); this inside scope of main(string[] args) which why can't access outside { } of main.

android - trasparent statusbar navigationdrawer after setstatusbarcolor -

Image
i'm try developing app navigation drawer template found on github. in style.xml have: <style name="apptheme" parent="theme.appcompat.noactionbar"> <!-- customize theme here. --> <item name="colorprimary">#ff0000</item> <item name="colorprimarydark">#0000ff</item> and status bar in navigation drawer ok. when click button runs command: getwindow().setstatusbarcolor(color.green); now status bar color in navigation drawer no more translucent how restore status bar color translucent? the difference xml defined colors colorprimary , colorprimarydark not used directly set status bar color. actually statusbar transparent time , underlaying view colored. thats why can have color on left on right side (have @ second screenshot). if call getwindow().setstatusbarcolor(..) indeed color statusbar directly , over-draw color of both views . needs stay transparent! what want

c# - Databinding partially working to custom dependency property in UserControl -

hallo , thank time. i have peculiar problem. have created usercontol, has custom dependency properties. if implement usercontrol, , bind static text. working fine. however, if try set value of selected objects properties. not work. this error getting in output window: error: bindingexpression path error: 'selectedusecase' property not found on 'helper.usercontrols.usecasepropertydisplay'. bindingexpression: path='selectedusecase.name' dataitem='helper.usercontrols.usecasepropertydisplay'; target element 'helper.usercontrols.usecasepropertydisplay' (name='null'); target property 'text' (type 'string') usercontrol: https://github.com/toudahl/softwaredesignhelper/blob/master/helper/usercontrols/displayandeditcontrol.xaml <usercontrol x:class="helper.usercontrols.usecasepropertydisplay" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x=

swing - Java JFrame Bouncing Ball Physics Simulation- Ball Motion Conflicts Upon Creation of Creation -

so, right now, i'm able create multiple balls , update them through vector of objects , loop update each object independently. problem every ball after first, ball created seems affect momentum , position of other balls, causing balls abruptly change flight paths. code creating frame , managing ball creation based on mouselistener: public class framecreation extends jframe{ static vector<ballcreate> ballobjects = new vector<ballcreate>(); static timer timer; point m1; point m2; static jframe frame1; static mousehandler mouse; public static void main(string args[]){ framecreation frame = new framecreation(); frame1 = new jframe("phyiscs test"); frame1.setvisible(true); frame1.setsize(520,530); frame1.setdefaultcloseoperation(frame1.exit_on_close); mouse = frame.new mousehandler(); frame1.addmouselistener(mouse); } public class mousehandler extends jpanel impl

c# - Use of unassigned local variable `IsZoneEmpty' -

why saying use of unassigned variable iszoneempty . i'm having hard time finding out why. because using variable in if statement.please me. why saying use of unassigned variable iszoneempty . i'm having hard time finding out why. because using variable in if statement.please me. using unityengine; using system.collections; using system.collections.generic; public class spawnzone : monobehaviour { private vector3 zone1; private vector3 zone2; private vector3 zone3; private vector3 zone4; private vector3 zone5; public vector3 zone1l; public vector3 zone2l; public vector3 zone3l; public vector3 zone4l; public vector3 zone5l; public gameobject monster; gameobject spawnedm; void start () { dictionary <vector3,bool> iszoneempty; new dictionary <vector3,bool>(); { iszoneempty.add(zone1,true); iszoneempty.add(zone2,true); iszoneempty.add(zone3,true

javascript - Why ng-model does not update controller value select? -

this code html: <div ng-controller="selectctrl"> <p>selected item : {{selecteditem}}</p> <p> age of selected item : {{selecteditem.age}} </p> <select ng-model="selecteditem" ng-options="item.name item in items"> </select> </div> this code angularjs: var app = angular.module('myapp', []); app.controller('selectctrl', function($scope) { $scope.items = [{name: 'one', age: 30 },{ name: 'two', age: 27 },{ name: 'three', age: 50 }]; $scope.selecteditem = $scope.items[0]; console.log($scope.selecteditem); //it's not update :( }); in view new value updated every time change select, controller not update current value of select. should do? thanks! to updated or change value inside controller, write ng-change function on it. check updated value inside controller. markup <select ng-model="selecteditem" ng-op

Looking for an advanced PDF comparison software -

for work assignment have read through 600-1000 page pdfs , form general opinion on how similar (the extent company putting them out using 'boilerplate' formats). i've used adobe xi pro dc's comparator software, can compare 2 pdfs , highlight parts different or changed. i'll through comparison pdf, , part isn't highlighted i'll know exact same in both pdfs. the problem software if similar portions/strings far apart each other in terms of page count (ex: if relevant section on page 100 of first pdf page 25 on second pdf), comparison software isn't going catch it. my ideal pdf comparator software highlight sections/paragraphs/strings in first pdf cannot found anywhere in second pdf. section/string/paragraph found in second pdf, no matter how far apart in terms of page count, stay unhighlighted. any hugely appreciated! you may want check xdocdiff project (open-source may adapt needs) , maybe of these diff tools recommended in tortoises

android studio gradle refresh failed (The system cannot find the file specified) -

i receiving following error in android studio gradle error:c:\users\subash.gradle\caches\2.2.1\scripts\aslocalrepo16_1ny8gqikcqanmkspcmvyfsub7\initscript\initscript\cache.properties (the system cannot find file specified) if understand right problem can solved simple correction of path of file contains correct version of gradle. you can find in android studio -> preferences -> gradle -> service directory path. you must find correct version of gradle run smoothly. have [gradle-2.4-rc-1]. i hope can solve problem.

Python/Flask: ValueError: View function did not return a response -

seemingly trivial problem can't figure out, despite going through documentation , tutorial. keeps on coughing up: builtins.valueerror valueerror: view function did not return response whenever try render template. using pycharm editor doesn't warn problems. website.py: from flask import flask, url_for, request, render_template app = flask(__name__, template_folder='templates') @app.route('/') def hello_world(): render_template('hello_world.html') if __name__ == '__main__': app.debug = true app.run() hello_world.html: <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>hello, flask</title> </head> <body> <h1>hello, world , flask!</h1> </body> </html> should of course have been @app.route('/') def hello_world(): return render_template('hello_world.html') overlooked &#

database schema for like entities that can be combined pairwise (ActiveRecord) -

i designing database of woodwind instrument sounds, , create table joins pairs of sounds performer can combine into, example, trill. such relations transitive: if sound has 'sound relation' sound b, sound b has same 'sound relation' sound a. i familiar join tables, i've never seen them used join 'like' objects, join 'unlike' objects, such tags , posts, i'm wary of going direction. i realize example below looks extremely dubious, gives idea of i'm after. better way of doing it? (using activerecord syntax) models class sound < activerecord::base has_many :linked_sounds, through: :sound_relations, class_name: "sound", foreign_key: ??? end class sound_relation < activerecord::base has_many :sounds end migration class createsoundrelations < activerecord::migration def change create_table :sound_relations |t| t.integer first_sound_id # cannot possibly right. t.integer second_sound_id # sure

c# - SqlDependency.OnChange firing but SqlDataReader is not returning with data -

Image
when execute query datetime column filter where [order].createdon >= @createdon using sqldependency , change on data source fires sqldependency.onchange event sqldatareader associated sqlcommand doesn't return data ( reader.hasrows returns false ). when change filter condition in sql statement where [order].statusid = 1" it works fine , sqldatareader returns data ( reader.hasrows returns true ) code: using system; using system.collections.generic; using system.configuration; using system.data; using system.data.sqlclient; using system.linq; using system.web; using system.web.ui; using system.web.ui.webcontrols; namespace signalrserver { public partial class departmentscreen : system.web.ui.page { protected void page_load(object sender, eventargs e) { var u = system.security.principal.windowsidentity.getcurrent().user; var username = u.translate(type.gettype("system.security.principal.ntaccount&quo

ios - Change view controller when user exits app -

hey trying make whenever user presses home button , try returns app, returned initial view controller. there can write app delegate work? i have tried call function in applicationdidbecomeactive function: let storyboard = uistoryboard(name: "main", bundle: nil) let vc = storyboard.instantiateviewcontrollerwithidentifier("homevc") as! uiviewcontroller self.window?.rootviewcontroller?.presentviewcontroller(vc, animated: true, completion: nil) but error saying view not in hierarchy. any appreciated! you want implement applicationdidbecomeactive method of app's delegate, , programmatically perform segue or dismiss current view controller, depending on navigation setup. your users might not forced navigation though. general assumption can resume left off.

MongoDB on Ubuntu weird error ^?ELF^B^A^A -

i running mongodb on ubuntu server along nodejs application. reason following error in mongodb-log when start forever start /path/to/mongod : /mongodb/mongodb-linux-x86_64-3.0.5/bin/mongod:1 (function (exports, require, module, __filename, __dirname) { ^?elf^b^a^a^ syntaxerror: unexpected token illegal @ module._compile (module.js:439:25) @ object.module._extensions..js (module.js:474:10) @ module.load (module.js:356:32) @ function.module._load (module.js:312:12) @ function.module.runmain (module.js:497:10) @ startup (node.js:119:16) @ node.js:902:3 error: forever detected script exited code: 8 i removed mongodb directory , installed again, still same error. thanks help forever meant node.js-based modules. mongod binary (i.e. in elf format, file $(which mongod) verify yourself) , cannot handled forever . what see forever trying use node start node module called mongo and failing compile js code (since reading elf header). you have rely on system's init s

python - losing subclass fields when serializing in django? -

i see baffling , seems flatout bad behavior in serializing django objects. example, have models: class mytag(tagbase): user = models.foreignkey(user) class mymptttag(mpttmodel, mytag): parent = treeforeignkey('self', null=true, blank=true, related_name='children') class mpttmeta: parent_attr = 'parent' which means mymppttag has fields of name, slug, user, parent . when serializers.serialize('json', mymppttag.object.all()) , get: [{"fields": {"lft": 1, "level": 0, "tree_id": 29, "parent": null, "rght": 2}, "model": "index.mymptttag", "pk": 45}...] why lose name, slug, , user , , how them back? thank you on model design, have 2 tables in database: yourapp_mytag have primary key column (normal auto-increment column), columns inherited tagbase (as long tagbase abstract) , column user - foreign key model user

java - Scala repl throws error -

when type scala on terminal start repl, throws error scala> [init] error: error while loading annotatedelement, class file '/usr/lib/jvm/java-8-oracle/jre/lib/rt.jar (java/lang/reflect/annotatedelement.class)' broken (bad constant pool tag 15 @ byte 2713) when hit enter , type println("hello, world") , again throws this error: error while loading charsequence, class file '/usr/lib/jvm/java-8-oracle/jre/lib/rt.jar (java/lang/charsequence.class)' broken (bad constant pool tag 15 @ byte 1501) i using ubuntu 14.04 , java -version gives java version "1.8.0_05" java(tm) se runtime environment (build 1.8.0_05-b13) java hotspot(tm) 64-bit server vm (build 25.5-b02, mixed mode) either update newer scala version (2.10.3+) or downgrade java java 6/7. have seen in output, 2.9.2 here long before java 8 introduced ( copyright 2002-2011, lamp/epfl ), don't work together. this duplicate question contains exact instructions on

list - Why does this function give rise to an infinite loop? -

i trying solve exercises haskell course found online , this question , have following implementation: reverse :: list -> list reverse nil = nil reverse (x :. xs) = let l = (reverse xs) in l ++ (x:.nil) with list being defined as: data list t = nil | t :. list t deriving (eq, ord) it seems there infinite loop inside function. not find out why. enlighten me? this correct implementation of reverse definition of list in exercise book. if there infinite loop somewhere in implementation of (++) .

Eclipse Galileo is not running over Java 1.8 machine -

Image
i have eclipse galileo version java 1.8 machine , it's not running. i have newer version running well, need use exact version. what can fix it? edit 1: java version 1.7 , not 1.8 attached message got: **edit 2: main reason why need exact eclipse version, it's because don't jboss server in list: ** i can see you're using java 7 run eclipse. noted line in configuration: -vm c:\program files\java\jdk1.7.0_71\bin\..\jre\bin\server\jvm.dll ^ points jdk 1.7 change place have installed java 8. also, use absolute paths here, avoid using things .. .

jquery - stick navigation to top when scrolled to/past - Bootstrap 3 -

i trying create navigation sticks top of site when hits top of page. (the navigation 280px top when user @ top of page)i using bootstrap 3 framework in wordpress. this common thing , have found number of examples can't seem work me. i have generic bootstrap navigation. trying put following code in no success. html ( in < head > tags ) <script> $('#nav').affix({ offset: { top: $('header').height() } }); </script> html <body <?php body_class(); ?> > <header class="masthead"> <div class="container"> <div class="row"> <div class="col-sm-6"> <h1><a href="#" title="scroll down viewing pleasure">bootstrap 3 layout template</a><p class="lead">big top header , fixed sidebar</p></h1> </div> <div class="col-sm-6"> </div> </d

r - quantile on a matrix in long format -

i trying compute quantiles on matrix represented data.table in long format (rowid, colid, value). converting matrix::sparsematrix , computing quantiles. wondering if there more efficient way this? (using r 3.2.1 , data.table 1.9.5 github) require(data.table) require(matrix) set.seed(100) nobs <- 1000 #num rows in matrix nvar <- 10 #num columns in matrix density <- .1 #fraction of non-zero values in matrix nrow <- round(density*nobs*nvar) data.dt <- unique(data.table(obsid=sample(1:nobs,nrow,replace=t), varid=sample(1:nvar,nrow,replace=t))) data.dt <- data.dt[, value:=runif(.n)] probs <- c(1,5,10,25,50,75,90,95,100) #approach 1 system.time({ data.mat <- sparsematrix(i=data.dt[,obsid], j=data.dt[,varid], x=data.dt[,value], dims=c(nobs,nvar)) quantile1.dt <- data.table(t(sapply(1:nvar, function(n) c(n,quantile(data.mat[,n], probs=probs/100, names=false))))) quantile1.dt <- setnames(quantile1.dt, c("varid",sprintf("p%0

Organizing rails model files into subdirectories -

i'm organizing models subdirectories listed below. i've tried every solution listed in stackoverflow few others keep getting errors. seems simple task , in need of help. makandra - organizing large rails apps rails 4: organize rails models in sub path without namespacing models? how organize rails models fat? rails models in subfolders , relationships however, keep getting error: activerecord::statementinvalid: not find table 'blog_posts' config/application.rb: 1 require file.expand_path('../boot', __file__) 2 3 require 'rails/all' 4 5 # require gems listed in gemfile, including gems 6 # you've limited :test, :development, or :production. 7 bundler.require(*rails.groups) 8 9 module multifile 10 class application < rails::application 11 # settings in config/environments/* take precedence on specified here. 12 # application configuration should go files in config/initializers 13 # -- .

java - Spring and Jersey Filter - Provider or Component? -

i'm trying determine spring-boot, jersey , how jersey , spring-boot contexts relate 1 another. @component public class corsfilter implements filter { public void dofilter(servletrequest req, servletresponse res, filterchain chain) throws ioexception, servletexception { httpservletresponse response = (httpservletresponse) res; response.setheader("access-control-allow-origin", "*"); response.setheader("access-control-allow-methods", "post, get, options, delete"); response.setheader("access-control-max-age", "3600"); response.setheader("access-control-allow-headers", "x-requested-with"); chain.dofilter(req, res); } public void init(filterconfig filterconfig) { } public void destroy() { } } when have labeled @provider , make jersey in package lives it, doesn't find it. works when make @component. @configuration @appl

windows - Listview looked like a ListBox in the attached picture in the Universal App -

what need listview looked listbox in attached picture in universal app or whether there easier way similar-looking list? https://i-msdn.sec.s-msft.com/dynimg/ic505349.png i'm not entirely sure you're trying ask, i'll give shot. you can use listview , set datatemplate make u want. example: <listview itemssource="{binding myitems}" > <listview.itemtemplate> <grid> <grid.columndefinitions> <columndefinition /> <columndefinition /> </grid.columndefinitions> <textblock text="{binding property1}" /> <textblock grid.column="1" text="{binding property2}" /> </grid> </listview.itemtemplate> </listview> where property1 , property2 bindable properties of item in itemssource.

c# - Running external processes asynchronously in a windows service -

i writing program moves csv files "queue" folder "processing" folder, third party process called import.exe launched taking csv file path argument. import.exe long running task. i need program continue running , checking queue new files. reason i’ve chosen windows service application long running. my problem overwhelmed options , can't understand if should approach problem background threads or parallel programming , or combination of both. so far have code running synchronously. see @ moment, wildly firing processes without anyway manage or check completion. have commented out process.waitforexit () blocking call. public int maxconcurrentprocesses = 10; protected override void onstart(string[] args) { // set timer trigger every minute. system.timers.timer timer = new system.timers.timer(60000); timer.elapsed += new system.timers.elapsedeventhandler(this.ontimer); timer.start(); } private void ont

Setting Global Variables in Java -

here's problem: have number of classes need access specific value (such email address) , instead of declaring again , again in each class i'd declare once , access using sort of global variable. now before naysayers start screaming (or down-voting post) aware declare class this: public class globalvar{ public globalvar() throws exception { } public static string email = "myemail@gmail.com"; } and access email anywhere using globalvar.email my problem value of email cannot set static because comes text file (from key/property using java properties class ) , don't see anyway load value txt file if set variable static. i storing dynamically generated email in file , retrieving next time start application. of course can attempt retrieve each time need use variable not elegant. update: a potential solution has been proposed follows: public static string email = null; static { email = "awesome@email.com"; // cha

jquery - Passing variable from Ajax Call into the Success Function -

i have code takes user input, incorporates ajax call url, retrieves data based on input. the retrieved data in json format, , want access part of json object using user's original input. for example: user input: example_name ajax url: www.something.com/api/example_name?api_key=12345 upon returning object: i want access: object.example_name.id i having difficulties passing variable ' example_name ' original ajax call success function. here code: function getsummonerid(n) { console.log("check function..."); $.ajax({ datatype: "json", type: 'get', url: 'https://url_here/' + n + '?api_key=12345', success: function (json, n) { console.log(json); console.log(n); //this logs "success" summonerid = json[n].id; console.log(summonerid); getscore(summonerid); //send function } }); } i getting err

How can I read a text file and save the numbers inside a group to a 5 different lists in python -

i have text file have structure: transactions/sec group = aa\code1\kb 100 200 300 400 500 transactions/sec group = ab\code2\kb 800 300 400 500 600 transactions/sec group = ac\code3\kb 400 300 500 600 700 transactions/sec group = ad\code4\kb 200 200 300 400 400 i read each group , save 5 numbers in 5 different lists. example, read group 1, , create list 1, list 2, list 3, list 4, list 5. read group 2, , numbers list 2, "append" them in list 1, list 2, list 3, list 4, list 5... this did: with open('output.txt') foutput: count = 0 list1 = [] list2 = [] list3 = [] list4 = [] list5 = [] line in foutput: #print line count = count + 1 if 'group' in line: key = line[line.index('=')+1:].strip() #f.write(key) else: value = float(line.strip()) list1 = value

python - Find four numbers in a list that add up to a target value -

below code wrote in attempt solve problem: find 4 numbers in list add x . def sum_of_four(mylist, x): twosum = {i+j:[i,j] in mylist j in mylist} 4 = [twosum[i]+twosum[x-i] in twosum if x-i in twosum] print 4 sum_of_four([2, 4, 1, 1, 4, 6, 3, 8], 8) the answer sample input is: [[1, 1, 3, 3], [1, 2, 3, 2], [3, 1, 3, 1], [3, 2, 1, 2], [3, 3, 1, 1]] however, list of lists contains duplicates. example, [1,1,3,3] same [3,3,1,1] . how can print list of lists without duplicate lists? want efficient possible in runtime , space. possible change list comprehension don't print duplicates? not want sort lists , use set() delete duplicates. want better. a correct , relatively efficient approach starts counting number of times each value occurs in input list. suppose value occurs count times. can append count copies of value list in build selection of values. before appending copies of value , , after appending each copy, make recursive call move on next v

multithreading - GO: runtime: program exceeds 10000-thread limit -

when using go, got error 'runtime: program exceeds 10000-thread limit' . that information goroutine. ' sched 229357ms: gomaxprocs=16 idleprocs=0 threads=8797 idlethreads=8374 runqueue=2131 gcwaiting=0 nmidlelocked=141 nmspinning=0 stopwait=0 sysmonwait=0 ' we can see has 8374 idlethreads, no reason create more thread os. why program exceeds 10000-thread limit? no way provide definitive answer without lot of program code. , doubt can provide simplified example hit problem. 10,000 threads lot of threads. what guess because go creates new thread each goroutine's blocking operations, have lot of goroutines doing blocking calls. i not sure, think each goroutine keeps own blocking call thread , not pooled. having more 10,000 goroutines each make blocking calls may issue. all guesses though. edit: found way increase 10,000 thread limit: https://golang.org/pkg/runtime/debug/#setmaxthreads debug.setmaxthreads(20000)

php - Posting to XML with cURL, Noob here learning -

hi i'm trying program curl. haven't started return me wit server internal error. there wrong given code in curl? <?php'; $now = new datetime(); $url = "smsx.ia.com.my"; $parameters = array( 'userid' => 'something@gmail..com', 'version' => '1.0', 'action' => 'productcreate', 'timestamp' => $now->format(datetime::iso8601), ); // sort parameters name ksort($parameters); $params = array(); foreach ($parameters $name => $value) { $params[] = rawurlencode($name) . '=' . rawurlencode($value); } $strtosign = implode('&', $params); // compute signature , add parameters $parameters['signature'] = rawurlencode(hash_hmac('sha256', $strtosign, $api_key, false)); // build query string $querystring = http_build_query($parameters, '', '&', php_query_rfc3986); // open curl connection $ch = curl_init(); curl_setopt($ch, curlopt_url, $url."

datastax - Is it possible to do sequential batch in cassandra. -

is possible sequential batch in cassandra. eg: insert table1 , take uuid insert operation , pass table2 insert statement. if table 2 insert fails, fail entire operaion. if not , whats best option? (its kind of transactional) you'r best shot cassandra batch statement: batch - cassandra documentation combined "if exists" constraints (like here: delete - cassandra documentation ) may need. however, don't believe there possibility "insert table1 , take uuid insert operation , pass table2 insert statement". can think of batches in c* transactions in sql - it's executed or not. important things note: batches can span multiple tables in c* although batches atomic, not isolated. portion of batch can executed, in query can read changes, may happen revoked because batch fail.

Quick injection of data in C without 3rd party functions -

this code made. objective @ first make abcdef appear on screen least amount of code possible given abc 1 memory space , def memory space. #include "stdio.h" void catstring3(){ char space[10]; char toadd[5]={'d','e','f','\0'}; char *string=space; char *addon=toadd; *string++='a'; *string++='b'; *string++='c'; *string++='def' // how? *string++='\0'; string=space; printf("result: %s\n",string); } void catstring(){ char space[10]; char toadd[5]={'d','e','f','\0'}; char *string=space; char *addon=toadd; *string++='a'; *string++='b'; *string++='c'; while (*addon!='\0'){ *string++=*addon++; } *string++='\0'; string=space; printf("result: %s\n",string); } void catstring2(){ char space[10]; char *string=space;

Python to save needed rows in Excel contents -

Image
i using windows 7 + python 2.76. i trying save specific contents of xls files new files. the original contents looks like: what want save rows “uk” (2nd column) in new files. what doing below: old_file = open_workbook('c:\\1.xls',formatting_info=true) old_sheet = old_file.sheet_by_index(0) new_file = xlwt.workbook(encoding='utf-8', style_compression = 0) new_sheet = new_file.add_sheet('sheet1', cell_overwrite_ok = true) contents = [] row in range(old_sheet.nrows): = old_sheet.cell(row,0).value b = old_sheet.cell(row,1).value c = old_sheet.cell(row,2).value if "uk" in b: contents.append(a) contents.append(b) contents.append(c) c, content in enumerate(contents): new_sheet.write(0, c, content) new_file.save('c:\\file_1.xls') however puts results in 1 row. think it’s because put contents 1 list , write them 1 row. but what’s right way put them? (as number of needed rows uncertai

sql - Workflow control in mysql or oracle -

in mssql, can submit batch query statements workflow control, this: declare @num int select @num = 100 if @num > 0 begin select @num = @num + 1 end how in mysql or oracle (without procedure or function). you can't use if ... then in official mysql outside of stored programs. you can, however, in mysql-compatible mariadb, starting in version 10.1 (currently in beta). now 1 can use begin , if , case , while , loop , repeat statements directly in sql scripts , mysql command line prompt — outside of stored programs. https://blog.mariadb.org/mariadb-10-1-1-compound-statements/

php - Show textarea or div (just below the comment to reply),when i click reply button on comment system javascript not jquery -

so trying make comment system in new site.all comments have reply button id ' replybtn ' which, onclick want show textarea or input field inside div id ' replyform ' right below respective comment. , using php,mysql retrieve comments. <div class='cmt'> <div class='cmttext'></div> <div id='replybtn'></div> <div id='replyform'> <form method='post' ..... > <textarea name='reply' ></textarea> <input type='submit' /> </form> </div> </div> thank you. first question asked on stackoverflow, sorry if have not given sufficient information. try this. plain javascript. modify below want. :) updated it. var varhtml = "<form method='post' ..... ><textarea name='reply' ></textarea> <input type='submit' /> </form>";

python - Django REST Framework nested serializer FK creation -

i'm in trouble creating bunch of related models using drf nested serializers. failing validation on foreign key. models class employee(models.model): user = models.onetoonefield(user) # django user ... class task(models.model): author = models.foreignkey(employee, related_name='tasks') title = models.charfield(max_length=64) ... class employeetarget(models.model): employee = models.foreignkey(employee, null=false) task = models.foreignkey(task, null=false, related_name='employee_targets') ... objective basically have employees created, , want create task , related employeetarget in single request, getting request user author . json request example: { "title": "lorem ipsum", "employee_targets": [ { "employee": 10 }, { "employee": 11 }] } /* or */ { "title": "lorem ipsum", "employee_targets": [10,11] }