Posts

python - sympy: how to sympify logical "NOT" -

the following code work sympify logical expressions: sympify('a&b') # and(a, b) sympify('a|b') # or(a, b) but how result of not(a) ? it turns out symbol looking ~ . see following: >>> sympy import sympify >>> sympify('a&b') and(a, b) >>> sympify('a|b') or(a, b) >>> sympify('~a') not(a)

mysql - stored procedure to display monday or weekday -

i want write stored procedure find out joining date of teachers , if monday should display monday else should display “weekday” the tbl_teacher table ; vchr_teacher_name dat_teacher_doj teena 1982-01-10 lawrence 1979-09-01 mathew 1981-10-13 job 1980-11-12 and need create stored procedure " call check_date(1982-01-10)" results as: day ---------- weekday ---------- i tried : delimiter // create procedure check_date (in dat date,out day varchar(10)) begin select dayname( dat ) day tbl_teachers; end// delimiter ; it's show error as #1172 - result consisted of more 1 row how , find day monday or weekday. i think better served function : drop function if exists `check_date` // create function `check_date` (dat date) returns varchar(10) begin return if(dayname(dat) = 'monday' , 'monday', 'weekday...

Process 'command 'F:\android-sdk\build-tools\21.1.2\aapt.exe'' finished with non-zero exit value 1 -

here content of build.gradle file: // top-level build file can add configuration options common sub-projects/modules. buildscript { repositories { maven { credentials { username artifactoryusername password artifactorypassword } url 'http://test:8081/artifactory/libs-release-local' } mavencentral() } dependencies { classpath 'com.android.tools.build:gradle:1.1.0' } allprojects { repositories { maven { credentials { username artifactoryusername password artifactorypassword } url 'http://test:8081/artifactory/libs-release-local' } mavencentral() maven { url 'http://repo1.maven.org/maven2' } jcenter() } } here content of app\build.gradle : apply plugin: 'com.android.application' android { compilesdkversion 21 buildtoolsversion "21.1.2" lintoptions { abortonerror false ...

java - Updating to mongo 3.0 -

i working on mongo 2.x , have updated mongo 3.x updated java mongodb client 3.0.3, have js on mongo server needs executed , js requires 2 object parameters done in previous version this: db database = mongoclient.getdb(db); commandresult cr = database.doeval(js, query, collection); // js string, query basicdbobject , collection list<string> need in running same in place of db getting mongodatabase (as getdb has been deprecated) , doeval replaced runcommand you can in code of original doeval method figure out how this, looks like: public commandresult doeval(final string code, final object... args) { dbobject commanddocument = new basicdbobject("$eval", code).append("args", arrays.aslist(args)); return executecommand(wrap(commanddocument)); } that means you'll need like: document commanddocument = new document("$eval", code).append("args", arrays.aslist(args)); return runcommand(commanddocument); note r...

Array size in Perl -

i trying run code , getting output as: #!/usr/bin/perl @array = (1,2,3); $array[50] = 4; $size = @array; $max_index = $#array; print "size: $size\n"; print "max index: $max_index\n"; output: size: 51 max index: 50 what explanation this? in perl, array data structure representing list . list has elements . keys list called indexes . first index 0 ( 0 ). you have started array these indexes , valus: index value 0 1 1 2 2 3 if set 50th index value, other indexes in between filled undef , undefined value. you have correctly identified $#array max index, or highest or last index . if force array scalar context , give number of elements, or size . you've got well. , will, Сухой27 said in comment , last index minus one. you can illustrate behaviour if dump out array . use strict; use warnings; use data::printer; @array = (1,2,3); $array[10] = 4; p @array; it output following. again can see index starts @ 0 , , each...

apache - setting document root in antoher partition on ubuntu -

i place apache document root inside partition of ubuntu hard drive, keep getting forbidden message, when place home directory woking find, how be? group or owner affected ? here mysite.conf , apache2.conf when place document root in home folder (working) #site-available/mysite.conf documentroot /home/jono/www #/etc/apache2/apache2.conf <directory /home/jono/www/> options indexes followsymlinks allowoverride none require granted </directory> bu when change document root partition keep getting forbidden messasge #site-available/mysite.conf documentroot /media/jono/website_data/www #/etc/apache2/apache2.conf <directory /media/jono/website_data/www/> options indexes followsymlinks allowoverride none require granted </directory> is owner/group access affected ? or there problem ? at last it's working, have grant access www:data accesing whole directory @mark-b, using chown -r www-data:www-data whole directory is...

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -

i trying add nodes dagre graph through cityscape.js. problem nodes not painted. code have: cy.add({ group: "nodes", data: { id:"n0",name:"n0",weight: 75 }, }); $.ajax(url).done(function(jsontree){ var newnodes=[]; for(var i=1;i<6;i++){ //var child = jsontree.result[i]; newnodes.push( { group: "nodes", data: { id: "n"+i, name:"n"+i}}, { group: "edges", data: { id: "e"+i, source: "n0", target: "n"+i } } ); } cy.add(newnodes); any ideas? have used loaded function reload graph not work. not know if have use specific function reload graph. thank in advance. you need add positions new nodes. cytoscape.js docs : it important note positions of newly added nodes must defined when calling cy.add(). nodes can not placed in graph without valid position — otherwise not displayed. yo...

r - Parse time elapsed / time span / duration with several different formats -

i need parse time spans several different formats, including days, hours, minutes, seconds.ms, separated : : %os , %h:%os , %h:%m:%os or %d:%h:%m:%os . example: x <- c("28.6575", "1:14.0920", "1:5:38.1230", "5:23:59:38.7211") the first idea comes mind using strptime parse given strings date. approach not work strings not contain parts of time span. possible turn parts of format string being optional? strptime("5:23:59:38.7211", "%d:%h:%m:%os") # [1] "2015-08-05 23:59:38" strptime("1:5:38.1230", "%d:%h:%m:%os") # [1] na # wanted: "2015-08-01 01:05:38" a different approach turn formatted values seconds (e.g. 1:14.0920 ~~> 74.0920 secs ). however, unable find convenient way using r. here's expanded version of @konrad rudolph's comment: # split time spans different time elements l <- strsplit(x, ":") # pad vector leading zeros. here 4 max...

node.js - How to run NodeJS unit tests with a different NODE_PATH -

the question can run unit tests within node/gulp have different node_path has been inherited environment? the issue i have project being run within rhino based application, require loads scripts set of defined locations. i want have unit tests components. in order run tests need able call scripts node environment. ends error similar this: error: cannot find module 'lib/foo/foo.js' this because scripts contain require(foo/foo) ... fine if node_path have contained lib . issue here want folder present unit tests, not other gulp tasks. i guess issue facing test runners came across (e.g. karma ) browser based. question might be: is there test runner runs pure nodejs tests? well can along lines of node_path=node_path:/path/to/lib npm test`. node_path environment variable. rely on value persists through login shell profile. can set/unset/change suits you. to set environment variable duration of execution of 1 command... variable=value command ...

sql - How to clean database table from garbage data after it is populated with a data from excel file? -

Image
i have package dumps data .xls file kind of staging table. need insert data main table. i'm looking way write sql code rid off garbage data staging table. this example of xls file when executing package, staging table looks this: after that, run following code delete garbage data statging table: delete stagingtable data null , data = 'date' that takes care of garbage removal particular case. but if data comes in so, xls columns names different, delete statement not work is there work around problem? i found answer. work if first column of staging table has date value: select * statgingtable isdate(date) = 1 this return:

sql server - Adding an IF Condition in WHERE Clause to Add an 'AND' only on particular occasion. In other occasion skip the 'AND' part -

i'm trying workout this. it's sample code, since i'm not able put whole stored procedure. i'm taking value table, while getting @children parameter sp. want run and condition if the value in @children greater one. possible add if condition in where clause within sql server 2008? how can achieve following? logically, below situation want achieve. if have questions please let me know, can provide additional information. select empid, empdesignation, empsalary, haschildren employee empdesignation = 'manager' if (@children > 2 ) { , haschildren = 1 } you can use combined query and , or operators: select empid, empdesignation, empsalary, haschildren employee empdesignation = 'manager' , (@children < 2 or haschildren = 1) in case if @children 1 or less condition @children < 2 valid condition haschildren = 1 never evaluated. in on other hand @children more 1 condition @children < 2 invalid , in case conditi...

command line - How do I add a right-click option to search the web using a selected file's name? -

i'm looking add option right-click menu in windows explorer launch chrome , search specific site file's name. little more specific, want able on video file , available subtitles it. i'm aware there number of programs can variation of this, after trying out bunch of them, haven't quite found want. not that, i'd rather use lightweight, native code having install program. the closest thing guide i've found in post , doesn't quite work. of course, i've tried cleaning needs, still doesn't work, think there's flaw in there. here's have far... running command prompt administrator, executed these 2 lines add them registry: reg add "hklm\software\classes\*\shell\subtitle search" /d "subtitle search" reg add "hklm\software\classes\*\shell\subtitle search\command" /d "c:\my projects\my code\subtitlesearch.bat ""%1""" the, create batch file (subtitlesearch.bat) following: set x...

asp.net - What is the best way to create .xls from datatable in asp .Net c#? -

i have datatable , want export excel that, datatable contains unicode characters (persian characters) , want convert .xls files correctly. wonder possible stimulsoft? this common method use public void exportdetails(datatable tempdatatable, string filename) { try { system.io.stringwriter objstringwriter1 = new system.io.stringwriter(); system.web.ui.webcontrols.gridview gridview1 = new system.web.ui.webcontrols.gridview(); system.web.ui.htmltextwriter objhtmltextwriter1 = new system.web.ui.htmltextwriter(objstringwriter1); httpcontext.current.response.clearcontent(); httpcontext.current.response.clearheaders(); httpcontext.current.response.contenttype = "application/vnd.ms-excel"; httpcontext.current.response.charset = ""; httpcontext.current...

python - .exe closes immediately after launch when double clicked -

i've created exe file using py2exe module. weird thing works has work when run exe command line when double-click on exe , opens console (as has do) , console closes immediately. i wrote logging method figure out problem , surrounded method try-except not catch exception. here piece of code: if __name__ == '__main__': try: mh = moto() db = database() # can find __init__ of database() below log('ok') # can't find line in log file problem inside __init__ od database() except exception e: log(str(e)) log(str(traceback.format_exc)) url in [__cats__,__hyphens__]: log(' url') init database(): class database(): def __init__(self): self.conn = sqlite3.connect('db.db') # database created self.cursor = self.conn.cursor() self.create_table_moto() self.drop_and_create_temp_table() log('init_end') # can fin...

neo4j - The @QueryResult doesn't work -

i'm using spring data neo4j 4 (sdn4),and trying return more 1 entities using @queryresult there no exception thrown,but null in @queryresult object model simple (:user)-[:role]-(:role) does 1 know root cause? the user model @nodeentity public class user implements userdetails { @graphid private long id; public long getid() { return id; } public void setid(long id) { this.id = id; } private string userid; @relationship(type="role") private set<role> roles = new hashset<>(); public aduser getaduser() { return aduser; } public void setaduser(aduser aduser) { this.aduser = aduser; } public string getuserid() { return userid; } public void setuserid(string userid) { this.userid = userid; } public set<role> getroles() { return roles; } public void setroles(set<role> roles) { this.roles = r...

How do I create a photo gallery with same widths and different heights using HTML/CSS? -

i beginner html , css. want create photo gallery columns same width, each photo have different height. want photos "hug" each other, photos in second row may not start in same vertical position each other. how accomplish that? saw columns - maybe work? i'm grateful available! you create html page contains div s each column. you either use css stylesheet place columns together: - either float these column div left (refer w3c school's css floating ), or - using relative or absolute position ing (refer w3c school's css positioning ) , give each div x , y coordinate. then give each column div preset width (refer w3c school's css width , max-width ). every item in column move new row (when has static positioning, default tags). give each image in column same fixed should fine...

arrays - how to change the value of a specific key in short words in php -

array of title replaced words temporary array ( [title] => led flash macro ring light (48 x led) 6 adapter rings for canon/sony/nikon/sigma lenses [manufacturer] => neewer electronics accessories [currency] => cad [price] => 35.99 ) convert title values have less words temporary compare key array ( [title] => led flash macro ring [manufacturer] => neewer electronics accessories [currency] => cad [price] => 35.99 ) not entirely sure if suffice try following. $title=$arr['title']; $length=30; $smalltitle=rtrim( preg_replace('/\s+?(\s+)?$/', '', substr( $title, 0, $length ) ) ); echo $smalltitle; $arr['title']=$smalltitle;

image processing - How to convert a jpg to yuv in C? -

Image
even though question of nature sounds similar, having problems in converting jpg image yuv in c (without using opencv). this have understood of now, how solve problem : identify structure of file formats jpg , yuv. i.e each byte in file contains. think jpg format looks like. with above structure tried read jpg file , tried decipher 18th , 19th bytes. did type cast them both char , int don`t meaningful values width , height of image. once have read these values, should able convert them jpg yuv. looking @ resource . appropriately, construct yuv image , write (.yuv) file. kindly me pointing me appropriate resources. keep updating progress on post. in advance. based on https://en.wikipedia.org/wiki/yuv#y.27uv444_to_rgb888_conversion decoding jpeg, in pure c without libraries ... following code straightforward ... https://bitbucket.org/halicery/firerainbow-progressive-jpeg-decoder/src assuming have jpeg decoded rgb using above or library (us...

java - QueryDSL add cross join when building predicate queries -

i want fetch data modela base on user in modelb. not compulsory every record have record in modelb. when use below code fetch data, return 0 records. booleanexpression searchcriteria = searchcriteria .and( qmodela.modelb.user.id.eq(userid) ) .and ( other conditions well); modela.findall(searchcriteria, pageable); when debug found querydsl put cross join. can tell me how fix this, there way querydsl add left join instead of cross join? below 2 models. @entity public class modela implements serializable { private long id; private string label; private modelb modelb; @id @sequencegenerator(name = "modelaseq", sequencename = "modela_id_seq", allocationsize = 1) @generatedvalue(strategy = generationtype.sequence, generator = "modelaseq") public long getid() { return id; } public void setid(long id) { this.id = id; } @column(length = 15...

javascript - eq(0) is not a valid selector with $.each -

<select class="qty"> <option>1</option> <option>2</option> <option>3</option> <option>4</option> </select> <select class="qty"> <option>1</option> <option>2</option> <option>3</option> <option>4</option> </select> i have 2 select tags , want update them array. means changing selected correct value, why in attempt below :eq() not working loop? selectedarr = [2,3]; $.each(selectedarr,function(i,obj){ console.log(obj); $('.qty:eq(' + + ')').prop('selected', true); }); there's few things wrong here: $('.qty:eq('+i+')').prop('selected',true) setting selected property on <select> element - not <option> element you aren't selecting appropriate option array according selectedarr i this: var selectedarr = [2, 3]; ...