Posts

Showing posts from July, 2015

Python unicode equal comparison failed -

this question linked searching unicode characters in python i read unicode text file using python codecs codecs.open('story.txt', 'rb', 'utf-8-sig') and trying search strings in it. i'm getting following warning. unicodewarning: unicode equal comparison failed convert both arguments unicode - interpreting them being unequal is there special way of unicode string comparison ? you may use == operator compare unicode objects equality. >>> s1 = u'hello' >>> s2 = unicode("hello") >>> type(s1), type(s2) (<type 'unicode'>, <type 'unicode'>) >>> s1==s2 true >>> >>> s3='hello'.decode('utf-8') >>> type(s3) <type 'unicode'> >>> s1==s3 true >>> but, error message indicates aren't comparing unicode objects. comparing unicode object str object, so: >>> u'hello' =

sorting - How to sort a file in unix both alphabetically and numerically on different fields? -

please don't think repeat of "sorting alphanumeric data in unix" question... looked @ other answers, , think case bit different! i have data this: a 192 d 112 d 188 c 091 281 b 919 ...and want sort first column 1 (alphabetically), , column 2 (numerically). tried using: sort -n -k1,2 ...but gave me correctly sorted first field, wrong sorting second field (1000,1002,1003,10,1 ... instead of 1,10,1000,1002,1003). can please suggest how sort these 2 columns way i'd like? try using this:- sort -k1,1 -k4,4n -n : makes program sort according numerical value -k opts: sort data / fields using given column number. example, option -k 2 made program sort using second column of data. option -k 3,3n -k 4,4n sorts each column. first sort 3rd column , 4th column.

php - Show different image depending on value in variable -

just want make sure i'm going in right direction this. have image want replaced/changed if value of variable either 0/1. here code guy doing server side stuff. <?php //requires mysql_connect create connection $link_state = 0; //if wish don't have check connection, may idea leave in. if ($mysql_connection['connected'] == true) { $result = mysql_query("select * link"); //the bit looking should first row, , should 1 row $count = mysql_num_rows($result); if ($count <= 0) { //interesting... $mysql_error['error'] = true; $mysql_error['description'] = "error: no rows returned table 'link'"; } else { //we should ok continue if ($count > 1) { $mysql_error['error'] = true; $mysql_error['description'] = "warning: found more 1 row in 'link' table!"; } $row = mysql_fetch_

String as Indexer in C# -

let me start showing code: using system; namespace tutorialadvanced { class collection { object[] values; public collection(int size) { values = new object[size]; } public object this[string index] { { return values[index]; } set { values[index] = (object)value; } } } class program { static void main() { collection collection = new collection(3); collection["integer"] = 123; collection["decimal"] = 456.78; collection["text"] = "hello world!"; double total = (double)(int)collection["integer"] + (double)collection["decimal"]; console.writeline("total {0}", total); console.writeline(); collection collection

python - Can I My Program be Under the GPL if I Use PySide? -

i making program , want put under gpl using pyside in under lgpl. can still put program under gpl or have under lgpl. both of these licenses program? thanks yes, can. gpl doing program? read license. :-) the lgpl not program. lgpl makes static linking more difficult, doubt matters python.

Can't display the output result in browser returned from htmlentities() function in php -

i tried display output returned htmlentities() function. but, display nothing in browser. here code.. $advertisement = "coffee @ 'cafè française' costs $2.25."; echo htmlentities($advertisement); the result should this: coffee @ 'cafè française' costs $2.25. but, there nothing displaying in browser. when assign output in variable, it's value not null. testing code is: $temp = htmlentities($advertisement); if($temp === null) echo "null"; else echo "not null"; then, result "not null"; i try code testing: $str = "a 'quote' `<b>`bold`</b>`"; //outputs: 'quote' &lt;b&gt;bold&lt;/b&gt; echo htmlentities($str); but, output in browser not expected. mean in browser it's not replaced <b> &lt;b&gt; what missing? need change setting in php.ini file? that htmlentities supposed do. echo string out , should implement html auto

Why is my android receiver dropping 10-60% of UDP broadcast packets? -

i have 802.3 wired transmitter application on computer i've written broadcast udp packets every 10ms. each broadcast packet contains 4-byte integer value unique particular packet, allows me figure out on receiver end how many packets have been dropped. i have verified transmitter works wireshark. set 4 802.11 receivers (2 android phones , 2 laptop computers) on same network. laptops received 95% of udp broadcast packets; 1 phone received 89%; other phone received 40%. why? here part of android receiver code: public class netthread extends thread { int[] pkt_nums; int p; netthread(int[] pkt_nums) { this.pkt_nums = pkt_nums; (int i=0; i<pkt_nums.length; i++) { pkt_nums[i]=0; } p = 0; } @override public void run() { receivedata(); } public void receivedata() { // request permission network operations in manifest file...done // start n

c# - Type or namespace couldn't not be found. My database context has gone missing? -

i opened project working on morning , changed target framework .net 4 client .net 4 resolve issue having moq. after tried rebuilding solution , following error: the type or namespace name 'aredatabase' not found (are missing using directive or assembly reference?) i tried reverting .net 4 client no luck, i've been trying fix while no luck. here of code: aredatabase arecontext = new aredatabase(); rule stratrule = new rule(); ruleservice ruleservice = new ruleservice(new rulerepository(new aredatabase()), new rule()); any ideas? thanks

c# - Clear particular column values in DataTable -

i have data table 4 fields emp_no, amountpaid, amount_adjusted, adjustment_reason i want clear values of adjustment_reason column i have tried below code : for (int = adjustmenttable.rows.count - 1; >= 0; i--) { adjustmenttable.rows[i]["adjustmentreason"] = dbnull.value; } its working fine. but can 1 suggest me code achieve using linq you can write this: adjustmenttable.rows .oftype<datarow>() .tolist() .foreach(r => r["adjustmentreason"] = dbnull.value); but quite frankly i'm not sure how performant can large amount of data in datatable.

install phpmyadmin with mysql 5.6.13 CentOS 6.4 64bit -

i installed centos 6.4 x86_64 , install on web server , mysql 5.6.13 mysql-server-5.6.13-1.el6.x86_64.rpm mysql-client-5.6.13-1.el6.x86_64.rpm mysql-shared-5.6.13-1.el6.x86_64.rpm mysql-devel-5.6.13-1.el6.x86_64.rpm and want install phpmyadmin i used yum install phpmyadmin not working ================================================================================ package arch version repository size ================================================================================ installing: phpmyadmin noarch 3.5.8.1-1.el6 epel 4.3 m installing dependencies: libxpm x86_64 3.5.10-2.el6 base 51 k libmcrypt x86_64 2.5.8-9.el6 epel 96 k mysql-libs x86_64 5.1.69-1.el6_4 updates 1.2 m php-gd x86_64 5.3.3-23.el6_4 updates 106 k php-mbstring

r - how to programmatically back-out, deduce, decompile, reverse-engineer the algorithm used to construct a variable in a data set -

Image
i'm looking algorithm or program or function deduce how variable created, long supply other variables. think computer programmers call "decompiling" , architects call "reverse-engineering" guess don't know statisticians call it..or if there accepted methods it. let's i've got categorical column in data.frame called newvar , don't know how constructed. do know variables used create it..or @ least can provide exhaustive set of variables used create -- if not of them used. # start example data set x <- mtcars # # # # # # # # # # # # # # # # # # # # # # # # # pretend block of code black box x <- transform( x , newvar = ifelse( mpg > 24 , 1 , ifelse( cyl == 6 , 9 , ifelse( hp > 120 , 4 , ifelse( mpg > 22 , 7 , 2 ) ) ) ) ) # end of unknown block of code # # # # # # # # # # # # # # # # # # # # # # # # # knowing `mtcars` has 11 columns choose names(x)

javascript - How to not refresh selected items in multiselect -

i'm using multiselect jquery plugin dynamic select of recipients (by profile level [master, administrator, etc] message box. so, when selected (in single select), profile level, application search in database , return select, use $('#recipients').multiselect('refresh'); to update multiselect box. but, in multiselect plugin have 2 boxes (selectable , selection), , when refresh multiselect, every option selected (on selection box) disappears, , first box (selectable) refreshed. know if has way refresh selectable box, , keep selected options in selection box without change on refresh?

javascript - NodeJS + MongoDB ASYNC results appearing late -

i have simple function returns list of connected users in channel, using in initial stage simple array, know, want retrieve user details mongodb database , add array. the problem i'm having return giving empty result, can see later on in console log because queries running late , return running before having results back. i know because asynchronous functions, i've tried q , others cant working. :( //get users specified room function get_room_users( room ){ // create array hold usernames of poeple in specific room var roomusers = new array(); // clients in ‘room1′ var clients = io.sockets.clients( room ); var = 0; for(var = 0; < clients.length; i++) { db.users.findone( { email: clients[i].username }, function(err, userdata) { if( err || ! userdata ){ console.log('no user found'); } else { console.log("displaying user data: " + userdata.nickname

How can I add a fade event to my simple javascript image array? -

i have simple image array website : javascript code triggered links in html. the javascript working fine can't seem images in fadein when image switches. switch abrupt painful eyes. could please explain how might fadein event or effect going image array? here javascript: var image = new array("one.jpg","two.jpg","three.jpg","four.jpg"); var image_number = 0; var image_length = image.length - 1; function change_image(num){ image_number = image_number + num; if (image_number>image_length){ image_number = 0; } if (image_number<0){ image_number = image_length; } if (image_number>0){ function fade_in () { $("image_number") .fadein(); } document.my_imagearray.src= image[image_number]; return false; } and html: seems forgot add html code from code have provided, can assume should write this: if ( image_number > 0 ) { $("html_item_that_contains_image").fadeou

excel vba - VBA: Run-time error 3220 “Supplied provider is different from the one already in use” -

i error message run-time error 3220 "supplied provider different 1 in use" when try run following command in file have received datconnection.open (provider=microsoft.jet.oledb.4.0;data source='c:\users\laptop\desktop\excel files test\macros\example 1.xlsx';extended properties='excel 8.0;hdr=yes;imex=1') any idea why error , how can change make work? i don't know if relevant have windows 7 x64 excel 2013 adapted first example on connectionstrings.com page kazjaw linked to: "provider=microsoft.ace.oledb.12.0;data source=""c:\users\laptop\desktop\excel files test\macros\example 1.xlsx""; extended properties=""excel 12.0 xml;hdr=yes;imex=1"";" the version using before works older .xls format. data source contains spaces needs surrounded double quotes. double quotes need escaped doubling them up

java - trying to get location from "network" provider fails on some devices despite the provider being enabled -

i'm trying write android app gets current location 'network' provider (so should need android.permission.access_coarse_location permission). works fine on devices, on others don't seem able location update. here's code. in oncreate: locationmanager = (locationmanager) getsystemservice(context.location_service); provider = locationmanager.network_provider; log.v (tag, "finding location provider: " + provider); if (check_provider_enabled && !locationmanager.isproviderenabled (provider)) { toast.maketext (this, "location provider disabled", toast.length_long).show (); } else { try { location location = locationmanager.getlastknownlocation(provider); if (location == null) { log.i (tag, "getlastknownlocation returned null, requesting updates when available"); locationmanager.requestlocationupdates (pro

jquery - Changing attribute of a DOM element using D3 data that is bound to it -

i have d3.js visualization of dag, using force-directed layout. want change colours of nodes. far, have done in click listeners using this : function clicknode(node) { d3.select(this).attr("fill", nodehighlightcolour); } however, want change node colour in function called listener, instead of listener itself. reason has separate function want "highlight" series of nodes, tracing node that's clicked, need call function ( tracepath ) recursively. if call tracepath listener, "undefined function" runtime error when try d3.select(this).attr("fill") . i'm guessing because this no longer in scope. can pass node object tracepath , node data rather dom element. how dom element using data object bound it? edit: wrote in comment felix kling, can't pass this tracepath . work first node, still have call function recursively. here tracepath function far: // trace node - node_el "this", node node data funct

Can’t create plain C++ project in Qt creator - no valid kits found -

this question qt creator 2.8.0. when go file>>new file or project>>non-qt project>>plain c++ project then this page. when press “next” this page , error: no valid kits found i can’t press “next”. can click on "options" takes me this page. using latest version of qt creator (2.8.0) installed on updated fedora 19 64bit. kit , how can add can create plain c++ project? i have solved it. had change “qt version” “none” “qt 4.8.5 in path (system)”. kit shows correctly.

Make dir in C, linux doesnt create sub-dirs (dir tree) - why? -

i want create dir tree in c on linux. wrote code: #include <sys/types.h> #include <sys/stat.h> #include <stdio.h> #include <stdlib.h> static int direxists(const char *path) { struct stat info; if(stat( path, &info ) != 0) return 0; else if(info.st_mode & s_ifdir) return 1; else return 0; } int main(int argc, char **argv) { const char *path = "./mydir/firstdir/"; if(!direxists(path)) { mode_t mask = umask(0); if(mkdir(path, s_irwxu | s_irwxg | s_irwxo) == -1) exit(-1); umask(mask); } printf("%d\n", direxists(path)); return 0; } its ok when path single dir, lets say, path = "./mydir" when want create dir tree, example: path = "./mydir/a/b/c/d/" dirs not created. why? you need define code able create directory tree. in other word mkdir doesn't create directory recursively. edit: in link y

python - I do not quite understand how to parse the Yahoo NHL Page -

here code far: from bs4 import beautifulsoup urllib.request import urlopen url = urlopen("http://sports.yahoo.com/nhl/scoreboard?d=2013-04-01") content = url.read() soup = beautifulsoup(content) print (soup.prettify) table = soup.find('table') rows = table.findall('tr') tr in rows: cols = tr.findall('td') td in cols: text = td.findall('yspscores') yspscores in td: print (yspscores) the problem i've been having html yahoo page has table data in context: <td class="yspscores"> i not quite understand how reference in code. goal print out scores , name of teams score corresponds to. you grabbed first table, there more 1 table on page. in fact, there 46 tables. you want find tables scores class: for table in soup.find_all('table', class_='scores'): row in table.find_all('tr'): cell in row.find_all('td', class_='ysps

android - Check for contacts having app installed -

i building application users able interact contacts of device(using phonenumber) have application installed ( pretty how whatsapp, viber function) now functionality can achieved function getcontacts() storing app registrations on server from app, sending contact server , receiving in server response, registered contacts however, leads problems of synchronization in cases contacts added/deleted or existing ones updated for this, knowledge guides me 3 alternatives everytime app launched, call getcontacts() method data retrieved fresh not sure if method used whatsapp & viber, achievable lot of unnecessary processing during each launch have background service poll server through getcontacts() method this can keep contacts synchronized however, not refresh changes instantaneously. in whatsapp, if change name of contact, reflected instantanouesly register contentobserver on contactscontract.content_uri ( not of idea on ) please provide insights

css - Absolute position is working fine on different resolutions even if there is no relative position element on the top of it -

i wondering i've heard absolute position messes page on different resolution. reason, working fine me without wrapping around relative element. how possible? want understand. here css: body { background-image:url('images.jpg'); background-repeat:repeat-x; } .mainpage { margin-top:100px; width:900px; margin:auto; } .gridline { content:""; height:1px; background:-moz-linear-gradient(left, #ffffff 0%,#000000 50%,#ffffff 100%); background:-webkit-linear-gradient(left, #ffffff 0%,#000000 50%,#ffffff 100%); background:linear-gradient(left, #ffffff 0%,#000000 50%,#ffffff 100%); width:100%; display:block; } .empbox { height:30px; background:-moz-linear-gradient(left, #ffffff 0%,#6c8483 50%,#ffffff 100%); background:-webkit-linear-gradient(left, #ffffff 0%,#6c8483 50%,#ffffff 100%); background:linear-gradient(left, #ffffff 0%,#6c8483 50%,#ffffff 100%); width:100%; display:block; color:white; margin-top:190px; padding-top:10px; clear:

mongodb - snapshot option of find method not working -

my code method 1: ... var cursor = collection.find({}, {snapshot: true}); //i made sure insert new document collection before below timer fires settimeout(function(){ cursor.each(function(err, docu){ console.log("cursor items", docu); }) }, 15000); method 2: var cursor = collection.find({}, {snapshot: true}); cur.nextobject(function(err, item) { console.log("read first doc alone", item) }) //i made sure insert new document collection before below timer fires settimeout(function(){ cursor.each(function(err, docu){ console.log("cursor items", docu); }) }, 15000); for both methods, started application, within next 15 secs inserted row same db manually. method 1 outputs rows exists , row inserted in 15 secs. method 2 outputs first row , method not printing row inserted in 15 secs, irrespective of {snapshot: true} or {snapshot: false} questions why ' snapshot ' option of find method not working

UIManagedDocument used in UITabViewController crashes when trying open an existing database -

i using justin driscoll's article on core data uimanageddocument in singleton pattern set uitabviewcontroller. running app on simulator. working fine first time. database created , can see data in tableview controller each tab. when restart application, app crashes error assertion failure in -[uimanageddocument openwithcompletionhandler:], ** terminating app due uncaught exception 'nsinternalinconsistencyexception', reason: 'attempt open or revert document has open or revert operation in flight my code causes crash. did debugging using nslog statements. if (![[nsfilemanager defaultmanager] fileexistsatpath:[self.document.fileurl path]]) { nslog(@"document doesnot exist , hence start creating"); [self dataintodocument:self.document]; nslog(@"document finished creating"); [self.document savetourl:self.document.fileurl forsaveoperation:uidocumentsaveforcreating completionhandler:ondocumentd

c++ - How negate std::is_integral for use in tag dispatch? -

i've been playing around tag dispatch, , following code works expect: #include <type_traits> #include <iostream> void impl(std::true_type) { std::cout << "true\n"; } void impl(std::false_type) { std::cout << "false\n"; } template<typename t> void dispatch(t&& val) { impl(std::is_integral<typename std::remove_reference<t>::type>()); } int main() { dispatch(10); // calls impl(std::true_type) dispatch(""); // calls impl(std::false_type) } but if want negate condition, i'm running trouble. thought throw " ! " code inside dispatch , impl(!std::is_integral<t>()); // added "!" but won't compile. what need code work? you may instantiate std::integral_constant constexpr value this: impl(std::integral_constant<bool, !std::is_integral<t>::value>()); std::true_type , std::false_type aliases class. other way introduce met

java - Parallel processing in app engine -

for each request app gets, sends lot of url fetch requests many apis, , want send , process response in parallel. it's not heavy in computation, in time takes wait external api's response. what best why use make paralleled it? thread? task queue? or even, thought sending http main servlet other servlets in app. there few options consider using async urlfetch, have read of article. http://ikaisays.com/2010/06/29/using-asynchronous-urlfetch-on-java-app-engine/ if have big number of urls (you haven't quantified how many have) consider using task queue, have 10min request time. alternately use pull queue submit url's processed , backend processes requests , can use threads in backend instance.

java - Proguard obfuscated jar won't launch -

i having trouble running obfuscated jar, got "java virtual machine launcher" message "a java exception has occurred" when try run it. (this error popup, not on command line) tried running command line , printing stacktrace jvm console , didn't see exceptions. so did little troubleshooting: disabled shrinking, obfuscating , optimizing output (should be) same input. output jar turned out few kb less input. extracted both jars, decompiled .class files , compared source of every single file , manifest.mf , same*! i'm using proguard 4.10, jdk 1.7.0_25 x64 , windows 8. i'm building elaborate javafx program , believe configured proguard- shouldn't matter anymore if shrinking, obfuscating , optimizing disabled, right? here notes proguard gives me: note: duplicate definition of library class [netscape.javascript.jsexception] note: duplicate definition of library class [netscape.javascript.jsobject] note: com.javafx.main.main accesses field 'hkey

php - Other variable value null when change new one -

i making admin panel own site. i have 5 input fields goes post method variable , these variables call image src. here demo if input fields fill image links work fine after if l change 1 link other pictures lost. php & html <form action="" method="post"> <input type="url" name="img1"/> <input type="url" name="img2"/> </form> <?php if($_server['request_method'] == "post") { $img1=$_post['img-one']; $img2=$_post['img-two']; ?> <div><img id="admin-image-pack-2" alt="null" src="<?php echo $img1; ?>"/><img id="admin-image-pack-2" alt="null" src="<?php echo $img2; ?>"/> check if post $_post['img-one'] not null before assign variable. way if update second value example won't lose first one. same posts

php - URL dissector that splits up a query string -

ok reading through piece of source code , not understand purpose of specific area. class url_processor { private static $urlpath; private static $urlbits = array(); /* gets data current url @return void */ public function geturldata() { $urldata = (isset($_get['page'])) ? $_get['page'] : '' ; self::$urlpath = $urldata; if( $urldata == '' ) { self::$urlbits[] = 'home'; self::$urlpath = 'home'; } else { $data = explode( '/', $urldata ); while ( !empty( $data ) && strlen( reset( $data ) ) === 0 ) { array_shift( $data ); } while ( !empty( $data ) && strlen( end( $data ) ) === 0) { array_pop($data); } self::$urlbits = $this->array_trim( $data ); } } private function array_trim( $array ) { while ( ! empty( $array ) && strlen( re

jquery - Load First image on custom Gallery with FadeIn effect -

i script custom build image gallery: $('#plantas-img a').click(function(){ image = $("<img />").attr("src", $(this).attr("href")); $("#plantas-img .img_big").html(image); return false; }) my html: <div id="plantas-img" class="product-img"> <div class="img_big"> <img src="plantas/image_1.jpg"/> </div> <div class="wrap_thumbs_plantas"> <ul class="thumbs"> <li><a href="plantas/image_1.jpg"><img src="plantas/thumb_image_1.jpg"/></a></li> <li><a href="plantas/image_2.jpg"><img src="plantas/thumb_image_2.jpg"/></a></li> <li><a href="plantas/image_1.jpg"><img src="plantas/thumb_image_1.jpg"/></a></li&

virtualhost - Remove index.php in Wordpress subfolders when using virtual hosts -

i have looked everywhere find solution problem, nothing have tried has worked. when having permalink settings /index.php/%postname%/ works fine, when remove index.php part 404 , in log: [tue aug 13 05:05:46 2013] [error] [client 202.58.198.84] file not exist: /var/www/html/domain1/postname, referer:..... i have red hat webserver running apache 2 wordpress sites through virtual hosts. virtual hosts this. <virtualhost *:80> # general serveradmin info@domain1.com documentroot /var/www/html/domain1 servername domain1.com serveralias www.domain1.com # logging errorlog logs/domain1-error_log customlog logs/domain1-access_log common </virtualhost> and <virtualhost *:80> # general serveradmin info@domain2.com documentroot /var/www/html/domain2 servername domain2.com serveralias www.domain2.com # logging errorlog logs/domain2-error_log customlog logs/domain2-access_log common </virtualhost> the .htaccess file in sub folde

c - What does this define mean? #define ASSERT(exp) -

i see code in c program don't understand. #define assert(exp) if(!(exp)){putstr("err\n");} please explain , show me how use it. thank you! you should read preprocessor directives in c. here creating macro, gets replaced during compile time value used define macro with. for eg: we can use assert(<some condition or expression>) through out code instead of if(<some condition or expression>) { putstr("err\n"); } during compile time, compiler replaces assert actual condition.

android - Custom ListView in Fragment not working -

i'm newbie in android , trying display custom listview in fragment when run display nothing.can me fix that. here code: public class tab1 extends fragment implements listview.onitemclicklistener{ private arraylist<custom> fetch = new arraylist<custom>(); private contactsadapter adapter; private listview lv; @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle saveinstancestate){ view v = inflater.inflate(r.layout.tab_layout, container, false); custom 1 = new custom("hoang ha", "01672286349"); custom 2 = new custom("ha link", "03203590176"); fetch.add(one); fetch.add(two); lv =(listview)v.findviewbyid(r.id.list); adapter = new contactsadapter(getactivity(), fetch); lv.setadapter(adapter); lv.setonitemclicklistener(this); return v; } public class custom{ private

Problems Starting VLC HTTP Stream with Servlet -

i'm working on vlc project myself. goal create html front end start stream. doing through use of java servlets. overview: ubuntu 13.04, java 7-21 : icedtea 2.3.9, eclipse javaee ide, tomcat 7 i trying start vlc http video stream using call. vlc -vvv /home/jca310ms/videos/test.avi.flv \ --sout '#transcode{vcodec=flv1,vb=4096,fps=25,scale=1,acodec=mp3,ab=512,samplerate=44100,channels=2}:std{access=http,mux=flv,dst=0.0.0.0:8081/stream.flv}' now, call work command line. however, when run using : string args = "vlc -vvv /home/jca310ms/videos/test.avi.flv --sout '#transcode{vcodec=flv1,vb=4096,fps=25,scale=1,acodec=mp3,ab=512,samplerate=44100,channels=2}:std{access=http,mux=flv,dst=0.0.0.0:8081/stream.flv}'"; runtime runtime = runtime.getruntime(); process p = runtime.exec(args); i these errors output: err: [0x7ff2d8000b78] main input debug: creating input 'test.avi.flv' err: [0x7ff2ac001108] main stream output debug: using sout ch

html - CSS3 Media Queries for targeting landscape on both iphone 4 and iPhone 5 sized sceens -

i having issue css3 media queries developing mobile site. code below works great on iphone 5 landscape, not on iphone 4 , below in landscape mode. /* normal css represents portrait */ .test {width:100%;} /* flip landscape (working great on iphone 5) - not great on 4s , below */ @media screen , (orientation: landscape) { .test {width: 50%} } now need keep above target iphone 4s , below in landscape mode, other devices around screen size. can add media query target smaller screens keep styles above? any great. thanks yeah, can target landscape on both using: // iphone 5 @media screen , (orientation:landscape) { .test { width: 50% } } // iphone 4 , below, @danield's example @media screen , (min-device-width : 320px) , (max-device-width : 480px) , (orientation : landscape) { .test { width: 30% } } where first iphone 5, , second iphone 4 , below. although, think second 1 should work both in itself. can't confirm since don't own 5. h

asp.net - Controls in ContentPlaceHolder are not recognized by javascript document.getelementsbyname -

i have calender script in project. using it, have added image , on onclick event call javascript function displaydatepicker: <img alt="calender" src="calender.jpg" onclick="displaydatepicker('txtbox1', this);"/> i use masterpage in project , if image , associated textbox control in contentplaceholder, javasript library's function document.getelementsbyname returns null , seems can not detect controls inside contentplaceholder. i used code page not using masterpage , went well. i appreciate in advance. good luck. your asp textbox may render like: <input name="ctl00$featuredcontent$txtbox1" id="featuredcontent_txtbox1" type="text"/> so, in javascript, should use clientid: <img alt="calender" src="calender.jpg" onclick="displaydatepicker('<%= txtbox1.clientid %>', this);"/>

Digit value to array in JavaScript -

i have number 8939 , want array [8000,7000,6000,5000,4000,3000,2000,1000] , example if have 340 can array 300,200,100 . i knew , if user i = i/1000 * 1000 then can round down 8939 8000, don't know how can got result want above. no reason complicate it, can use for loop function getarrfornum(num){ var arr = []; // create new array var digitnum = num.tostring().length; //get number of digits, can use math.log instead var mulof10 = math.pow(10,digitnum-1); for(var i=1;i*mulof10 < num;i++){ arr.push(i*mulof10); // push next multiple of 1000 } return arr; //return } then can use it: getarrfornum(3211); //1000,2000,3000 getarrfornum(321); //100,200,300 here 1 line version challenge, suggest avoiding :) array(+(832+"")[0]).join(".").split(".").map(function(_,i){ return (i+1)*math.pow(10,(832+"").length-1);}); // 800,700,600,500,400,300,200,100 array(+(3332+"")[0]).join(".&qu

website - Bash file redirection instead of string interpretation in Pandoc makefile -

introduction i started using pandoc markdown generate static xhtml personal website. managed automatically insert couple of links refer $(name) of .md file using pandoc -b argument (see below makefile ). pandoc -b argument designed contain file name, had use output redirection of echo command in addition shell interpretation. the problem the pandoc -b argument has grown long maintained within makefile . want move xhtml string separate file whilst keeping bash string interpretation. cat command not because not part of bash. shell := /bin/bash name = $(basename $(wildcard *.md)) all: index.html html: index.html index.html: $(name).md pandoc $< -s -o $@ \ -b <(echo "<div id=\"pdf\"><ul><li><a href=\"$(name).a4.pdf\">a4 pdf</a></li><li><a href=\"$(name).letter.pdf\">letter pdf</a></li></ul></div><div id=\"source\"><ul><li><a

sql - Rails scope select where all values are in a list -

i've got rails scope looks this: default_scope joins(:groups).where("groups.name in ('group1','group2')") which filters model objects aren't in group1 or group2, need find way filter model objects don't have group1 and group2. any suggestions? in advance.

java - MjpegInputStream issue -

i'm trying view ip camera android, , follow topics founded here, doesn't work in "return new mjpeginputstream(res.getentity().getcontent());" on "doread" method. i followed " android ics , mjpeg using asynctask " this error log: 08-13 09:28:11.260: d/clipboard(4135): hide clipboard dialog @ starting input: finished else... ! 08-13 09:28:30.310: d/mjpeg(4577): 1. sending http request 08-13 09:28:30.450: d/clipboard(4577): hide clipboard dialog @ starting input: finished else... ! 08-13 09:28:31.010: d/mjpeg(4577): 2. request finished, status = 200 08-13 09:28:31.010: d/mjpeg(4577): 3. traza 08-13 09:28:31.010: w/dalvikvm(4577): exception ljava/lang/unsatisfiedlinkerror; thrown while initializing lcom/camera/simplemjpeg/mjpeginputstream; 08-13 09:28:31.020: w/dalvikvm(4577): threadid=11: thread exiting uncaught exception (group=0x40c5e1f8) 08-13 09:28:31.020: e/androidruntime(4577): fatal exception: asynctask #1 08-13 0

python - SQLAlchemy returns an integer -

i accessing database using sqlalchemy. when try filter table using bunch of public , private keys attribute error saying 'int' object has no attribute 'date'. sometimes, able filter results once , when filter called again, crashes giving me same error. problem of sqlalchemy or pydev? below snippet of filter. randomize_query(session('test').query(tablename).filter(tablename.field1 == criteria, tablename.field2 == 2).order_by(desc(tablename.field3))).first() the full traceback below file "c:\python27\lib\site-packages\sqlalchemy\orm\query.py", line 2145, in first ret = list(self[0:1]) file "c:\python27\lib\site-packages\sqlalchemy\orm\query.py", line 2012, in __getitem__ return list(res) file "c:\python27\lib\site-packages\sqlalchemy\orm\loading.py", line 72, in instances rows = [process[0](row, none) row in fetch] file "c:\python27\lib\site-packages\sqlalchemy\orm\loading.py", line 447,

bash - Git issue - git archive handling files with space in their names -

i having trouble while handling filenames having space in them. i use below piece of script fetch files contained in push onto folder in zip format , later unzip files. tempdir=$(mktemp -d /apps/sample/xxxx) while read oldrev newrev refname commits=`git rev-list $oldrev..$newrev` commit in $commits git diff-tree -z --no-commit-id --name-only -r $commit | xargs -0 git archive -o $tempdir/list.zip head: unzip $tempdir/list.zip -d $scandir rm -rf /apps/sample/list.zip done done exit 0 in below example, added , committed file sample file.txt . thing when git archive command encounters space, error below. [root@inba2 repo]# git push origin master counting objects: 4, done. delta compression using 4 threads. compressing objects: 100% (2/2), done. writing objects: 100% (3/3), 296 bytes, done. total 3 (delta 1), reused 0 (delta 0) unpacking objects: 100% (3/3), done. remote: fatal: path not found: sample file.txt remote: archive: /apps/sample/l7im/list.z

jQuery file upload and RequireJS configuration -

i'm trying use jquery file upload , i'm getting stuck requirejs configuration. install our dependencies in /ext/ folder, e.g: /src /ext /jquery-file-upload in main.js use following config: require.config({ paths: { "ext/jquery-file-upload": "../ext/jquery-file-upload/js/jquery.fileupload" } }); require([ "ext/jquery-file-upload" ]); but requirejs tries load jquery.ui.widget.js root instead of relative file. located in jquery-file-upload directory.. does know i'm doing wrong, or know of working requirejs config jquery file upload? thanks, martijn if @ jquery.fileupload.js file, @ top declares own dependencies if (typeof define === 'function' && define.amd) { // register anonymous amd module: define([ 'jquery', 'jquery.ui.widget' ], factory); you need edit require.config path jquery.ui.widget item. require.config({ paths: {

java - Initializing Fields Value in Constructor Versus in Fields Declaration -

this question has answer here: initialize class fields in constructor or @ declaration? 12 answers as know, in java , other object-oriented programming languages, fields value can set in constructor or initialized in fields declaration statements. want know essential differences between 2 ways above. , conditions should initialze fields constructor , condtions should't. help. the advantage argumented constructors can set field values per inputs cant same initialized fields. so if want create different objects different attribute values go constructors arguements. , assign values of instance variables in constructor. if want instance variables have default value, assign values @ declaration.

java - How to set the line spacing in a JtextPane? -

first of all, set jtextpane this: htmleditorkit editorkit = new htmleditorkit(); htmldocument document = (htmldocument) editorkit.createdefaultdocument(); jtextpane textpane = new jtextpane(); textpane.setcontenttype("text/html"); textpane.setdocument(document); and want set line spacing in jtextpane , idea,but can't work: simpleattributeset aset = new simpleattributeset(); styleconstants.setlinespacing(aset, 50); textpane.setparagraphattributes(aset, false); i wrong? when call textpane.setparagraphattributes(aset, false); tries apply line spacing selection nothing selected call way document.setparagraphattributes(0, document.getlength(), attr, replace);

javascript - how to preload an audio in html before showing the content to the user -

this question has answer here: preloading audio files 3 answers i have page full of css animations , important me have music beginning. i've used call music. here code: <body> <audio autoplay> <source src="./1.mp3" type="audio/mpeg"> <source src="./1.ogg" type="audio/ogg"> <embed height="50" width="100" src="./1.mp3"> </audio> </body so how can preload music (and images too) , show whole page users @ once? create js preloader , show page after content ready the simplest way create preloading div @ top of page , hide after music loaded. or can wait not music, of content, how wish #preloadingdiv { position: absolute; top: 0; left: 0; padding: 0; margin: 0; border: 0; width: 100%; z-index: 100; } $("#preloaderdiv"

git - how to directly merge github pull request to my private repo? -

here's situation, i have private repo, privaterepo, on own server i make private repo on github public repo, openrepo (like mirror) people can fork openrepo, makes changes, sends pull request if request accepted, i'd rebase directly privaterepo instead of merging openrepo meanwhile, commits can submitted privaterepo people working directly on privaterepo because if accept merging on openrepo, have update privaterepo openrepo, there circle , it's redundant, not conflicts resolving. possible? what circle talking about? flow merging on openrepo , syncing privaterepo absolutely clear. have 2 remotes - private , public , merge pulls in public, , sync private. if you'd skip pull requests in openrepo, deviate more , more privaterepo. tricky job sync them again after while. also, if not keep public repo up-to-date, people can base work on old, stale commits. example create branch fix bug, while has been fixed pull request not merged. also, unclear why ne

.htaccess don't go to folder if slash on end -

i have site where site.com/index.php?page=test (include file test.php pages folder index.php) is replaced site.com/test goal: if go site.com/index.php?page=forum/new_enrty i want ot make url site.com/forum/new-entry problem: if open site.com/forum/new-entry directs me forum directory new-entry file directly , not include new-entry index.php so far got this: <ifmodule mod_rewrite.c> rewriteengine on #rewritebase /cms/ rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{request_filename} !-l rewriterule ^ index.php [l] </ifmodule> replace code this: options +followsymlinks -multiviews rewriteengine on rewritecond %{request_filename} !-f rewritecond %{request_filename} !-d rewritecond %{request_filename} !-l rewriterule ^(.+?)/?$ index.php?page=$1 [l,qsa]

foreign keys - Entity Framework DELETE statement conflicted with the REFERENCE constraint -

i’m pretty new ef , have little problem. i want delete item in database. i’m using sql server 2012 express, vs2012, adventureworks 2012. the query execute following: context = new awentities(); var removeditem = context.addresses .include("stateprovince") .include("salesorderheaders") .include("businessentityaddresses").single(d => d.addressid == 11); context.addresses.remove(removeditem); context.savechanges(); the error is the delete statement conflicted reference constraint "fk_salesorderheader_address_shiptoaddressid". conflict occurred in database "adventureworks2012", table "sales.salesorderheader", column 'shiptoaddressid'. statement has been terminated. is way delete items , according entries in other tables? please point me right direction. public partial class address { public address()

javascript - Regex c# to jquery implementation -

i have regex on asp.net mvc3 application: regex pattern = new regex(@"^(?!.*(.)\1\1)(?=.*\d)(?=.*[a-z])(?=.*[a-z])[0-9a-za-z]{8,20}$"); i needed implement jquery due requirements this: password.match(/(.*(?=.*\d)(?=.*[a-z])(?=.*[a-z])[0-9a-za-z]/)) this working. detect if 1 uppercase, 1 lowercase , 1 number present on password. , have need detect if 3 consecutive letter present (eg: aaa, bbb). with regex on c# , working of: /(.)\1\1/ but can't make work on password.match(/(.)\1\1/) did missed here? in advance! i've copied c# regex , tried in javascript console , works great: "waweeead2".match(/^(?!.*(.)\1\1)(?=.*\d)(?=.*[a-z])(?=.*[a-z])[0-9a-za-z]{8,20}$/) returns ["waweeead2", undefined] and "waweeeead2".match(/^(?!.*(.)\1\1)(?=.*\d)(?=.*[a-z])(?=.*[a-z])[0-9a-za-z]{8,20}$/) returns null .

jquery - Knockout: DOM not updated until resize -

i have div data bound using knockout foreach syntax. <div id="mydiv" data-bind="foreach: { data: mydata }, mycustombinding: { param: paramname }"> <a id="mylink" class="mylink" data-bind="text: label"></a> </div> mydata observablearray holds data. have knockout subscribe on mydata follows: mydata.subscribe(function () { if (mydata().length > 0) { resizediv(); } }); in resizediv() function trying remove few links div , move different hidden div if size of controls combined greater div width. problem controls width not available @ moment of time. control width refreshed in dom after resizing browser. have added window resize event calls same resizediv() method. $(window).on('resize', function () { resizediv(); }); not sure if able convey issue/concern. please let me know if need further information. update: here fiddle http://jsfiddle.net/2m3jk/7/ . binding handler not f

php - Vimeo - get all user video ids in array -

i new vimeo api, need connec account, ids of uploaded videos , store them in array. have understanding of php frankly examples saw or documentation provided vimeo didn' tell me much, asking if there can direct me examples how connnect through oauth , call vimeo methods through script. lot! 1.if need user videos, can use curl request url - http://vimeo.com/api/v2/username/videos.json username name of vimeo user stream want get. example: $curl = curl_init('); curl_setopt($curl, curlopt_returntransfer, true); curl_setopt($curl, curlopt_followlocation, true); curl_setopt($curl, curlopt_timeout, 30); $data = json_decode(curl_exec($curl)); url_close($curl); 2.you can use implementation of advanced vimeo api php oauth - https://github.com/vimeo/vimeo-php-lib

php - How to find out, if facebook ID is a user, group or page -

i wonder if there's way determine, if given id user, group or page on facebook. i've checked fql-reference , haven't found anything. edit: nevermind. seems, ?metadata=1 trick (if profile accessible) as far i'm aware, there no way "type" facebook, assume know id supposed relate anyway. the best thing can think of find attribute unique each object, , check if exists on returned data from ://graph.facebook.com/id you want check documentation , return data best key/attribute check, quick @ docs, possible check: if company exists, assume application id if first_name exists, assume user id if owner exists, assume group the advantage being once determine type of id, have data need object, whatever consequent actions. n.b: fact don't know type, leads me believe don't have access_token allow additional permissions. therefore you're restricted public data, sure use key not require access_token (i.e. haven't tested th