Posts

Showing posts from March, 2013

c# - Json.NET parse array in object -

i'm having extremely difficult time parsing multiple arrays out of array, embedded in several object in json. basically json looks like { took:8, success:true, items:[ keywords:{...}, maininfo:{ name:'...', expdate:'...', targetcities:[...], targetstates:[...] }, additionalinfo:{ skills:[], hometime:'' } } my c# looks like: public class job{ public string name{get;set;} public list<string> targetcities{get;set;} public list<string> targetstates{get;set;} public list<string> skills{get;set;} public string hometime{get;set;} } public class jobs{ private jobject o; private list<job> jobs; public jobs(string json){ this.o=jobject.parse(json); } public list<job> tolist(){ list<jobject> alljobs=o["items"].select(t => (jobject)t).tolist(); foreach(jobject in alljobs){ job j=new job(); j.name=(string)i["maininfo"][&q

python - pytee can not produce proper output in python3 -

i have piece of code runs in python 2.7.5 doesn't work python 3. the major problem tee.write , can not write file. this piece of code suppose write 20 letters a file /tmp/tee-test-1 , /tmp/tee-test-2 not, 2 files empty… could 1 give me advice? import sys import os import subprocess #from netsa.util.shell import * string import template __author__ = 'brandon sandrowicz <brandon@sandrowicz.org>' __version__ = '0.1' valid_modes = ['a','w'] def create_tee(files, mode, buffer_size=128): if mode not in valid_modes: raise ioerror("only valid modes create_tee() are: %s" % ', '.join(valid_modes)) tee_list = [] file in files: if type(file) == str: fp = open(file, mode) tee_list.append(fp) else: tee_list.append(file) pipe_read, pipe_write = os.pipe() pid = os.fork() if pid == 0:

Python: how to pass a index range as parameter -

i know possible, there other way pass 0:100 ? a=range(1000) ohlc.c.ix[a] thank you! pass slice object. a = slice(0, 100)

how to scale an image on python-opencv? -

when tried scale photo in python gives me error: indentationerror: unindent not match outer indentation level my code: cv.setimageroi(image, (pt1[0], pt1[1],pt2[0]-pt1[0], int((pt2[1] - pt1[1]) * 0.6))) the problem indentation in python. in python code must aligned when in same scope.

django - how to make python __FILE__ display symbolic path when accessed use symbol path -

the __file__ convenient macro designed access current file path in python. there's issue when use it. have file /home/a/b.py when accessed directory __file__ macro in b.py should give /home/a/b.py correct. created symbol link under /var/www/a -> /hom/a when b.py accessed /var/www/a expect macro in b.py give path /var/www/a/b.py . not case. although file accessed form symbol path /var/www/a, macro still giving real file path /home/a/b.py i've tried abspath , realpath in python os package. there api can peel out symbolic path wanted? you can use first argument command line if script called full path. here's example ran: import sys print(sys.argv) from command line: python test.py # results in ['test.py'] python /full/path/test.py # results in ['/full/path/test.py']

How to parse PHP output that has multiple arrays -

ok i'm using btc-e api , i'm calling using this: $btc_usd = $btceapi->getpairticker('btc_usd'); // show information print_r($btc_usd); and output print array ( [ticker] => array ( [high] => 640.04199 [low] => 605.00201 [avg] => 622.522 [vol] => 4217103.07651 [vol_cur] => 6723.54768 [last] => 636.1 [buy] => 636.1 [sell] => 635.999 [updated] => 1394418227 [server_time] => 1394418228 ) ) how parse returns/prints number [last] example: so output looks "636.1" can save variable. this array of arrays. outer element ticker : $btc_usd["ticker"]["last"];

ios - tabbarcontroller + navigation. How to make so that landscape one representation had an orientation -

i created application in has: viewcontroller , navigationviewcontroller , tabbarviewcontroller . i have many tabs , respectively many representations. problem when click 1 tab there should portrait orientation. when click following tab should have representation types of orientation. precisely understand want, start skype application on iphone. first tab can't pass landscape, second can't transfer. if opening chat should possible transfer mode of orientation. i tried add following code, works in navigationcontroller not in tabcontroller . tabcontroller : int test = 0; public override uiinterfaceorientationmask getsupportedinterfaceorientations() { int = 0; foreach (var v in viewcontrollers) { if (v.gettype () == typeof(createcompviewcontroller)) { test = i; break; }i++; } int s = test; test++; if (

java - Throwing exceptions in other classes -

i need make changes 2 classes. so, exceptions thrown when necessary. and, have class in program called checkemptyexception , extends runtimeexception . make these changes other 2 classes? in classes there 2 methods called public boolean isempty() .

sql - Create new Table when submit the form -

now have table : propertytable - ( id, property , owner_name , date , location) and kinda input statement : id : _________ property : ________ owner_name : _________ date : _________ location : ________ submit then, each time user submit form want system create new table : ownertable - ( owner_name , date , location)

excel - Trying to set up a summary sheet for data validation -

i've created workbook friend owns own business. workbook includes sheet each month, data validation determine service, price, products, etc. indicates method of payment. she's asked update summary sheet not show totals per month, show total each method of payment. i'm having hard time finding right way this. since change each client, imagine i'll have sort of if statement, don't have enough experience able write out (at least not in excel). any appreciated. thanks!

java - Expand multiple JTree nodes when user expands a node -

i have large jtree displayed in swing panel. i've implemented nodes extend defaultmutablenode, calculate children dynamically, , working well. in cases (specifically, when expanded node has 1 child), i'd jtree expand more 1 node when use clicks expand element (recursively expanding child nodes long there 1 child, perhaps limit. for example, if had following tree: a - b - b2 - b3 - b4a - b4b - c - d and user clicks expand b node, i'd b b2, , b3 nodes expanded right away. jtree has public void addtreewillexpandlistener(treewillexpandlistener tel) so should implement interface public interface treewillexpandlistener extends eventlistener { /** * invoked whenever node in tree expanded. */ public void treewillexpand(treeexpansionevent event) throws expandvetoexception; /** * invoked whenever node in tree collapsed. */ public void treewillcollapse(treeexpansionevent event) throws expandvetoe

php - Using new Js and Css scripts in Wordpress -

i developing wordpress plugin. want plugin work on many wordpress installations possible. in order use various js , css scripts in plugin. want make use of wp_register_script( $handle, $src, $deps, $ver, $in_footer ); my doubt that, eg. have use plupload functionality. on referring documentation. http://codex.wordpress.org/function_reference/wp_enqueue_script#link_scripts_only_on_a_plugin_administration_screen . found plupload script included under default script. how determine, wordpress installation has script default. wordpress version. not have manually add scripts part of plugin. thanks in advance browsing wordpress versions, see /wp-includes/js/plupload/ introduced on version 3.3 . can creat check versions lower 3.3 in register_activation_hook (and display admin_notice or abort installation). or enqueue alternative script if version lower. from here , function check current version if ( ! function_exists( 'is_version' ) ) { function is_ver

java - Set Object name from String -

i have create objects using reflection, facing problem how set name of instance specified in string e.g. string contains: new instancename java.util.arraylist where instancename refers new instance of arraylist, know how create object through reflection cannot figure out way assign specific name instance string. help? in advance. the name of variable references created object not define object, , can't assigned during runtime. create "name" referece object, , can use object later through "script" (the strings mention), need implement yourself. one way have map<string, object>, add name , points value (of map) object every time create new object (when processing strings example). problem approach if never delete map entries, object never freed memory garbage collector. fix that, should have way in "script" tell when free object created.

excel - Dynamically Pick a Dynamic Range -

i've spent several hours trying come clean solution this, , don't seem able to. basically, have several dynamic ranges have defined, , want select 1 based upon condition. seems straightforward! reason want select dynamic range can graph range. indirect not work. dindirect (a common vba algorithm) not work. (or can't them to) choose works! however, maximum length of dynamic range reached, means i'm forced inane solutions following. i define dynamic_dynamic =if(a1<3,choose(a1,'worksheetname'!dynamic_range_1, 'worksheetname'!dynamic_range_2),'worksheetname'!dynamic_dynamic_2) then define dynamic_dynamic_2 =if(a1<5,choose(a1-2,'worksheetname'!dynamic_range_3, 'worksheetname'!dynamic_range_4),'worksheetname'!dynamic_dynamic_3) then define dynamic_dynamic_3 =if(a1<7,choose(a1-4,'worksheetname'!dynamic_range_5, 'worksheetname'!dynamic_range_6),'worksheetname'!dyn

Mqtt for Arduino (CC 3000) -

i'm planning use cc 3000 (wi-fi) arduino communicate cloud. i'm wondering have mqtt client arduino supporting cc 3000? there fork of arduino client mqtt available claims support cc3000 hardware: https://github.com/nathanchantrell/pubsubclient

javascript - Ember.js Save Up and Down Vote to the Data -

i used jsfiddle ( http://jsfiddle.net/chopper/ggggd/22/ ) stackoverflow question ( how handle votes in ember.js? ) add , down voting ember site. in fiddle, data lives inside app.js, have no backed database. the , down voting works, not save data, resets on page refresh. how save change when upvotes appreciated! controller app.themecontroller = ember.objectcontroller.extend({ actions: { voteup: function () { console.log("voting up"); this.set('votes', this.get('votes') + 1); }, votedown: function () { console.log("voting down"); this.set('votes', this.get('votes') - 1); } } }); data app.themes = [ { id: 1, title: 'decode', price: '$0', free: true, description: 'a minimal, modern theme, designed mobile first , responsive, decode built ghost , uses ghost\'s innovative features present beautiful , clean blog.', columns: 1, popular: true, purchase

How can I create files , read and write files in Python? -

all tutorials can find follow same format isn't working.i don't error message don't normal output. appears file description @ memory location. # file_test ftpr= open("file","w") ftpr.write("this sample line/n") a=open("file","r") print #this result <open file 'file', mode 'r' @ 0x00000000029dddb0> >>> do want read contents of file? try print a.readlines() . ie: with open('file', 'w') f: f.write("hello, world!\ngoodbye, world!\n") open('file', 'r') f: print f.readlines() # ["hello, world!\n", "goodbye, world!\n"] fyi, with blocks , if you're unfamiliar them, ensure open() -d files close() -d.

system verilog - Sequence item generating 'X' or unknown value -

i have started seq item on sequencer generate seq item random constraints item generated has many "x" values. reason behind this? here code: virtual task run_phase(uvm_phase phase); begin uvm_test_done.raise_objection(this,"started sequence"); `uvm_info(get_type_name(),"inside run_phase of base test:\n", uvm_low) fork #10; spi_m_seq.start(spi_env_inst.spi_master.spi_sequencer); #300; join uvm_test_done.drop_objection(this,"sequence finished"); end endtask:run_phase the systemverilog lrm states constraint solve can handle 2-value logic. means x's have due uninitialized 4-state logic types in class. here's , example of mean: package some_package; class some_class; rand logic[15:0] field1; logic[15:0] field2; function void print(); $display("field1 = %x", field1); $display("field2 = %x", field2); endfunction endclass endpackage module top;

php - How can I get the all value in one column using result() -

model: function get_all() { $query = $this->db->get('loan'); return $query->result(); } function get_loan_name($code) { $this->db->where('loan_type_code',$code); $query = $this->db->get("loan_type"); return $query->row(); } controller: function index() { $this->data['loans'] = $this->loan_approval->get_all(); $this->build_view("loan_approval/list.php"); } in "loan table" have "loan_type_code" column want value in column , match 2nd function. example loan table loan type table id loan_type id loan_type_code loan_type_name 1 edl 1 edl education loan 2 df 2 df damayan fund i need match "loan_type" in table "loan" "loan_type_code" in "loan type"

sql - Complex SP for monthly sales returning wrong data -

i try explain problem, , simplified 2 needed tables important in procedure: **table 1: book_sales** identifiers sales_price sales_date store quantity **table2: discount** identifiers sales_price (the changed / discounted price) from_date to_date if to_date in discount table '2999-01-01' should overwrite sales price in book_sales (in example is: 99,-) if from_date , to_date in discount table period, lets from_date: 2014-02-03 , to_date 2014-02-05 should overwrite other prices period. (in example 69,-) my stored procedure supposed return data this: +------------+-----------+---------+----+-----+ | 2014-02-01 | itemname | item01 | 3 | 99 | | 2014-02-02 | itemname | item01 | 2 | 99 | | 2014-02-03 | itemname | item01 | 2 | 69 | | 2014-02-04 | itemname | item01 | 2 | 69 | | 2014-02-05 | itemname | item01 | 2 | 69 | | 2014-02-06 | itemname | item01 | 2 | 99 | +------------+-----------+---------+----+-----+ but showing both , returning d

javascript - How to find two default submit buttons when i press the Enter key in asp.net using jquery? -

i have 2 default submit button in single web page.. 1 in main form.. , 1 button inside div control.. div control popup @ login button click event.. when popup div.. div has submit button , when press enter key.. button needs submit.. if div closed.. press enter key main form submit button need submit values.. how can find 2 submit buttons on enter key press using jquery? please help. thank you.. when popup shows up, set focus submit button of popup div: $('div.popupclass').find('button[type="submit"]').focus(); and, when popup closed, switch focus main form: $('body').find('button[type="submit"]').focus(); if using jquery-ui's dialog, put lines in open: , close: calls.

api - Gson Deserialization error: com.google.gson.JsonSyntaxException: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was STRING -

i've seen many questions on topic, can't seem find solution problem. i'm getting deserialization error: com.google.gson.jsonsyntaxexception: java.lang.illegalstateexception: expected begin_object string @ line 1 column 3384 when deserializing routingtable clas specifically, decerialization works else. i've uploaded serialized json data here: http://jsonfiddle.net/bx0ga class serialize: public class routingtable { private transient final node localnode; // current node private final kadbucket[] buckets; { buckets = new kadbucket[nodeid.id_length]; } // methods.... } kadbucket class: public class kadbucket implements bucket { private final int depth; private final map<nodeid, node> nodes; { nodes = new hashmap<>(); } // methods , on } serialization code: have serialization class handles serialization using generics: public class jsonserializer<t> implements kadseriali

caching - How to drop memory cache periodically in Linux? -

working on system measurement project , requires me drop cache periodically accurate number (since having cache there alter results). can manually drop cache using: echo 3 > /proc/sys/vm/drop_caches however, want automatically drop every microsecond. command should use? you create own command that, i.e. write program that. example, like: while (1) { if ((fp = fopen("/proc/sys/vm/drop_caches", "r")) == null) { /* error handler */ } fprintf(fp, "3\n"); fclose(fp); nanosleep(...); /* see nanosleep(2) */ } in program, , made daemon.

javascript - when the dynamic stylesheets is applied? -

i load style.css dynamically in javascript. when style loaded, i'll calculation depends on styles. code this: link = document.createelement('link'); link.href = 'sheety.css'; link.rel = 'stylesheet'; document.head.appendchild(link); link.onload = function(){ //some code //here, can't the correct style sometime. //but of time, can correct style settimeout(function(){ //here, can correct style }, 1000); }; so, question is: when style applied successfully? if modify element's position(width, height), can correct value instant, or must wait time let browser using settimeout() function? i read resources says: call dom.getcomputedstyle cause browser reflow. indeed call method, still wrong width/height of dom. when debug js code in chrome, can see style not applied @ break point (from style tab in chrome developer tools). once style sheet loaded, cssom or cssobjectmodel generated. along dom, cssom raste

Apache-Camel: How to put more than one Ical File in exchange -

i have processor puts unmarshaled ical file in custom object. after list of object saved exchange. after need put second ical exchange. problem cant use "from" 2 times in route. how can solve this? code processing 1 ical following: from("file://src/test/resources?filename=calendar.ics&delete=false&noop=true") .unmarshal("ical") .process(icstobeanprocessor) .end(); perhaps can improve design bit. instead of specifying filenames use directory instead. process files present in directory , set them in header properties. like from("file://src/test/resources?delete=false&noop=true") .unmarshal("ical") .process(icstobeanprocessor) // in icstobeanprocessor set header property content.filename output of unmarshaller bean .end(); also can more specific using regex specifying filenames. case pick files ends "ics". see http://camel.apache.org/file.html more details.

sql server - PHP PDO connect to MS SQLServer Express using SSL -

i have remote ms-sql express 2012 server set use ssl. have certs need. how can create pdo connection server using ssl? have found plenty of articles pdo mysql using ssl, none ms-sql using pdo , ssl. (microsoft os only) in order connect securely, append 'encrypt=true' connection string. valuable blog on topic . also of note: make sure using: microsoft drivers make sure aren't using: outdated wrong driver the drivers located here: microsoft provided drivers .

How to improve a brute-forcing algorithm using groups? -

i got excercise in have guess password using brute-forcing algorithm. charset 'a-z' , length varies between 3 , 6. with 2gb of ram i'm getting memory allocation errors after couple of hours on examples 5 , 6 characters. asked teacher , told me bruteforcing using groups of 3, don't know how approach this. i don't know instructor meant, should ask him or clarification. however, why need lot of memory? don't need keep possible passwords in memory, 1 you're trying now.

d - Learning GtkD - especially custom painting -

i've downloaded gtkd, , i'm trying find resources online me learn it. however, of find either gtk+ (which looks different gtkd syntactically), or limited in scope (such this ). there resources out there have missed? how learning gtk+ understanding gtkd? can tell, quite different in terms of code. well, answer not go far 'nothing @ all', maybe it'll of use. gtkd wrapper around gtk+. means, there's one-to-one correspondence between functions. also, means object models same. e.g. there such entities windows, buttons, etc. have relations, like, button can placed on window. conceptually, of objects , relations same both gtkd , gtk+ (v3.x). and gui toolkit object model important thing study , understand. also, it's biggest thing. so, if understand model: objects there , how can used - you'll successful in writing gui apps using either gtk+ or gtkd. the syntactical difference you'll need overcome pretty trivial compared this. i sugge

c# - not wrap ListItem Text in Horizontal CheckBoxList -

Image
i have dynamic checkboxlist : <%@ control language="c#" autoeventwireup="true" codefile="projectorigin.ascx.cs" inherits="usercontrol_pem_aspx_projectorigin" %> <div style="display:block;"> <asp:checkboxlist id="checkboxlist1" runat="server" repeatdirection="horizontal" > </asp:checkboxlist></div> and add listitems in function private void chklistboxinit() { if (checkboxlist1.items.count != 0) return; checkboxlist1.items.clear(); desprovider p = new desprovider(); list<tbldes> list = p.getbydesgrpid(grpid).orderby(a => a.desid).tolist(); listitem li; foreach (var l in list) { li = new listitem(l.desf, l.val); checkboxlist1.repeatlayout = repeatlayout.flow; checkboxlist1.items.add(li); } } the html generated is: <div style="display:block;&q

asp.net mvc - C# How to initilization a variable in class? -

i'm creating billing address user shipping including (first name, last name, address 1, address 2...) based on mvc music store project [httppost] public actionresult addressandpayment(formcollection values) { var order = new salesorderheader(); var order1 = new salesorderdetail(); tryupdatemodel(order); try { if (string.equals(values["promocode"], promocode, stringcomparison.ordinalignorecase) == false) { return view(order); } else { order.accountnumber = user.identity.name; order.orderdate = datetime.now; order.address.addressline1 = values["addressline1"]; order.address.addressline2 = values["addressline2"]; order.address.city = values["city"]; //save order bikedbs.salesorderheaders.add(order);

java - NullPointerException on getPlacesUrl(params[0]) -

i using included placeprovider.java tutorial regarding setting searchview , integrating google places api. code tutorial seems quite buggy- @ least in terms of integrating existing code. particular error being thrown mainactivity starts. loads second , error thrown: 03-10 00:17:27.716: e/androidruntime(7895): fatal exception: modernasynctask #1 03-10 00:17:27.716: e/androidruntime(7895): java.lang.runtimeexception: error occured while executing doinbackground() ... 03-10 00:17:27.716: e/androidruntime(7895): caused by: java.lang.nullpointerexception 03-10 00:17:27.716: e/androidruntime(7895): @ java.net.urlencoder.encode(urlencoder.java:92) 03-10 00:17:27.716: e/androidruntime(7895): @ com.....placeprovider.getplacesurl(placeprovider.java:266) 03-10 00:17:27.716: e/androidruntime(7895): @ com.....placeprovider.getplaces(placeprovider.java:290) 03-10 00:17:27.716: e/androidruntime(7895): @ com.....placeprovider.query(placeprovider.java:88) where begin in terms o

c - sprintf corrupting arrays in IAR microcontroller -

i learning embedded programming, , working on iar-platform using ti microcontroller arm architecture. since not @ familiar technicalities related kind of programming, or c programming in general, ask basic question: i have following simple code snippet: int i; for(i = 0; < num_samples; i++) { sintable[i] = sinf(2*i*dt*pi); } for(i = 0; < num_samples; i++) { char out[32]; sprintf(out,"sin: %.7f, %.7f;", i*dt, sintable[i]); putstring(out); delay(delay_100us); } where sintable[] global variable of size num_samples , putstring(*char) function writes rs232-port, , delay(float) simple delay-function. my problem once sprintf(...) called, corrupts sintable , giving peculiar results when plotting table on receiver end of com-signal. i don't expect run out of memory, mc has 64kb sram. does have thoughts? ensure stack pointer on 64-bit boundary when main reached. the symptom seeing typical of stack aligned on odd 32-bit bo

javascript - How can I identify when a copy process in node.js is finished? -

this first steps node.js. watch directory chokidar added files. if copy process finished script should called. don't know how can identify when copy process finished , file complete available on directory. console log command word finish never appear. var fs = require('fs'); var chokidar = require('chokidar'); var watcher = chokidar.watch('/root/documents/gw/', {ignored: /^\./, persistent: true}); watcher .on('add', function(path) { console.log('file', path, 'has been added'); fs.watchfile(path, function(curr, prev) { if (curr.size == prev.size) { console.log('finish'); // todo start shell script } else { console.log(curr.size); } }); }); i use node.js version 0.10.25 on linux system. thanks in advance help! the reason test never positive on simple copy operation fs.watchfile won't generate event previous si

javascript - Edit the response in ExpressJS -

i'm trying edit response request in express. when request xhr request, want return body inside javascript object (this return different parts of page different pieces in javascript object, i.e. { header: '<header></header>', footer: '<footer></footer>' } . i can't seem find part of response object holds actual response. direction think i'm meant go, can't work. app.use(function(req, res, next) { res.on('send', function() { if(req.xhr) { //if page requested ajax, return json res.body = {body: res.body}; } }); next(); }); you'll want monkey-patch send method app.use(function(req,res,next){ var send=res.send; res.send = function(){ //use arguments here body out (won't first property if there's response code passed through) console.log("sending",arguments); send.apply(res,arguments); } ne

performance - How much is the overhead of smart pointers compared to normal pointers in C++? -

how overhead of smart pointers compared normal pointers in c++11? in other words, code going slower if use smart pointers, , if so, how slower? specifically, i'm asking c++11 std::shared_ptr , std::unique_ptr . obviously, stuff pushed down stack going larger (at least think so), because smart pointer needs store internal state (reference count, etc), question is, how going affect performance, if @ all? for example, return smart pointer function instead of normal pointer: std::shared_ptr<const value> getvalue(); // versus const value *getvalue(); or, example, when 1 of functions accept smart pointer parameter instead of normal pointer: void setvalue(std::shared_ptr<const value> val); // versus void setvalue(const value *val); std::unique_ptr has memory overhead if provide non-trivial deleter. std::shared_ptr has memory overhead reference counter, though small. std::unique_ptr has time overhead during constructor (if has copy provided dele

android - keeps listview data between activities -

in android application have 2 activities(act1,act2).in act1 have gridview , data , when click 1 item start act2.in act2 have multi column listview , data , when press button data can add list.the problem when act1 , select item gridview , act2 again starts , listview becomes empty(because listview adapter in act2 oncreate method).but need previous data in list.if there idea save or keep listview data between activities.or common method or class can used insert items listview. act1(menuactivity) gridview.setonitemclicklistener(new onitemclicklistener() { public void onitemclick(adapterview<?> parent, view v, int position, long id) { // show message box particular name //toast.maketext(getapplicationcontext(),((textview) v.findviewbyid(r.id.vegname)).gettext(), toast.length_short).show(); textview name=(textview) v.findviewbyid(r.id.vegname); textview price=(textview) v.findviewbyid(r.id.vegprice);

Is it possible to run Apache for one domain and Lighttpd for another domain on one server? -

hello every professional ! have apache running on standard 80 port serves of domains/subdomains on dedicated server. need install lighttpd on same server serve 1 specific domain , it's subdomains - separately apache. my first question - possible under 1 physical dedicated server ? second question - if it's possible - how separate them ? basic settings must lighttpd ? (i've heard apache run on 80 port , lighttpd on 81 port, that) have real knowledge such symbiosis ? have nice day ! apache , lighttpd 2 servers, can run them other 2 servers, long listen different ports. don't have experience apache , lighttpd apache , nginx , worked fine. just install both servers , make sure specify correct ports. otherwise if 1 of them try register used ports fail. afterwards start them , enjoy. in apache can specify ports should listen in ports.conf listen <portnumber> more here: http://httpd.apache.org/docs/current/bind.html i don't know lighttpd ther

css3 - Including LESS/SASS framework in RhoMobile Studio -

how include less or sass css framework in rhomobile application?? want application recognize .less or .css.scss files,use mixins , media queries. how can achieve that?? thanks. update: after installing sass gem , running task created in rake file,my original css file not getting executed , in console output: cmd: vcbuild/m4 rhodes.sln "release |win32" * rake aborted! * no such file or directory - vcbuild you need preprocess , convert css before compiling. done creating rake task preprocess scss files, generating css output and, finally, invoking actual rhodes compile task. update: you installing sass gem (gem install sass) , adding end of rakefile: task :compile_scss_and_run dir.chdir $app_path system "scss --update public\\css\\*.scss" end rake::task["run:win32"].invoke end please change 'run:win32' task used compile rhodes app. after, run on command line: rake compile_scss_and_run . in layout.erb file must

python - Searching from a list of word to words in a text file -

i trying write program reads text file , sorts out whether comments in positive, negative or neutral. have tried sorts of ways each time no avail. can search 1 word no problems more , doesn't work. also, have if statement i've had use else twice underneath wouldn't allow me use elif. i'm going wrong appreciated. in advance. middle = open("middle_test.txt", "r") positive = [] negative = [] #the empty lists neutral = [] pos_words = ["good", "great", "love", "awesome"] #the lists i'd search neg_words = ["bad", "hate", "sucks", "crap"] tweet in middle: words = tweet.split() if pos_words in words: #doesn't work positive.append(words) else: #can't use elif reason if 'bad' in words:

c# - standard procedure WINAPI DllMain environment .Net dynamic loading dll -

prompt how can implement analog standard procedure winapi dllmain environment. net dynamic loading. dll bool winapi dllmain (     in hinstance hinstdll,     in dword fdwreason,     in lpvoid lpvreserved   ); i want have method in c# library executed when loaded? there's no direct equivalence this, however, can create static class (or @ least static constructor class) executed when class used first: public class mylibraryfactory { static mylibraryfactory() { // add static initializer code here. // called when class first referenced or used. } } this constructor called before other method using class. there's no guarantee first thing called inside library, compiler ensures else executes inside library independent of class, won't notice difference.

javascript - Angular inheritance in factories -

in current project working angular in front first time , having little problem extending "classes" true factories. case: have 3 types of markers can placed on map. 1. assigned markers. 2. unassigned markers. 3. panned markers. i have base marker object engine.factory('marker', ['map','icons', function (map, icons) { var marker = function marker() {}; marker.prototype.mouseover = function mouseover (e) { e.target.seticon(this.icons[this.icononhover]); }; marker.prototype.mouseout = function mouseout (e) { e.target.seticon(icons[this.icon]); }; return marker; }]); and trying make panned marker engine.factory('pannedmarker', ['map', 'marker', 'icons', function (map, marker, icons) { var pannedmarker = {}; pannedmarker.prototype = new marker(); return function pannedmarker(location, id) { this.id = id; this.location = location; this.icon = 'purple'; this.icononhover = 

java - Netbeans not compatible with maven 3.1.1, ignores maven-distributed dependency -

maven projects using apk (android-maven-plugin 3.8.2) packaging displayed "unloadable" in netbeans 7.4 (using maven 3.1.1) because netbeans fails find following dependency: <dependency> <groupid>org.eclipse.sisu</groupid> <artifactid>org.eclipse.sisu.plexus</artifactid> <version>0.0.0.m5</version> <scope>system</scope> <systempath>/opt/maven/lib/org.eclipse.sisu.plexus-0.0.0.m5.jar</systempath> </dependency> as can see, tried convince netbeans @ correct place, seems insist on finding inside m2 local repository , fails because maven silently skips jar download. command line execution of maven fine. anyone knowing temporary fix that? looks sufficient switch netbeans' internal maven (which version 3.0.5 , incompatible android-maven-plugin) , resolve project issues, because old maven version downloads dependency local repo. after download,

sql server - sql update with aggregate functions in where clause -

i have table these fields >>> i want number of s-id=1 >>>>relevancy value updated 2 (s-id)(relevancy) 0 null 0 null 3 2 4 null 4 null 4 null 4 null 5 2 9 null here code: select s-id,count(s-id) ccc group s-id update ccc set relevancy=2 count(s-id)=1 but figured aggregate function can't used in clause,what should now? update ccc set relevancy = 2 (select count(*) ccc c2 c2.[s-id] = ccc.[s-id]) = 1 demo (last row's relevancy updated 2 since 9 unique) another option using cte count(*)over : with cte ( select [s-id], relevancy, cnt = count(*) on (partition [s-id]) ccc ) update cte set relevancy = 2 cnt = 1 demo

java - Not able to get data from request in Junit when action class implements ParameterAware -

i need write junit struts 2 action class.but action class implementing "parameteraware" interceptor takes parameter map in hashmap , action class takes request parameter hashmap action class: public class brokeraction extends actionsupport implements servletrequestaware, servletresponseaware,sessionaware, parameteraware { /** parameters. */ private map parameters; @override public void setparameters(final map param) { this.parameters = param; } public string getparametervalue(final string param) { final object varr = getparameters().get(param); if (varr == null) { return null; } return ((string[]) varr)[0]; } public string getbrokerdetails()throws pactexception{ string id = getparametervalue("id"); } when putting data junit in request hasn't reflected in parameters map junit: @test public void testgetactionproxy() throws exception {

c# - select all rows in gridview without paging -

i have gridview 100 rows paging turned on (showing 20 rows @ time). there checkbox in each row select record. in header there "check all" checkbox when check select 20 current page. is there way have select 100 rows out resizing size of page (have show 100 rows). thanks add field checked in datalist , , set value according checked checkbox.

http - any python tools to build a complex url with get parameters? -

i wonder if there library allows me build complex urls lot of parameters. following: request = { 'protocol': "http", 'hostname': "www.example.com", 'port': "80", 'page': "/foo/bar/example.php", 'parameters': { 'foo': "spaced parameter", 'quuz': 42 } } url = urlbuilder.build(request) at point variable url contain following string: http://www.example.com:80/foo/bar/example.php?foo=spaced%20parameter&quuz=42 any ideas? you write tool yourself, example this: class urlbuilder(object): def build(self, request): url = [ request['protocol'], '://', request['hostname'], ':', request['port'], request['page'], ] pars = request['parameters'] if len(pars): u

php - Accessing object property with variable -

i have object full of arrays, able change element in array code $i = 0; $object->property[$i] = "some value"; however following code not change value , returns no errors. $i = 0; $propertyname = "property"; $object->$propertyname[$i] = "some value"; try: $i = 0; $propertyname = "property"; $object->{$propertyname}[$i] = "some value";

multithreading - MailboxProcessor and interaction with GUI Thread -

i've created agent interacting gui means of synchronizationcontext: type asyncworker(id:int) = let someevent = new event<int * string>() let errorevent = new event<_>() let synccontext = synchronizationcontext.current let f (inbox: mailboxprocessor<_>) = let rec loop () = async { let! message = inbox.receive () ... synccontext.raiseevent someevent (id, str) } is there danger in that? if had 20 agents? these raised events synchronized? suppose have long time calculating function event. can sure other agents' event handlers waiting termination?

node.js - nodejs/express - cannot load routes using passport -

i trying use passport add user sessions on webapp. have configure main js file follow: /** * module dependencies. */ var express = require('express'); var user = require('./server/routes/user'); var routes = require('./server/routes/index'); var http = require('http'); var path = require('path'); var app = express(); var passport = require('passport'); var flash = require('connect-flash'); require('./server/config/passport')(passport); // pass passport configuration // environments app.set('port', process.env.port || 3000); app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'ejs'); app.use(express.favicon()); app.use(express.logger('dev')); app.use(express.json()); app.use(express.urlencoded()); app.use(express.methodoverride()); app.use(app.router); app.use(require('stylus').middleware(pat

c# - Passing Text Box Values from a user control file to another class file -

i looking pass values on ascx.cs user control file class file in project. need able values of dynamic text boxes user control able put them in database. here have far user control file public void page_load(object sender, eventargs e) { itembox.text = request.form[itembox.uniqueid]; numberbox.text = request.form[numberbox.uniqueid]; descriptbox.text = request.form[descriptbox.uniqueid]; } other class file viewstate[viewstatekey] = int.parse(viewstate[viewstatekey].tostring()) + 1; loadpagecontrols(); rowid ++; string box1value = request.form[itembox.text]; string box2value = request.form[numberbox.uniqueid]; string box3value = request.form[descriptbox.uniqueid]; string sconnection = generic database address; i have seen other people using method pull data over. can't syntax right , keeps giving errors. i tried because saw here c# textbox value class , thought work, no joy strin

javascript - Poor Image Quality Inserting Google Charts into a PDF using JSPDF -

i'm trying render pdf view of reporting page contains google charts display data. going converting chart url encoded jpeg. image quality @ stage still once add pdf document using jspdf image quality severely reduced. here's jsfiddle of current method: http://jsfiddle.net/5c5yx/3/ function getimgdata(chartcontainer) { var chartarea = chartcontainer.getelementsbytagname('svg')[0].parentnode; var svg = chartarea.innerhtml; var chartdoc = chartcontainer.ownerdocument; var canvas = chartdoc.createelement('canvas'); canvas.setattribute('width', chartarea.offsetwidth); canvas.setattribute('height', chartarea.offsetheight); canvas.setattribute( 'style', 'position: absolute; ' + 'top: ' + (-chartarea.offsetheight * 2) + 'px;' + 'left: ' + (-chartarea.offsetwidth * 2) + 'px;'); chartdoc.body.appendchild(canvas); canvg(canvas, svg);