Posts

Showing posts from May, 2013

java - How to write event class for a customized listener? -

i'm making game in java need character listen on time event handled in class. i been using this answer make own listener it. so fare have defined interface this: public interface timelistener { public void ontick(timeevent event); } and the timeevent this: public class timeevent { private int time; public timeevent(int time) { this.time = time; } public int gettime() { return time; } } in answer wrote eatevent simple wrapper class food. not quite how that. timeevent cover this? my timeevent, unlike eatevent, needs give time along time class listeners. proper way send time along? simply use observer design pattern it

java - failed to load the JNI shared library "C:\Windows\system32\..\jre\bin\client\jvm.dll\" ECLIPSE -

i working on stuff few days ago , today went open eclipse got error: "failed load jni shared library "c:\windows\system32\..\jre\bin\client\jvm.dll\" " could please help. have looked on 20 stack overflow things , none of them have worked me. looks eclipse cannot find proper jre. make sure have jre or jdk installed , java_home environment variable set valid jre installation path. note 32-bit eclipse work 32-bit jre , same applies 64-bit version. if nothing works can point eclipse jre manually editing eclipse.ini file. see this article details.

c# - Scrolling Background Animation in WPF -

Image
this code: <drawingbrush viewport="0,0,16,16" viewportunits="absolute" stretch="none" tilemode="tile" x:key="dbcheckerboard"> <drawingbrush.drawing> <drawinggroup> <geometrydrawing brush="lightgray"> <geometrydrawing.geometry> <geometrygroup> <rectanglegeometry rect="0,0,8,8"/> <rectanglegeometry rect="8,8,8,8"/> </geometrygroup> </geometrydrawing.geometry> </geometrydrawing> <geometrydrawing brush="white"> <geometrydrawing.geometry> <geometrygroup> <rectanglegeometry rect="8,0,8,8"/> <rectanglegeometry rect="0,8,8,8"/>

python - Wordnet Synonyms not returning all values nltk -

i trying synonyms or similar words using nltk's wordnet not returning. i doing: >>> nltk.corpus import wordnet wn >>> wn.synsets('swap') [synset('barter.n.01'), synset('trade.v.04'), synset('swap.v.02')] i tried doing (from 1 of stackoverflow page): >>> ss in wn.synsets('swap'): sim in ss.similar_tos(): print(' {}'.format(sim)) but not getting synonyms. not want add synonyms wordnet. expecting return exchange,interchange, substitute etc. how achieve this? thanks abhi to synonyms using wordnet , this: >>> nltk.corpus import wordnet wn >>> synset in wn.synsets('swap'): lemma in synset.lemmas(): print lemma.name(), barter swap swop trade trade swap swop switch swap # note overlap between synsets to obtain of words mentioned, may have include hypernyms well: >>> synset in wn.synsets('swap'): hypernym i

c# - How to Add rows to DataGrid containing a combox column -

i have datagrid defined follows: <datagrid autogeneratecolumns="false" height="200" horizontalalignment="left" margin="44,39,0,0" name="datagrid1" verticalalignment="top" width="277"> <datagrid.columns> <datagridtextcolumn header="id" /> <datagridcomboboxcolumn header="value" /> </datagrid.columns> </datagrid> how can bind list of strings datagrid , include items "yes", "no", "maybe" datagridcomboboxcolumn each row? var fruit new list<string> {"apple","orange","banana"}; public class fruit { public string id {get;set;} public string name { get; set; } } xaml <datagrid autogeneratecolumns="false" name="mygrid" margin="10"> <datagrid.columns>

windows - ETW Provider stopped working -

we using etw tracing activities in our applications. when server applications under heavy work, , start tracing our runtime tracing application, our provider doesn't work. , restarting tracing application , server application doesn't , , solution restart windows server! tried xperf , logman commands stop or delete had other problems (we coudn't delete provider after stopping , direct delete wasn't possible because "data collector running"). how can fix without restarting windows? etw has command resetting logs?

vb.net - how to keep the selected checkbox when the form is close? -

i got checkbox , want retain selected ones when reopen form. here's done returns first selected checkbox only.. for each stritm string in str each ctl control in me.controls if typeof ctl checkbox if ctl.text = stritm dim cb checkbox = directcast(ctl, checkbox) cb.checked = true end if end if next next and me out. tnx in advance. more power. an easy way create global bool variable each check box holds true when check box checked , false when it's not. when close form variables keep values. once re-open form can set checked property matching variables through form load event private sub frmmain_load(sender object, e eventargs) handles mybase.load checkbo1.checked = globalvar1 checkbo2.checked = globalvar2 checkbo3.checked = globalvar3 end sub

mongodb - How to paginate output inside mongo shell -

is possible pipe results in pager within mongo shell? the mysql cli equivalent be: mysql> pager less mongo shell paginates results if returned cursor not assigned variable. documentation: ...in mongo shell, if returned cursor not assigned variable using var keyword, cursor automatically iterated 20 times print first 20 documents match query. mongo shell prompt type iterate 20 times. you can set dbquery.shellbatchsize attribute change number of iteration default value 20.

jdbc - Oracle query inside java -

string sql = "insert student_info(name,roll_no,address,phone_no) values('101', 1, 'fatma', '25')"; string sql = "insert student_info(name,roll_no,address,phone_no) values("+student.getname()+","+student.getroll_no()+","+student.getaddress()+","+student.getphone_no()+")"; the last query shows error: java.sql.sqlexception: ora-00917: missing comma at statement.executeupdate(sql); can rule out missing comma? you miss single quotes around student.name, student.address , student.phone_no string sql = "insert student_info(name,roll_no,address,phone_no) values('"+ student.getname()+"',"+ student.getroll_no()+",'"+ student.getaddress()+"','"+ student.getphone_no()+"')"; do notice sql statement vulnerable sql injection attacks. use preparedstatement . s

html - Placing box and text over image z-index -

Image
i want place box , text within box on image. i've managed place text on image can see on screenshot below: by using code: #wrap { position:relative; width: 200px; height: 145px; border: 1px solid grey } #text { z-index:100; position:absolute; color:black; font-size:20px; font-weight:bold; left:10px; top:115px; } and calling function this: <div id="wrap"> <img src="/wp-content/uploads/2014/03/brandslang.png"/> <div id="text">brand</div> </div> i'd add box around text this: i of course have change text color white etc. , idea have text box black , change opacity of box make see thru that. however i'm not sure how add box, tried setting background of #text black didn't work ended painting box around text. i'm not sure how able change texts position using option. so hoping guys me! :) since using position absolute try :

c# - Geting Error "No connection could be made because the target machine actively refused it" -

i creating smart device application client in visual studio 2008. have create web service stock data actual database , save in windows ce device compact database on button click event of smart device application. here code: private void btngetdata_click(object sender, eventargs e) { serviceagent.inventorysev ws = new invetorydevice.serviceagent.inventorysev(); asynccallback cb = new asynccallback(servicecallback); ws.begingetinventorydata(cb, ws); } private void servicecallback(iasyncresult ar) { serviceagent.inventorysev ws = (serviceagent.inventorysev)ar.asyncstate; datatable dt = ws.endgetinventorydata(ar); } i geting error: datatable dt = ws.endgetinventorydata(ar); error: system.net.webexception unhandled message="unable connect remote server" stacktrace: @ system.net.httpwebrequest.finishgetresponse() @ system.net.httpwebrequest.getresponse()

python - Get a unique list of strings in pandas after a split() operation -

i'm getting started pandas, , have one column of data in larger dataframe such 0 1 2 1 2 7 6 2 3 1 5 3 7 5 five 8 4 6 4 5 3 dtype: object and i'd split sequences of words component parts, unique set or counts words. can split fine numbers.str.split(' ') 0 [one, two] 1 [two, seven, six] 2 [three, one, five] 3 [seven, five, five, eight] 4 [six, four] 5 [three] dtype: object however, i'm not sure go here. again, i'd have output such ['one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight'] or same in dictionary counts, or in series/dataframe equivalent of 1 of these two. the best i've been able far use apply() in combination set unique words. pandas elegant package i've seen far, , seems within easy reach kn

asp.net mvc - Claims-Based Authorization with Angular.JS and WIF -

we have application built asp.net mvc 5. application, we've built several url-related html helpers act this: imagine there anchor leads url, i.e. /customer/edit/5. have helper in background ask claimsauthorizationmanager (which part of windows identity foundation api) whether current user can perform action edit on resource customer. if yes, html markup anchor tag rendered. otherwise, nothing rendered. with these helpers, we've been able have dynamic website based on background policies define url's user can access based on specific claims. now need push same logic angularjs based spa. so again, goal skip rendering of url-related html if user not allowed access particular url. i've not been able find resources on how perform kind of authorization angularjs. is there proper way or should go custom logic? there references can read on? angular works great in restful applications. in case, set app fetch claims json , set angular template render acco

android - How to implement multi device log in? -

my app allows registered users log in. my current implementation log in user, register sessionid on server's db , on mobile device itself. if these 2 match, authenticated , logged in. however poses problem when user has multiple devices (iphone, android, tablets etc). because unless logged out previous session, server's db retain current session , prevent logging in other devices. hope can share solution handle multi device log ins.

java - How to retrieve many columns using jpql? -

i have problem retrieving info class. @entity public class absence { @id @generatedvalue(strategy= generationtype.identity) private int absenceid; private int crn; private int studentid; @temporal(temporaltype.date) private date absencedate; } i want retrieve following information : studentid, student name ,number of absences. problem query doesn't work. query using public list<studentabsencesummary> getsetionabsences(int crn) { query q=em.createquery("select b.studentid,count(b.studentid) absence b b.crn =:crn group (b.studentid)") .setparameter("crn", crn); list<studentabsencesummary> students =q.getresultlist(); return students; } the class of retrieved list public class studentabsencesummary { private int studentid; private string name; private int absencecount;

bash - Check if a file exists inside a "Variable" Path -

i trying find if file exist in iphone application directory unfortunately, apps directory differs device another on device, use following command see if file exists: if [[ -f "/var/mobile/applications/d0d2b991-3cda-457b-9187-1f02a84ff3ab/appname.app/filename.txt" ]]; echo "the file exists"; else echo "the file not exist"; fi i want command automatically search if file exist without need specify "variable" name inside path. i tried this: if [[ -f "/var/mobile/applications/*/appname.app/filename.txt" ]]; echo "the file exists"; else echo "the file not exist"; fi but no luck, didn't find file, maybe because have 2 path of /var/mobile/applications/*/appname.app/ since have cloned app. i way able find if file filename.txt exists inside folder named appname.app inside directory /var/mobile/applications/*/ you can follows: [[ $(find /var/mobile/applications/*

android layout - Why is my image clipped after scaling? -

i having strange problem. scale image and, while scaling works correctly, image gets clipped. tried different scale types - things changed never make work. just clear, here's need solve: 1. have horizontalscrollview around imageview , scrollview around horizontalview . 2. scroll around (using scrollto of both scroll views) and, upon event, zoom in. 3. i'd happen imageview scale around current scroll position. here's layout: <?xml version="1.0" encoding="utf-8"?> <framelayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <scrollview android:layout_width="match_parent" android:layout_height="match_parent" android:scrollbars="none" android:overscrollmode="never"> <horizontal

c# - Application breaks with System.FormatException(not correct input type?) -

im making treegenerator training , im taking input console splitting array while trying split error saying system.formatexception(not correct input type) console.writeline("input number of branches, treefoot, , branch char"); string[] input = console.readline().split(' '); int nb = int.parse(input[1]); char tf = char.parse(input[2]); char bc = char.parse(input[3]); your index 0 not int in string, text in string . you got indices wrong, use 0,1,2 int nb; bool ok = int.tryparse(input[0], out nb); // ok true if parsing succeeded char tf = char.parse(input[1]); char bc = char.parse(input[2]); you should use int.tryparse() see if int parsing succeeded.

How to create a static member in clojure -

i have class(created deftype) , want make several static members deserialize on it. tried add theirs signatures in interface is'nt worked me(code below). (definterface inmk (serialize []) (deserialize [string]) (print [])) (deftype nmklinear [^:volatile-mutable ^:volatile-mutable b ^:volatile-mutable x-sum ^:volatile-mutable y-sum ^:volatile-mutable xy-sum ^:volatile-mutable xq-sum ^:volatile-mutable n] inmk (serialize [this] (str "{\"a\":" " \"b\":" b " \"x-sum\":" x-sum " \"y-sum\":" y-sum " \"xy-sum\":" xy-sum " \"xq-sum\":" xq-sum " \"n\":" n "}")) (deserialize [str] (let [j (json/read-str str :key-fn keyword)] (nmk

c# - Mass Transit unable to deserialize collections with exactly one element -

i've got mass transit message interface this: public interface iperson { icollection<personalname> names { get; } } public class personalname { public string familyname { get; set; } public string givenname { get; set; } public string secondname { get; set; } public string use { get; set; } } and works serializing , deserializing message using jsonmessageserializer . can serialize message using xmlmessageserializer , , result looks bit this: <person> <names> <familyname>simpson</familyname> <givenname>homer</givenname> <secondname>jay</secondname> <use>official</use> </names> <names> <givenname>homie</givenname> <use>nickname</use> </names> </person> and can deserialize if collection empty or if has more 1 element. however, if collection contains exactly one element, when g

javascript - Form select option to change what gets rendered -

ruby on rails 4 form drop down selection. if multiple choice selected want render page. if true/false selected want render different page. i not know why isn't working, javascript knowledge bad: <h1>new question</h1> <%= form_for(@question) |f| %> <%= render 'shared/error_questions' %> <%= render 'form', f: f %> <%= f.fields_for :answers |builder| %> <div id="mcanswers" style="display:none"> <h1>answers</h1> <%= render 'four_answers', :f => builder %> <%= f.submit "create question", class: "btn btn-lg btn-primary" %> </div> <div id="tfanswers" style="display:none"> <h1>answers</h1> <%= render 'tf_answers', :f => builder %> <%= f.submit "create question", class: "btn btn-lg btn-primary" %> </div> <% end %> <% end %> <hr /> &l

c# - Switching to artificial key with different type in Entity Framework Migrations -

i'm working on entity framework code first project where, previously, had class field called "id" string type , using hash. that's specified this: [key] public string id { get; set; } that's no longer need because updates can have duplicate values, want change this: [databasegenerated(databasegeneratedoption.identity)] public int id { get; set; } [required] [index] public string hash { get; set; } //this represents used id i ran trouble , went digging , found a bug report suggesting work in entity framework 6.1.0, i've updated, it's still not working me. hand-entered sql migration file set hash column id value before gets blown away, update fails when goes update foreign keys because can't figure out how go alphanumeric nvarchar int. of course, i'd insert integer id corresponds old hash. is there nondestructive way can achieve this? well, little bit hesitant post solution ended going with, because feels bit of hack, sin

java - Regex to remove all words starting with number -

i have following content stored in set: ...4tccs,4ug,5,50,6,6tccs,7,7ug,7west,8,8226,9,9fall,9west,a,aad,academic,account,acres,acresthis,acronyms,add,by,calendar,campus,campuses,can,capc,carey,catalog,catalogs,cd... this snippet of overall data. have store data file don't want store words starts number. so please suggest me regex remove words these. you can match: "\\b\\d[^,]*(?:,|$)" and replace with: ""

java - ArrayList generics -

could me explain ma.add(new highrights("aaa")); does? main class: public static void main(string [] a){ arraylist<securityrights> ma=new arraylist<securityrights>(); ma.add(new highrights("aaa")); } highrights class: public class highrights extends securityrights { private string name; public highrights(string n){ super(true); this.name = n; } public string getname(){ return name; } public static void main(string[] a){ highrights s= new highrights("lisa"); system.out.print(s.getname() +" "+s.getsecret()); } } this simple inheritance example. ma.add(new highrights("aaa")); it adds new object of highrights class list<securityrights> array list ma . highrights extends securityrights this inheritance. possible store child object highrights parent object securityrights . please

java - At a complete loss: mapping a simple entity via Hibernate -

i can't figure out why object not map via annotations. no matter try, receive error: org.hibernate.mappingexception: unknown entity: com.hibernate.practice.car i loosely following tutorial here can't seem working. i've tried strip object down bare bones (thinking making error in code somewhere), again, id, , name column, still fail working. my hibernate.cfg netbeans hibernate tutorial. <?xml version="1.0" encoding="utf-8"?> <!doctype hibernate-configuration public "-//hibernate/hibernate configuration dtd 3.0//en" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <property name="hibernate.connection.driver_class">com.mysql.jdbc.driver</property> <property name="hibernate.connection.url">jdbc:mysql://localhost:3306/practicedb?zerodatetimebehavior=converttonull</property> <prope

asp.net mvc 4 - Use Partial Views between multiple mvc application -

i have scenario like, define template footer of website in partial view. have written footer template in partial view. partial view placed in folder name "common" in views. now want use footer partial view in mvc application, because used same footer template. how can refer partial views in multiple applications, having partial views in class library? please guide me go right way. regards, karthik.

replication - How to configure a replica set with MongoDB -

i've got problem can't solve. partly because can't explain right terms. i'm new sorry clumsy question. below can see overview of goal. i want configure replication set in mongodb tried use local db.dropdatabase() config = { _id: "rs0", members:[ {_id: 0, host: 'localhost:27017'}] } rs.initiate(config) i hope every thing correct here showing following error message { "errmsg" : "server not running --replset", "ok" : 0 } anything wrong did here ? any ideas ? you can follow mongodb manual setup replica set. it's pretty clear. here critical steps described below: change configuration file , add following line.don't mess master/slave replication, because replica set meant replacement of master/slave replication. may want remove master/slave related config configuration files. replset = [set name] restart mongod instance: systemctl restart mongodb // or service mongod restart go loc

c# - How to reduce the execution time in Parallel.ForEach function? -

code: parallel.foreach( infomap, map => { var workitem = map.workitem; var parentinviews = viewmaps; var workbenchitem = map.workbenchitem; string linktype = string.empty; workitemlinkcollection linkedworkitems = workitem.workitemlinkhistory; if (linkedworkitems != null && linkedworkitems.count > 0) linktype = linkedworkitems[0].linktypeend.linktype.referencename; else if (workitem != null) linktype = workitem.store.workitemlinktypes.linktypeends["parent"].linktype.referencename; if (!string.isnullorempty(linktype)) { var viewmap = parentinviews.firstordefault(); if (viewmap != null) { var linkname = linktype; var childtype = viewmap.childtype; ilinkitem itm = factory.buildlinkitem(linkname, workbenchitem, workbenchitem); lock (addparents)

android - Initialize a Bluetooth connection in an activity and use the connected bluetooth device in a service -

i want select , connect bluetooth device (serial communication) in activity , use same connection in service. service works in background , calculations , send string bluetooth connection arduino device every time location changed. the service runs long desroy it. i want know how can use same connection activity in service.

Implement Web Services in PHP & JavaScript. -

i want use web services ajax php , javacript, thied exemple still have error. tried lot of code, please me. xmlhttprequest cannot load xxxxx/login.php. no 'access-control-allow-origin' header present on requested resource. origin 'null' therefore not allowed access. index.html:1 index.html <html><head> <script src="jquery-2.1.0.js"></script> <script src="jsjsjs.js"></script> </head> <body> <div id='logindiv'> <label>username:</label> <input name="username" id="username" type="text"> <label>password:</label> <input name="password" id="password" type="password"> <input value="submit" name="submit" class="submit" type="submit" onclick='chk_ajax_login_with_php();'> <d

javascript - Test is URL is valid (server response = 200) -

i trying check if url provided user in form valid one, i.e. if server's response 200. i want run check when user has typed in field , when loses focus. because of same origin policy, run check on server side: client side code: // test url when input loses focus angular.element(document).ready(function () { $('#target_url').focusout(function() { if ($('#target_url').hasclass('ng-dirty')){ $http.post('/test-url', { target_url: scope.newjob.target_url }).success(function(response){ if (response === 'valid url'){ console.log('valid url'); }else{ console.log('url not valid'); } }); }; }); }); server side: // url testing route app.post('/test-url', function(req, res) { request(req.body.target_url, function (err, respon

javascript - Issue with JS from fields obtained through Ajax response -

i use datatables in order create nicely displayed , managable table. data use ajax data source , prepared php script connect database , echo on screen date in json format. assign.php $q = "select o.id, a.id aid, o.starttime,o.scid, count(case when v.severity = '0' 1 else null end) zero, count(case when v.severity = '1' 1 else null end) one, count(case when v.severity = '2' 1 else null end) two, count(case when v.severity = '3' 1 else null end) three, o.starttime start topic a, project v, person o a.id = v.topic_id , a.id = o.topic_id , o.starttime = '".$_get['date']."' group o.id,o.starttime,o.scid,a.id order id desc"; $result = $db->query($q)->fetchall(pdo::fetch_assoc); $arr = array(); foreach ($result $row){ if ($row['scid']==1){ $button="<button id=\"opener_".$row['aid']."\" class =

multiple sorting in backbone.js -

sorting in backbone it's working fine. want sort multiple fields, passing sort argument dynamically clicking sorting headers. have 5 headers(id,desc,type,category,hierarchy). when click headers it's sort ascending , next click descending problem sort 1 attribute want multiple attribute pass collection , maintain previous sorting order , again sort till data relative. in collection: sortasc: function(sortfield) { var key = sortfield; this.comparator = function(model) { return model.get(key); }; this.sort(); }, sortdesc: function(sortfield) { var key = sortfield; this.comparator = function(a, b) { = a.get(key); b = b.get(key); return < b ? 1 : > b ? -1 : 0; } this.sort(); }, view: called when click header(click event) , elem id (dynamically change on click) id,,desc,category,type , hierarchy. sortitems: function(e) {

matlab - Resample and anti-alias FIRLS filter order -

i have audio files recorded in 48khz sampling frequency. have examine audio characteristics , need lower sampling frequencies see when start fail. going test downsampled audio files @ 24khz, 16khz, 12khz, , 8khz. i found matlab function resample(x,p,q,n) . it's easy understand there's 1 thing i'd ask. in description says applies anti-alias firls filter during re-sampling process. understandable. don't know should apply n because accuracy depends on n parameter. values should use obtain decent results in downsampling. help. also, says if downsample high low sampling frequency should in intermediate stages. suggest on this. cheers! :) you can use easier command y = decimate(x,r) the documentation mentions "for better results when r greater 13, divide r smaller factors , call decimate several times.", highest factor of 6 times decimating don't have worry. the default 8th order iir , 30th order fir seem sufficient me, if doubt them can

c - #include does not see the function definition -

i have .c , .h file: misc.c #include "misc.h" int isallzeros(int *arr, int l) { int i; int allzeros = 1; (i = 0; i<l; i++) { if(arr[i]) { allzeros = 0; break; } } return allzeros; } int containsdup(int *arr1, int *arr2, int l1,int l2) { int i,k; int dup = 0; (i = 0; i<l1; i++) { (k=0;k<l2;k++) { if(arr1[i] == arr2[k]) { dup = 1; break; } } if (dup) break; } return dup; } and misc.h #ifndef misc_h #define misc_h #include "ext.h" #include "ext_obex.h" #include "ext_path.h" typedef struct _mnote { t_uint32 t; t_uint8 note, vel; } t_mnote; typedef struct _mped { t_uint32 t; t_uint8 state; } t_mped; typedef struct _note { t_uint32 t, length; t_uint8 note, vel; } t_note; typedef struct _chordind { int

Faster way to get row data (based on a condition) from one dataframe and merge onto another b pandas python -

i have 2 dataframes different indices , lengths. i'd grab data asset column asset_df if row matches same ticker , year. see below. i created simplistic implementation using for-loops, imagine there fancier, faster ways this? ticker_df year ticker asset doc 2011 fb nan doc1 2012 fb nan doc2 asset_df year ticker asset 2011 fb 100 2012 fb 200 2013 goog 300 ideal result ticker_df year ticker asset doc 2011 fb 100 doc1 2012 fb 200 doc2 my sucky implementation: for in ticker_df.name.index: c_asset = asset_df[asset_df.tic == ticker_df.name.ix[i]] if len(c_asset) > 0: #this checks see if there asset data on company asset = c_asset[c_asset.fyear == ticker_df.year.ix[i]]['at'] if len(asset) > 0: asset = int(asset) print 'g', asset, type(asset) ticker_df.asset.ix[i] = asset

How to pass variables that are arguments in user defined functions to subfunctions in r -

i have general problem in understanding how create user defined function can accept variables arguments can manipulated inside defined function. want create function in can pass variables arguments internal functions manipulation. appears many of functions want use require c() operator requires quotes around arguments. so function has able pass name of variable dataframe quotes c() , other functions requiring quote strings. read through many post on paste0 , paste , cat(x) , cannot figure out how solve problem completely. here simple dataset , shortened code structure problem. here want able provide dataframe, , 3 variables. function should provide mean of variable in y position each combo of x , z variable. resultant aggregate table should have names of variables provided arguments xtabar column headers. n=50 datatest = data.frame( xcol=sample(1:3, n, replace=true), ycol = rnorm(n, 5, 2), catg=letters[1:5]) xtabar<- function(ds,xcat,yvar,group){ library(plyr)

javascript - How to create a horizontal sliding sub-menu panel for my site? -

i want create horizontal sliding sub-menu site. when click on menu item 2 sub-menu panel show/hide sliding function or that. just example, it's not i'm copyrighting or - godaddy.com navigation menu. here - jsfiddle there few things want in menu - fades out whole page when menu expand. when click anywhere else sub-menu on fade out page, sub-menu panel auto collapse. and collapse when click same menu item again. it slideup , slidedown smoothly. html <div id="header"> <div id="main-header" class="center"> <div id="menu"> <ul> <li><a href="#">menu item 1</a> </li> <li><a href="#" id="button" onclick="showhide()">menu item 2</a> </li> <li><a href="#">menu item 3</a>

java - Using Collections.sort to sort an ArrayList of a specific object -

so have seen multiple questions addressing similar problems mine, not able find 1 problem. i have arraylist of contact objects, , want sort them using collections.sort: public void sortcontactarraylist(){ arraylist<contact> newlist = new arraylist<contact>(); collections.sort(newlist); } in order this, made contact implement comparable<contact> . and, compareto method looks this: @override public int compareto(contact othercontact) { return this.getname().compareto(othercontact.getname()); } however, receiving error when calling collections.sort(newlist); the error is: "bound mismatch: generic method sort(list<t> ) of type collections not applicable arguments ( arraylist<contact> ). inferred type contact not valid substitute bounded parameter <t extends comparable<? super t>> " does know issue is? said, have seen similar problem customized list of objects " contactdatabase<contact> "

sqlalchemy - How to use descriptors in sqlachemy.orm.synonym -

i have code working fine: def get_timestamp(ts): return datetime.utcfromtimestamp(ts) def set_timestamp(dt): return time.mktime(dt.timetuple()) class group(base): __tablename__ = 'group' _created = column('created', integer, nullable=false) @property def created(self): return get_timestamp(self._created) @created.setter def created(self, value): self._created = set_timestamp(value) i want code this, it's not working: created = synonym('_created', descriptor=property(get_timestamp, set_created)) because passed in self 1st param. i'd use get_timestamp , set_timestamp across project of cause. i'm not going make them methods of class stand alone function. how can achieve this? edit : take option2, , still open other answers. option-1 : code below should work (you not need have class in order define self ): def pget_ti

where will I will get mysql 5.6 developer certification exam model paper -

where oracle mysql 5.6 developer exam 1z0-882 sample questions beneficial exam. friends in advance this blog entry oracle's todd farmer should help http://mysqlblog.fivefarmers.com/2013/10/15/exam-cram-preparing-for-the-mysql-5-6-certification-exams/ has has provided practice sections in linked articles under ("index")

java - Eclipse - Wrapped lines' indentation appears & disappears each time I save -

each time click save entire file's formatting alternates between these 2 formats: this.getobject() .method() .method(); this.method(arg1, arg2, arg3, arg4); and this.getobject() .method() .method(); this.method(arg1, arg2, arg3, arg4); i want stick first format. i have same problem current eclipse configuration. think eclipse bug. my guess problem related option: java code style -> cleanup -> code organizing -> correct indentation getting in conflict with java code style -> cleanup -> code organizing -> format source code which should fix indentation according formatter settings. i disabled option correct indentation in both java code style -> cleanup , java editor -> save actions -> additional actions -> configure... , problem seemed disappear.

datagridview - WPF edit autogenerated column header text -

Image
i'm using wpf datagrid display datatable 's. need able edit bound datatables (two-way binding). i'm using datagrid followed: <datagrid selectionunit="cellorrowheader" isreadonly="false" autogeneratecolumns="true" itemssource="{binding path=selecteditem.bindablecontent, fallbackvalue={x:null}}" /> the problem have, user can't edit columnheader 's cell content or rows. screenshot below illustrates porblem. thing can sort columns. there way edit column headers too, example when user clicks twice, or presses f2 . maybe style ' or headertemplate job? have tried styles , control templates i've found around internet, without success. edit: i managed display column headers in textbox (and not in textblock ) within autogeneratingtextcolumn event handler: private void _editor_autogeneratingcolumn(object sender, datagridautogeneratingcolumneventargs e) { // first: create , add data template parent

import - Set LD_LIBRARY_PATH before importing in python -

python uses pythonpath environment-variable determine in folders should modules. can play around modifying sys.path , works nicely pure python-modules. when module uses shared object files or static libraries, looks in ld_library_path (on linux), can't changed , platform dependent far know. the quick-fix problem of course set environment-variable or invoke script ld_library_path=. ./script.py , you'll have set again every new shell open. also, .so files in case in same directory .py file, may moved absolute path, i'd set them automatically every time invoke script. how can edit path in python interpreter looks libraries platform-independently on runtime? edit: i tried os.environ['ld_library_path'] = os.getcwd() , no avail. i use: import os os.environ['ld_library_path'] = os.getcwd() # or whatever path want this sets ld_library_path environment variable duration/lifetime of execution of current process only. edit: looks need

string - Treat a Character as a variable -

suppose have following code a<-c(1,2,3) b<-'a' now treat string in 'b' variable 'a' when input function or operation. imagine "treat.as.variable()" real function this: treat.as.variable(b)+c(1,2,4) [1] 2 4 7 is there function this, predefined? or way in general? use get function > get(b) + c(1,2,4) [1] 2 4 7

sql - Syntax error when updating -

i'm bit of noobie when come sql, i'm using access 2013 , i'm trying update date field in 1 table, using id numbers different table update specific ones. the query have is: update leadsavailable set first_usage_date = '23/04/2014' leadsavailable r inner join workingtable_gosh g on g.[lead number] = r.[lead number] g.type = 'gosh' but keep getting errors , don't know why. any appreciated try sorry im in mobile: update leadsavailable inner join workingtable_gosh b on a.[lead number] = b.[lead number] set a.[first_usage_date] = '23/04/2014' b.type = 'gosh';

c# - Why is a bool's default val (false) not recognized? -

this question has answer here: why must local variables have initial values 4 answers with code: bool successfulsend; const string quote = "\""; string keepprinteron = string.format("! u1 setvar {0}power.dtr_power_off{0} {0}off{0}", quote); string shutprinteroff = string.format("! u1 setvar {0}power.dtr_power_off{0} {0}on{0}", quote); string advancetoblackbar = string.format("! u1 setvar {0}media.sense_mode{0} {0}bar{0}", quote); string advancetogap = string.format("! u1 setvar {0}media.sense_mode{0} {0}gap{0}", quote); if (radbtnbar.checked) { successfulsend = sendcommandtoprinter(advancetoblackbar); } else if (radbtngap.checked) { successfulsend = sendcommandtoprinter(advancetogap); } if (successfulsend) { messagebox.show("label type command sent"); } i get, " use of unassigned l

resources - How do I reference elements from other resouces? -

i working on xml using fhir resource. found element of resource cross reference other resources. e.g. in encounter (resource), element :serviceprovider cross reference resource(organization). in such case, there way specify elements of resource(organization) on encounter (resource) xml such can validated correctly? i think you're asking is: can constrain information care have captured organization associated encounter (as opposed organization communicated in other manner or context). example, encounter, might want name , phone number while in other contexts may want other information. if that's indeed you're looking for,, solution profile. create profile on encounter and, serviceprovider reference organization, on "type" element, in addition "code" element indicating "organization", you'd specify "profile" element pointing structure wanted enforced on content of organization. structure might defined in same

html5 - Are there any custom semantic html tags project for designing html pages? -

i found semantic ui project here: http://semantic-ui.com/ semantic structured around natural language conventions make development more intuitive. for example bellow code creates menu using semantic : <nav class="ui menu"> <h3 class="header item">title</h3> <a class="active item">home</a> <a class="item">link</a> <a class="item">link</a> <span class="right floated text item"> signed in <a href="#">user</a> </span> </nav> instead of bootstrap css classes: <div class="navbar"> <a class="navbar-brand" href="#">title</a> <ul class="nav navbar-nav"> <li class="active"><a href="#">home</a></li> <li><a href="#">link</a></li> <li><a href="#&

php - How to register mails with shell_exec and plesk 11? -

i want create free e-mail service. i'm using vserver 200gb (for first time) on debian 6 parallels plesk 11 backend. now want simple php script guests register new mail (for themselves). i've asked programming friend if me, did. he has written script this: <form method="post" action=""> <input type='hidden' name='submitted' id='submitted' value='1'/> <label for='email' >email address:</label> <input type='text' name='email' id='email' maxlength="50" /> <br> <label for='password' >password*:</label> <input type='password' name='password' id='password' maxlength="50" /> <input type="submit" name="submit" value="submit" /> </form> <? function sanitize($data) { $data = strip_tags(trim($data)); $search = array('/[^a-za-z0-9\. -\!\

xpath - Behat/Mink - trouble finding buttons -

my application under test has been developed external suppliers have no control on html structure. application extremely javascript , ajax heavy, numerous dynamically generated buttons , auto-complete lists. in other words, characteristics of pages filled with: elements no fixed ids (ids generated on fly , have numbers or other text dynamically added them) the same happens classes most of times buttons have no text associated them since either custom coded 'down' arrows lookup lists (which aren't lookup lists hidden divs) or '+' , '-' icons maximise or minimise portions of content. - it therefore difficult identify these elements, buttons. i trying write generic 'i click on button near y' type of step not necessary hardcode each , every button (assuming can identify them with) each , every test. the thinking behind there label of sort close button @ least. what want to find text label, see if there button inside same scope, , if t