Posts

Showing posts from March, 2013

java - The algorithm compares two lists, synchronization tables -

the algorithm compares 2 lists list, synchronization tables i need synchronize local table table loaded server. decided compare 2 stages list (local list , server). initially, list sorted. remains landmark in comparing of id. if id on local list is, , server not present, removal of entries local database (delete). if id equal local server , update (update). if id server there, , there no local, add (select). problem have in phase comparison, somewhere wrong, not foreseen. i throw off comparison algorithm, began write, not finish image , example. please modify it. image example: http://c2n.me/3mmgizg list<integer> server = new arraylist<>(); list<integer> local = new arraylist<>(); databasehandler db = new databasehandler(context); iterator<integer> seriter = server.iterator(); iterator<integer> lociter = local.iterator(); int item1 = seriter.next(); int item2 = lociter.next(); while(seriter.hasnext()) { if (item1 <item2) {

multithreading - Read/write in simple client-server app in Java -

i'm new java , i'm trying learn threads , socket. decide make simple client-server application following official java tutorial. idea simple - server wait connection, if appears, makes new thread new socket, input , output. client side -> make connection; new thread socket, input, output , stdin (to read line , after send server). wrong (don't have idea why) code. connection established, there's no exceptions. explain why doesn't work , how fix it? have suggestions code (probably it's not best practices , things that): client side: public class client { private bufferedreader reader; private socket sock; private printwriter writer; public static void main(string[] args) { client client = new client(); client.go(); } public void go() { setupnetworking(); } private void setupnetworking() { try{ sock = new socket("127.0.0.1", 5000); system.out.println("network established"); serv

PHP Calendar with wrong start date for august 2015 -

i have got above code about.com. works except august 2015. start date should saturday calendar shows monday instead. other months have checked far correct. any hint? <?php function calendar() { date_default_timezone_set('utc'); $date = time(); // removed orginally. if (isset($_request['emonth'])&& isset($_request['eyear'])){ $month = $_request['emonth']; $year = $_request['eyear']; } else { $month = date('m', $date); $year = date('y', $date); } $first_day = mktime(0,0,0,$month, 1, $year); echo date('d', $first_day); $title = date('f', $first_day); $day_of_week = date('d', $first_day); switch($day_of_week){ case "sun": $blank = 0; break; case "mon": $blank = 1; break; case "tue": $blank = 2; break; case "wed": $blank = 3; break; case "thu

Continuing USSD request (Android) -

it known menu driven ussd applications got it's pre defined order of taking parameters in. example user sends #111# (sri lanka), , gets menu of 12 sub items select sending sub menu number back. may ask select 1 set of sub menu. send number etc. etc. , send pin, send phone number reload (if reloading) send yes(1) no(2) confirm 99 finish ussd event. have succeeded sending continues signals vb.net phone using nokia asha 501 (using bluetooth outgoing com port) follows. strcommand = "at+cusd=1," & chr(34) & "#111#" & chr(34) & ",15" & vbcrlf comport.write(strcommand) thread.sleep(5000) this bring ussd menu. datareceivedhandler of com port port.datareceived can give if there error returned com not open error dialing ussd. next send response string contains "ok" strcommand = "at+cusd=1," & chr(34) & "1" & chr(34) & ",15" & vbcrlf compor

javascript - Populate grid with row/column coordinates in extjs -

i'm trying populate extjs grid data json. values need populate in cells in object gives row , column number. i'm not sure how values correct cells json structure. here json: { "_links" : { "self" : { "href" : "http://localhost:8080/api/reports" } }, "columns" : [ { "softwarebuild" : { "buildid" : 10, "generation" : "alpha", "build" : "1.0" }, "eventtypedisplay" : "event name 1" }, { "softwarebuild" : { "buildid" : 10, "generation" : "beta", "build" : "2.0" }, "eventtypedisplay" : "event name 1" }], "entries" : [ { "row" : 0, "column" : 0, "value" : 10 }, { "row" : 0, "column" : 1, "value&qu

php - Form not submitting correct value from datatable -

looks simple may overlooking here. (document).ready(function(){ $('#data').datatable(); } if (isset ($_post ['deleteuser'])) { echo "<p>received form data</p>"; echo $_post['hidden']; } <form action="" method="post"> <table id="data"> <thead> <tr> <td>first name</td> <td>delete name</td> <td>email</td> <td></td> </tr> </thead> <tbody> <?php $cursor=$collection->find (); foreach ( $cursor $document ) { ?> <tr> <td class='first_name'> <?php echo $document [ "first_name"]; ?> </td> <td class='last_name'> <?php echo $document [ "last_name"]; ?> </td> <td class='ema

java.lang.NoClassDefFoundError: android.support.v7.widget.* since upgrading to Support Library v23 -

i'm using materialdialog library in app. yesterday i've updated library version latest, , since it's using new annotations, had update support v7 library well. ever since, no screen widget ( checkbox / radiobutton ) can loaded. here stack : 08-30 21:53:10.418: e/androidruntime(30341): fatal exception: main 08-30 21:53:10.418: e/androidruntime(30341): process: com.xx.xxx, pid: 30341 08-30 21:53:10.418: e/androidruntime(30341): java.lang.noclassdeffounderror: android.support.v7.widget.appcompatcheckbox 08-30 21:53:10.418: e/androidruntime(30341): @ android.support.v7.internal.app.appcompatviewinflater.createview(appcompatviewinflater.java:89) 08-30 21:53:10.418: e/androidruntime(30341): @ android.support.v7.app.appcompatdelegateimplv7.createview(appcompatdelegateimplv7.java:886) 08-30 21:53:10.418: e/androidruntime(30341): @ android.support.v7.app.appcompatdelegateimplv7.oncreateview(appcompatdelegateimplv7.java:940) 08-30 21:53:10.418: e/androidruntime(3

Sails.js installed globally in system npm directory, but looks inside node.js modules directory incorrectly -

node.js v0.12.7 installed on windows 10 via msi installer. sails.js v0.11 installed npm install -g sails but when attempted create new sails project via sails new testproject got this: error: cannot find module 'c:\program files\nodejs\node_modules\sails\bin\sails.js' @ function.module._resolvefilename (module.js:336:15) @ function.module._load (module.js:278:25) @ function.module.runmain (module.js:501:10) @ startup (node.js:129:16) @ node.js:814:3 the solution copy sails.js modules npm directory c:\users\username\appdata\roaming\npm node.js modules directory c:\program files\nodejs\node_modules . the problem is... want know why sails looking inside node.js modules directory, , why/how correctly set node/sails such issue not have occurred.

Java Using Arguments in a Complex Formula -

i new java, , reading book on now. book not give me answer. using following code: package loanpayments; public class loanpayments { public static void main(string[] args) { double years = double.parsedouble(args[0]); double p = double.parsedouble(args[1]); double r = double.parsedouble(args[2]); double r = r / 100; double = p*(math.e*math.exp(r*years)); system.out.println(a); } } i testing code following values: years = 3 p = 2340 r = 3.1 first have divide r 100 correct value (in case becomes 0.031). new value of 0.031 becomes capitalized r. use formula find a. i getting incorrect output of ~6980.712, when output should instead ~2568.060. i thinking put in formula wrong, should this: p e ^r(years) in case e euler's number (~2.71828) if advise me on how fix formula, or other mistake, appreciate it, thanks. not needed multiply e because math.exp() exponential function.

javascript - Angular 2.0 and ng-style -

i building angular 2.0 component , want control it's style dynamically (using ng-style ). after quick view on angular 2's docs tried this: <div class="theme-preview" ng-style="{'font-size': fontsize}"> {{fontsize}} </div> and saw size printed inside div did not affected style. fontsize 1 of component's property bindings', meaning component gets parent this: <my-component [font-size]="size" /> while inside component have: @component({ selector: 'xxx', properties: ['fontsize'] }) am missing here? update people still reach answer, i've updated plnkr beta.1. 2 things have changed far ngstyle no longer necessary explicitly added in directives property. it's part of common directives added default. the syntax has changed, must camel case. example @component({ selector : 'my-cmp', template : ` <div class="theme-preview" [ngstyl

php - How to add new custom field in Magento 1 customer address -

we have tried answer its working customer edit form, issue is, we have used magestore onestepcheckout, also have added <li> <div class="one-field"> <input onkeyup="validateelement(this.id)" type="text" title="<?php echo mage::helper('core')->quoteescape($this->__('govt id')) ?>" name="billing[govt_id]" id="billing:govt_id" value="380051" class="input-text" required/> <span class="highlight"></span> <span class="bar"></span> <label class="required" for="billing:govt_id"><?php echo $this->__('govt id') ?> <em>*</e

stata - how do I remove one factor level in R? -

i need drop variables data frame in r. data has column 18 factors: agriculture fisheries ... unclassified i need remove factor #18 before creating dummy variables "the person x works in y industry". is, need keep first 17 levels (the classified levels) in stata remove level drop if rama1 == 99 (rama1 factor column , 99 "unclassified") then create dummies in stata (one binary variable per industry) run: quietly tabulate rama1, generate(rama1_) that in r is: for(i in unique(data$rama1)) { data[paste("type", i, sep="")] <- ifelse(data$rama1 == i, 1, 0) } any ideas? highly welcome to remove levels, either way approached bondeddust or jlhoward works fine. create dummy variables, depend on want/how want formulated. for example, removed factor, want rows show <na> or 0 . base r the easiest way using model.matrix in base r. building on example bondeddust; df <- data.frame(x=as.factor(sample(le

label - How do i change command's name from toolbar programmatically in rcp? -

i creating command programmaticaly: final command commandadd = commandservice.getcommand( "editor.commands.macro.add1"); commandadd.define( "add", "add macro", commandservice .getcategory( "editor.category.macrogroup" ) ); then create contribution item , add toolbar: commandcontributionitemparameter addmacroparameter = new commandcontributionitemparameter( servicelocator , "", commandadd.getid(), commandcontributionitem.style_push ); commandcontributionitem add = new commandcontributionitem(addmacroparameter); toolbarmanager.add(add); right toolbar has button "add" in it. problem if run code again, change name "add" lets "insert" : final command commandadd = commandservice.getcommand( "editor.commands.macro.add1"); commandadd.define( "insert", "add macro", commandservice .getcate

performance - Fast list of top level directories in a tar -

i have tar file on 100gb in size, thousands of files in, , i'm trying find way list top level fast. i've seen people using --exclude , grep still has go through of file names first, in case take long time. is there way this?

activerecord - Rails - undefined method `username' for nil:NilClass -

i'm making website , has articles , comments too, articles not associated users because admin can create articles...but there comments associated users , articles when try show username of user create comment, in comment section of article give me error "undefined method `username' nil:nilclass" models user model has_many :comments article model has_many :comments comment model belongs_to :article belongs_to :user articles controller comments shown def show @article = article.find(params[:id]) @comments = @article.comments end and view <h2>comments <%= @comments.count %></h2> <% @comments.each |comment| %> <%= comment.content %> <%= comment.user.username %> <% end %> comments controller comment created def create @article = article.find(params[:article_id]) @comment = comment.new(comment_params) @comment.article = @article @comment.user = current

c# - Unexpected output from checking if mouse within control -

i implementing custom drag , drop interface winform buttons , after viewing several solutions on how obtain mouse position , check against control bound have not been able work. i have tried: button.clientrectangle.contains(pointtoclient(cursor.position)) and button.clientrectangle.contains(pointtoclient(control.mouseposition)) both of these have failed work. checking mouse bounds seem simple operation, stumped. my speculation of unexpected values are: process of obtaining cursor position may in wrong corner of cursor image method/function not work on buttons reason you using wrong object reference, calculating mouse position relative form instead of button. , writing in way make hard debug. fix: var pos = button.pointtoclient(cursor.position); system.diagnostics.debug.writeline(pos); // easy if (button.clientrectangle.contains(pos)) { // etc... }

xpath - Web Crawling using import.io -

i trying crawl following website https://goo.gl/thqdhd using import.io tool. used connector tool parse whole search result specific query (and include pagination), , chosen rows in search result, unable select items'image box (as column) import.io contain manually xpath overriding selected, tried select images in search results using following xpath: .//*[@id='container-inner']/div[3]/div[4]/div[*]/div[1]/div/a/ which should represent columns of table, got following problem what have selected not within result the result here previous selected rows, inspected item box , made sure selection inside. please? try // instead of .// . this: //*[@id='container-inner']/div[3]/div[4]/div[*]/div[1]/div/a/

database - Sum balance via Price + Balance From previous row -

i have oracle database 11g table 'transaction' . want balance. i have now: | date | description | min_plus | amount | balance | | 4-7-2015 | gift dad | + | 45,00 | 0 | | 5-7-2015 | gift sister | - | 3,00 | 0 | | 6-7-2015 | gift aunt | + | 2,50 | 0 | i'm looking for: | date | description | min_plus | amount | balance | | 4-7-2015 | gift dad | + | 45,00 | 45,00 | | 5-7-2015 | gift sister | - | 3,00 | 42,00 | | 6-7-2015 | gift aunt | + | 2,50 | 44,50 | is possible virtual colmn, better use pl/sql or not possible do? you can running total in plain sql, when select data display. no need create balance column or pl/sql trick. oracle windowing functions nifty use! in case, want sum() amount column first row current row in order of transaction date. can express in surprisingly plain language: with sample_data ( select to_date('04-07-2015'

how to download csv file to directory using python -

i trying download historical stock prices of aapl yahoo query failed. new python , not know method apply in auto extracting designated link desired local directory. pulldata("aapl") result: aapl https://query1.finance.yahoo.com/v7/finance/download/aapl?period1=345398400&period2=1505577600&interval=1d&events=history&crumb=x44gajpyonu main loop http error 401: unauthorized import urllib2 import time import csv import requests import pandas pd def pulldata(stock): try: print stock url = 'https://query1.finance.yahoo.com/v7/finance/download/'+stock+'?period1=345398400&period2=1505577600&interval=1d&events=history&crumb=x44gajpyonu' print url response = urllib2.urlopen(url) html = response.read() except exception,e: print 'main loop',str(e) you should updates pandas datareader fix https://github.com/pydata/pandas-datareader/i

c# - How to handle packages such as EF, MVC4, WebPages and friends in my project repository -

Image
i have asp.net application using ef, mvc4 , additional packages. whenever try open project on different pc have issues installed packages. references marked missing, , code far compilable. last time solved deleting references , packages , installing needed packages 1 one. find solution tedious. there better, global solution this? how supposed done? shouldn't automated? thanks , pointers! update i use nuget packages, (otherwise hard these dlls) somehow end uninstalling , reinstalling packages make project work. end wrong versions , not compiling code. i end doing following: delete package.config delete dependencies web.config file nuget package manager console: pm> uninstall-package a.b.c pm> install-package a.b.c clean - rebuild project , hope best i think uninstall - install can replaced update-package –reinstall a.b.c i hoping there simpler solution this. if using visual studio; can enable automatic package restore; article outlines nu

html - The 'lang' selector for css is not working in gmail -

Image
i'm using * [lang~=x-divbox] selector designing newsletter (mailchimp) work in gmail (table of content) i worked out solution in old template still works , when use in new template it's not working: here's code i'm using , screenshot comparison (and identical): * [lang~=x-divbox]{ /*@editable*/background-color:#939598; } * [lang~=x-divbox] h2{ /*@editable*/color:#fffffe!important; /*@editable*/font-family:arial; } * [lang~=x-divbox] ul{ /*@editable*/margin:0 !important; /*@editable*/padding:0 !important; /*@editable*/font-family:arial; } * [lang~=x-divbox] li{ /*@editable*/margin:0 !important; /*@editable*/padding:0 !important; /*@editable*/list-style-type:none !important; /*@editable*/color:#fffffe !important; } * [lang~=x-divbox] a{ /*@editable*/display:block !important; /*@editable*/padding:10px 0 !important; /*@editable*/co

smallbasic - Moving a shape across the screen and making it disappear -

this program have far works freezes when gets loop. have done program shapes doesnt it. graphicswindow.height = 400 graphicswindow.width = 600 graphicswindow.title = "fairytail" graphicswindow.canresize = "false" animation() controls.buttonclicked = action sub animation graphicswindow.brushcolor = "black" firstmove = controls.addbutton("fireball", 300, 100) controls.move(firstmove, 0, 200) endsub sub action if controls.getbuttoncaption(firstmove) = "fireball" graphicswindow.brushcolor = "red" fireball = shapes.addellipse(20, 20) shapes.move(fireball, 135, 115) = 135 465 if <> 465 shapes.animate(fireball, i, 115, 1000) = + 1 program.delay(100) else shapes.remove(fireball) endif endfor endif endsub what im trying move fireball across screen remove it. dont know how remove after animates. there few problems program. first 1 this: for = 135 465 if <> 465 shapes.animate(fire

Matlab Coder : Matlab Array to C Array -

i used matlab coder convert matlab code c. simple array had defined in matlab got converted complicated struct in c. struct emxarray_real_t { double *data; int *size; int allocatedsize; int numdimensions; boolean_t canfreedata; }; it of great if can shed light on how work struct. the type emxarray_real_t created because matlab coder unable determine fixed size or sufficiently small bounds on size array in matlab, 2x3. in case generated code allows size of array vary @ runtime using dynamic memory allocation (e.g. malloc ) , data structure represent matlab array in c. these called dynamically allocated variable size arrays in matlab coder documentation , struct fields used track dynamically allocated memory in generated code. regarding working such arrays, documentation recommended @horchler place start. also, can have @ other answer describes basics of working same struct when stored data uint32 rather double or real_t in case.

python - Drawing a snowflake using recursion -

Image
i want create output this:  i have use recursion. so far , code looks like: from turtle import * def drawflake(length,depth): fd(length) input("first line done") if depth>0: left(60) drawflake(length/3,depth-1) input("1") left(120) drawflake(length/3,depth-1) input("2") left(120) drawflake(length/3,depth-1) input("3") left(120) drawflake(length/3,depth-1) input("4") left(120) left(180) #drawflake(length/3,depth-1) input("1") left(120) drawflake(length/3,depth-1) input("this last") left(60) left(180) fd(length) drawflake(100,3) and produces output this(here, n =3) the issue long line @ left. there shoul

sql - I had errors in MariaDB Event Scheduler -

delimiter | create event queue_sorting on schedule every 1 seconds begin declare ts, pn int; select table_size_id ts tables table_size_id = ( select table_size_id queue order q_time desc limit 1 ) , phone_number null order table_line asc, table_number asc limit 1; select phone_number pn queue order q_time desc limit 1; update tables set phone_number=pn table_size_id=ts; delete queue phone_number=pn , table_size_id=ts; end | delimiter ; i love create event manage queue, code errors. don't know why. have been searching on websites, haven't found best solution. should do? can explain? what if latest table_size_id's had phone_number? event cannot move past find useful. table_size_id -- normalizing sizes? (i hope not.) please provide show create table .

c# - " formMain entry = new formMain(dt.Rows[0][0].ToString()); " What does this mean? Especially Rows[0][0] -

i'm newbie in programming world. given project , stuck database connectivity. thankful responses! formmain entry = new formmain(dt.rows[0][0].tostring()); what mean? rows[0][0] ? please help. dt object of datatable class (think of datatable normal database table), exposes property row of type datarow[] (a datarow array is), using can access single row of datatable passing row index; e.g. dt.rows[4] give 5th row of datatable . a datarow object (think of datarow single row of data) in turn exposes own indexer of type object[] (an object array is), gives access individual values of columns of datarow . if datarow object named dr , can use dr[2] access or change value of 3rd column of dr . if want access or change value of 3rd column of 5th row, can this: var dr = dt[4]; //5th row returned , stored in dr var myval = dr[2]; //value of dr's 3rd column stored in myval or can in 1 line: var myval = dt[4][2]; which code doing, i.e. passing

java - Apache POI gets NPE reading xls file -

i'm trying read xls file java, looks this column a|product id|number sold .................|105029 ....|15 .................|102930 ....|9 .................|203911 ....|29 .................|105029 ....|4 where need add total number of product sold each product id , create new file data sorted. program supposed flexible, in there 1000 different product id's or 400. code below have far... there quite few problems , lack of java knowledge making frustrating. the first loop not continue, it's stuck @ r=1, although second loop continues. import java.io.fileinputstream; import java.io.ioexception; import java.io.inputstream; import org.apache.poi.hssf.usermodel.hssfcell; import org.apache.poi.hssf.usermodel.hssfsheet; import org.apache.poi.hssf.usermodel.hssfworkbook; public class read { public static void readxlsfile() throws ioexception{ inputstream excelfile = new fileinputstream("c:/sales data.xls");

sql - ORA-00917: missing comma when insert not exist in oracle -

i have query : insert kontak (idkontak, nama, nohp, alamat, groupkontak_fk) values (sq_idkontak.nextval, 'andika pratama', '+6285226202202', 'jpr', '' not exists (select * kontak nama = 'amin')) i want insert data kontak table based on values not exist in kontak nama='amin'. when ran got error : ora-00917: missing comma any suggestion? if trying conditional insert, can either use merge, or use this, assuming want insert 'andika pratama' if 'amin' not there (which doesn't make sense me, seems goal): insert table1(id1, col1, col2) select sequence1.nextval, 'val1', 'val2' dual not exists (select 1 table1 col1 = 'amin') http://docs.oracle.com/cd/b19306_01/server.102/b14200/statements_9014.htm

c++ - Reading letters and numbers from .txt file -

i program reads letters , numbers input being used. dont know how implement .txt file. code: #include <iostream> #include <string> using namespace std; int main() { char ch; int countletters = 0, countdigits = 0; cout << "enter line of text: "; cin.get(ch); while(ch != '\n'){ if(isalpha(ch)) countletters++; else if(isdigit(ch)) countdigits++; ch = toupper(ch); cout << ch; //get next character cin.get(ch); } cout << endl; cout << "letters = " << countletters << " digits = " << countdigits << endl; return 0; } i made mistake in hw suppose count words instead of letters .txt file. im having trouble counting words because confused space between words. how change code count words in

sql - Query to total monthly hours for events spanning month borders -

i have series of events unique , may continue arbitrary time. need calculate how may hours events contribute monthly totals, given event may commence before specific month (in case contribute previous month current month) , finish after specific month. the data looks like: event | startdate | enddate | ------------------------------- | 1 | 10/01/2015| 11/01/2015| | 2 | 20/12/2014| 9/01/2015 | | 3 | 25/01/2015| 14/02/2015| ultimately, try generate list grouped month , year totals "event hours" each month (not each event - events within month summed). to honest, not sure start this. the easy way using months table because can have empty months. create table months ( month_id integer, date_ini datetime, date_end datetime ) then join table. sql fiddle demo with ranges ( select * months m left join events e on e.startdate <= m.d_end , e.enddate >= m.d_begin ) select r.*,

ruby - Why is `loop` not a keyword? What is the use case for `loop` without a block? -

i wondering why loop kernel method rather keyword while , until . there cases want unconditional loop, since loop , being method, slower while true , chose latter when performance important. writing true here looks ugly, , not rubish; loop looks better. here dilemma. my guess is because there usage of loop not take block , returns enumerator. me, looks unconditional loop can created on spot, , not make sense create such instance of enumerator , later use it. cannot think of use case. is guess regarding wonder correct? if not, why loop method rather keyword? what use case enumerator created loop without block? only ruby's developers can answer first question, guess seems reasonable. second question, sure there use cases. whole point of enumerables can pass them around, which, know, can't while or for structure. as trivial example, here's fibonacci sequence method takes enumerable argument: def fib(enum) a, b = nil, nil enum.each a,

xcode - UITableViewCell variables ni? -

i have correctly setup tableview using nib. register nib , identifier. somehow, getting nil in code here: func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { let cell = gallerytable.dequeuereusablecellwithidentifier("gallerycustomcell", forindexpath: indexpath) as! gallerycell it takes me custom cell created , telling me every variable nil. have reconnected outlets , still receive errors. in custom cell, crashes here: override func awakefromnib() { super.awakefromnib() // initialization code self.backgroundcolor = uicolor.whitecolor() var tapphotoaction = uitapgesturerecognizer(target: self, action: selector("phototap:")) tapphotoaction.delegate = self tapphotoaction.cancelstouchesinview = false galleryphoto.addgesturerecognizer(tapphotoaction) any thoughts on why happen @ all? saying galleryphoto nil, should not be. have outlet connected. also, happens on simulat

powershell - Access content os variable line by line in power shell -

i storing output of command in variable. want access content of line line. $outputvariable = (dir | % { $_.fullname -replace "c:\\","" }) | out-string; $outputvariable output follows:- d:\asgn5 d:\assignment 5 so want access output of variable line line first want have d:\asgn5 we can have data $$outputvariable[0..n] but want know there other way access line line? from the doc by default, out-string accumulates strings , returns them single string, can use stream parameter direct out-string return 1 string @ time. but don't have use out-string @ all. let use foreach loop on object return get-childitem (dir) command : $outputvariable = (dir | % { $_.fullname -replace "c:\\","" }) $outputvariable |foreach {"value $_"}

Python os.system('dir') points to 'C:\' not 'C:\myfolder\' -

python os.system('dir') points 'c:\' instead of 'c:\myfolder\'. ideas why , how can fix it? environment: windows 7, python3.4 please check if works you. import os #will print current working directory content #that script present os.system("dir") print "---------------------------------" #will print content of c:\python27 os.system("dir c:\python27") output c:\users\administrator\desktop>python chk.py volume in drive c has no label. volume serial number 2a3d-7b34 directory of c:\users\administrator\desktop 08/28/2015 01:56 pm <dir> . 08/28/2015 01:56 pm <dir> .. 08/19/2015 02:27 pm 27,156,654 a.bmp 08/31/2015 11:33 187 chk.py 08/28/2015 11:20 234 data.txt 08/13/2015 04:07 pm 502 eclipse - shor 08/13/2015 03:39 pm 502 eclipse - shor 06/24/2015 05:28 pm 876,888 freesshd.exe 08/27/2015 11:45 p

Embed one html file inside other report html file as hyperlink in python -

i trying embed a.html file inside b.html(report) file hyperlink. just clear, both html files offline , available on local machine. , @ last report html file sent on email. the email recipient not having access local machine. if click on hyperlink in report.html, " 404 - file or directory not found ". is there way embed a.html inside report.html , email recipient can open a.html report.html on machine you need 1 of: attach a.html report.html, post a.html shared location such google drive , modify link point it, or put content of a.html hidden <div> show method.

javascript - How to make jquery objects of array from php response of ajax call -

Image
here javascript variable my , wanted php file. inside selectannotation.php echoing echo "{ src : 'http://192.168.1.58/annotate/drive/image/test.jpg', text : 'suresh , gopinath....', shapes : [{ type : 'rect', geometry : { x : 0.1825726141078838, y: 0.23756906077348067, width : 0.11602209944751381, height: 0.11618257261410789 } }] }"; exit; as, wanted php file. achieve made ajax call var = { src : 'http://192.168.1.58/annotate/drive/image/<?php echo $_get['file']?>', text : 'suresh , gopinath....', shapes : [{ type : 'rect', geometry : { x : 0.1825726141078838, y: 0.23756906077348067, width : 0.11602209944751381, height: 0.11618257261410789 } }] } console.log(my); console.log('__________'); $.post("mastercall/selectannotation.php", { url: 'http://192.168.1.58/annotate/drive/image/<?php echo $_get[

c# - Complex Query using Sitecore 8 content search API -

i trying write linq iterate through list of id's using sitecore content search api throws exception invalid method call argument type: field - fieldnode - field: supplier_categories_sm - dcp.common.models.shared.categoryitem[]. constant arguments supported. //the search item class public class eventsupplieritem : basesearchitem { [indexfield("supplier_categories_sm")] public categoryitem[] suppliercategories { get; set; } //maped multilist } //i have wrote custom converter map multilist item public class categoryitem { [sitecoreid] [indexfield("_group")] [typeconverter(typeof(indexfieldidvalueconverter))] public virtual id id { set; get; } [indexfield("name")] public string name { get; set; } } the code create filter predicate results: var eventcategoryid = new id(eventsupplierfilters.suppliercategory); filteror = filteror.or(x => x.suppliercategories.select(a => a.id)

c# - RemotePresentitySubscriptionTarget error -

i using following code remotepresentitysubscriptiontarget target = new remotepresentitysubscriptiontarget("sip:abc@gmail.com"); to presence of users getting exception as invalid uri: parsing error; suspect character: '%'. how pass uri this?in format?

how to prompt save As Box in Excel Interlop c# MVC 4 -

i want export excel sheet using excel interloop... i have datatable convert excel sheet... now there way save file using save dialogue box in mvc 4 here code public string datatabletoexcel(datatable dt, string htmlheading, string key) { try { microsoft.office.interop.excel.application excel; microsoft.office.interop.excel.workbook excelworkbook; microsoft.office.interop.excel.worksheet excelsheet; microsoft.office.interop.excel.range excelcellrange; excel = new microsoft.office.interop.excel.application(); excel.visible = false; excel.displayalerts = false; excelworkbook = excel.workbooks.add(type.missing); excelsheet = (microsoft.office.interop.excel.worksheet)excelworkbook.activesheet; excelsheet.name = "sheet1"; dataset

Mysql FullText Syntax Error #1215 -

i have 3 table create table tag ( name varchar(294) not null, inserted_at datetime not null, status integer not null, primary key (name) ) engine=innodb; create table item ( id integer not null auto_increment, name varchar(294) not null, price integer not null, discounted_price integer default null, unit varchar(294) not null, additional_message text not null, stock integer not null, is_featured integer not null, inserted_at datetime not null, status integer not null, primary key (id) ) engine=innodb; alter table item add fulltext(name, additional_message); create table item_tag ( id integer not null auto_increment, item_id integer not null, tag_name varchar(294) not null, inserted_at datetime not null, status integer not null, primary key (id), foreign key (tag_name) references tag(name), foreign key (item_id) references item(id) ) engine=innodb; alter table item_tag add fulltext(tag_name); the first alter command works perfec

bpm - Bonita 7 : Custom Widget property type to support JSON data -

i trying create new custom widget in bonita 7 , need property can accept json data (not simple array collection) i.e., want assign below data [ { 'header1': 'data1-1', 'header2': 'data1-2', 'header3': 'data1-3' }, { 'header1': 'data2-1', 'header2': 'data2-2', 'header3': 'data2-3' } ] i tried available property types (text,choice ,html ,integer,boolean ,collection property) & guess nothing works. me achieve this. i trying create smart-table custom widget ( https://github.com/lorenzofox3/smart-table ) & want table data(rows) populated using variable of json type. is there other way of achieving this. thank time i sorry, collection property type works this did: in custom widget editor 1a) created new property : name : tabledatacollection label: table_data type: coll

c# - How to solve my android Udp socket doesn't receive the packet sometime? -

firstly,i know risk of using udp socket instead of tcp. i send image client c# server androids listening port using udp socket. the problem can sometime receive packet in first attempt of sending( note :run c# console image sending app). sometime, have try more 1 attempts of sending in order receive it. any or ideas appreciated. in advance c# client code const int port = 4800; string serverip = "?"; //get addresses string hostname = system.net.dns.gethostname(); iphostentry alllocalnetworkaddresses = dns.resolve(hostname); //walk thru network interfaces. foreach (ipaddress ip in alllocalnetworkaddresses.addresslist) { socket client = new socket(addressfamily.internetwork, sockettype.dgram, protocoltype.udp); //allow sending broadcast messages client.setsocketoption(socketoptionlevel.socket, socketoptionname.broadcast, 1); //bind on por

php - EzPublish render searchHits in Twig -

i have following code retrieve main menu on ezpublish 5.4 site: $query = new locationquery(); $query->query = new criterion\logicaland( array( new criterion\contenttypeidentifier( $this->gettopmenucontenttypeidentifierlist() ), new criterion\visibility( criterion\visibility::visible ), new criterion\location\depth( criterion\operator::between, array( $rootlocation->depth + 1, $rootlocation->depth + 3 ) ), new criterion\subtree( $rootlocation->pathstring ), new criterion\languagecode( $configresolver->getparameter( 'languages' ) ) ) ); $query->sortclauses = array( new query\sortclause\location\depth(), new query\sortclause\location\priority() ); $main_menu = $searchservice->findlocations( $query )->searchhits; this works, results expect , give array twig template: {% item in menu %} <a href="#menuitem

reactjs - What is the correct way to implement a stateless authentication? -

i new single page application. 1 big question me how make application secured. using react in front-end , express + mongodb in back-end. i old web site, use session authorization. if session timeout, can let user redirect login page. , if user keep actions on our website, session never expired. but now, using jwt authorization. token may expired in 1 minuet, after that, user have login again. for understanding, 1 way 're-send token on every request/response, each request/response have new token'. think not correct way of how use jwt. so questions are: what correct way avoid user login again if still work on our web app? do need store token in database (mongodb)? if store token in localstorage, can borrow browser , copy token client. how avoid it?

javascript - How to have both observer and on init for ember js properties -

new ember rules states need use below pattern propobserver: ember.observer(function () { //code }) instead of propobserver: function() { //code }.observers('someprop') before updating ember below propobserver: function () { //code }.observes('someprop').on('init') how achieve cascading? now know can separately propobserver: ember.observer('someprop', function () { //code }) propobserver: ember.on('init', function () { //code }) from 2.0.0 docs: http://guides.emberjs.com/v2.0.0/object-model/observers/#toc_observers-and-object-initialization propobserver: ember.on('init', ember.observer('someprop', function() { // code }))

.net - C# return from async task not working -

i'm working on async http call using httpclient. call made inside async task. call successful , response http call. when try return response task nothing happens, though have breakpoint waiting after return. public void executetask(foundation.security.securitytoken token, order order) { executetaskasync(token, order).wait(); } public async task executetaskasync(foundation.security.securitytoken token, order order) { if (order != null) { log.info("starting export of order " + order.id.tostring()); bool success = await exportorder(order, token); if (!success) { log.error("failed export order id " + order.id.tostring()); } } } private async task<bool> exportorder(order order, foundation.security.securitytoken token) { try { responseobject response = await webservice.sendorder(new senderinformation(token), new receiverinformation(order, token)); if (response.suc