Posts

Showing posts from February, 2013

c - select interrupted system call -

i creating timer runs approximately every second , waiting key pressed (which not doing). while running shows: select : interrupted system call select : interrupted system call select : interrupted system call select : interrupted system call can tell me why happening: struct sigaction s1; static timer_t tid3; sigfillset(&s1.sa_mask); s1.sa_flags = sa_siginfo; s1.sa_sigaction = signalhandler; if (sigaction(sigu, &s1, null) == -1) { perror("s1 failed"); exit( exit_failure ); } printf("\ntimer %d setting \n",timeridentity); tid3=settimer(sigu, 1000, 1); // ---------- set timer values ------------------- static struct sigevent sigev; static timer_t tid; static struct itimerspec itval; static struct itimerspec oitval; sigev.sigev_notify = sigev_signal; sigev.sigev_signo = signo; sigev.sigev_value.sival_ptr = &tid; if (timer_create(clock_realtime, &sigev, &tid) == 0) { itval.it_value.tv_sec = sec/1000; itval.it_va

android - AppWidgetProvider onEnabled() -- is widget list known at that point? -

i use alarmmanager set repeating alarm each widget updating purposes. it's working well, on devices. in order re-establish alarms after reboot, relying on onenabled() method, since called once group of app widgets. , in that, have following: alarmmanager alarmmanager = (alarmmanager) context.getsystemservice(context.alarm_service); appwidgetmanager appwidgetmanager = appwidgetmanager.getinstance(context); int appwidgetids[] = appwidgetmanager.getappwidgetids(new componentname(context, myappwidgetprovider.class)); (int appwidgetid : appwidgetids) { // call function set repeating alarm widget (including doing widget update now)... updateappwidgetalarm(context, appwidgetid, appwidgetmanager, alarmmanager); } whilst seems work in cases, appears devices onenabled() method not doing @ all. know being called, logging put in, nothing happening. i suspect maybe appwidgetids array empty, because @ time after reboot list has not yet been populated. put in more log

Selecting value of active select with jQuery -

in viw have 5-15 dynamically created dropdowns this: <select class="task-type" id="21"> <option value=""></option> <option value="easy">easy</option> <option value="hard">hard</option> </select> where class task-type used every dropdown , id unique each every , represents record in database, vary 1 10000. i have following jquery code try pick value of dropdown has changed value: $( '.task-type-select' ).change(function(){ alert($( ".task-type-select option:selected" ).text()); }); however, alerts every dropdown's value, need changed one. any or guidance appreciated. you can use this keyword reference element raised event. there can use val() method selected value: $('.task-type-select').change(function(){ console.log($(this).val()); });

ruby - undefined method `zone` for Time:Class after requiring active_support/time_with_zone -

i'm on ruby 2.2.1 , have active_support 4.2 installed want use time.zone.parse('2007-02-10 15:30:45') as described here: http://api.rubyonrails.org/classes/activesupport/timewithzone.html but after requiring active_support , active_support/time_with_zone , doesn't seem time.zone still doesn't work. observe: 2.2.1 :002 > require "active_support" => true 2.2.1 :003 > time.zone nomethoderror: undefined method `zone' time:class 2.2.1 :004 > require "active_support/time_with_zone" => true 2.2.1 :005 > time.zone nomethoderror: undefined method `zone' time:class what's going on? the zone class method time class in active_support/core_ext/time/zones . can require class if want use time.zone better approach might require active_support/all suggested solution require "active_support/all" if want check out source code fort active_support @ github repo

linux - "ambiguous redirect " error in shell script -

i'm getting "ambiguous redirect " error in shell script if use double quotes suggested getting "ambiguous redirect" error . i'm passing shell variable awk -f ',' -v grep_values="${grep_value}" '$6==grep_values' file awk -f ',' -v grep_values="${grep_value}" '$6=="${grep_values}"' file any suggestions.

javascript - Is it possible to inject dynamic angular dependencies -

i have many widgets , component. after time admin can add new component via bower , include in html file using grunt . but how dynamic dependencies can handle in angular.? for example. have following module name , dependencies app = angular.module("sematree", ['ngroute','ngresource', 'ui.bootstrap', 'adf', 'adf.structures.base', 'adf.widget.table']); after time want add stackedcolumnchart.js component in application folder , want add 'adf.widget.stackedcolumnchart' in dependencies opening angular file. is possibility can add dependencies using grunt.? or can handle dynamic under same folder.? kindly give me idea.

php - Alias mock persists over test classes -

i have created alias mock using mockery in class mock calls public static methods made in class want test. in different test class b want use these public static methods (not mocked) seems alias mock created in test class persists when test class b executed. when running tests in test class b exception: badmethodcallexception: static method helper::formatdate() not exist on mock object , though helper class should not mocked in class b. i have tried add: /** * @runtestsinseparateprocesses * @preserveglobalstate disabled */ in test classes make them run separately, error: phpunit_framework_exception: php fatal error: class 'testcase' not found anyone has ideas how solve this? try using aspectmock, supposed mock static methods: https://github.com/codeception/aspectmock anyway problem indication of code not being testable. should consider refactoring , not using static calls need mocked.

nginx - ffmpeg forward stream have 3 seconds delay -

i using nginx module nginx-rtmp-module live server. here sample config. application src { live on; exec /usr/bin/ffmpeg -re -i rtmp://localhost/src/$name -acodec copy -vcodec copy -f flv rtmp://localhost/hls/$name } application hls { live on; hls on; hls_path /tmp/hls; hls_fragment 2s; hls_playlist_length 8s; i use ffmpeg forward stream , has 3 seconds delay between src channel , hls channel. the reason of delay seems ffmpeg itself. are there methods reduce delay when using ffmpeg forward stream? any idea it? thanks. the hls format feature. not possible reduce lag zero. because of server creates playlist read client , read video/audio data. so, there @ least 1 file reproduce. use hls_fragment , hls_playlist_length decrease or use rtmp (flv) data format. read here https://github.com/arut/nginx-rtmp-module/issues/378

python - Conditionally remove lines between two patterns in a file -

input file : <chunk of text> pattern1 abc efg hij pattern2 klm nop pattern3 <chunk of text> output file : <chunk of text> <chunk of text> how remove lines between pattern 1 , pattern 3 of file(inclusive) if there pattern2 between them import sys,re flag,delete,store = false,false,"" line in open(sys.argv[1]): if re.search('pattern1',line): flag = true print store store = line continue if flag : store += line if re.search('pattern2',line): delete = true if re.search('pattern3',line) : if not delete : print store store = '' flag = false delete = false else : print line, print store

php - cakephp pagination with complex query -

i have database structure given below id | title | brand | ---+---------+-------+ 1 |product1 | lg | 2 |pruduct2 | lg | 3 |pruduct3 | lg | 4 |pruduct4 | lg | 5 |pruduct5 | lg | 6 |pruduct6 |samsung| 7 |pruduct7 |samsung| 8 |pruduct8 |samsung| 9 |pruduct9 |samsung| 10 |pruduct10|samsung| 11 |pruduct11| sony | 12 |pruduct12| sony | 13 |pruduct13| sony | 14 |pruduct14| sony | 15 |pruduct15| sony | we need query can mix results brands output should like id | title | brand | ---+---------+-------+ 1 |product1 | lg | 6 |pruduct6 |samsung| 11 |pruduct11| sony | 2 |pruduct2 | lg | 7 |pruduct7 |samsung| 12 |pruduct12| sony | .... , on i have following query can retrieve same result select id, title,brand row_number() on (partition brand_id) row_num product_test order row_; this doesn't work mysql unfortunately need solution based on cakephp find or other apporach thanks in advance you can emulate query in follow

javascript - Convert es6 to es5 using babel then Bundle with Browserify -

im using es6 feature import , classes , understand browser doesn't support import feature , read here . need convert es6 code es5 , , after need bundle them using browserify or gulp, webpack, browserify, etc. question going that: code changes everytime , want check results , need repeat of procedure everytime before want see results? yes, every time change need rebuild unfortunately. take @ watchify or more complex projects might consider using grunt or other task runner automate process. // first install watchify, babelify , babel-preset-es2015 watchify script.js -o bundle.js -t [ babelify --presets [ es2015 ] ]

encoding - How to determine the fileencoding of a file in linux correctly -

this question has answer here: how can detect encoding/codepage of text file 18 answers when have file created in vim/linux :set fileencoding=utf-8 , have diacritics (as e.g. german umlauts) in file, calling file myfile.txt results myfile.txt: utf-8 unicode text . if have no diacritics in file, determination of file encoding results myfile.txt: ascii text . why that? , how can determine safely, whole bunch of files encoded correctly using utf-8 file encoding? edit: ascii 7-bit , subset of utf-8. want know if source files encoded in utf-8 can hold diacritics sometime in future. imo not obvious , find way determine safely. there no generic , reliable way find encoding text file use. furthermore quite few encoding supersets of ascii-7 (utf-8, iso 8859-*, ...) in case of utf-8, 1 trick add (otherwise unnecessary) bom (byte order mark) @ beginning of fi

convert custom locale date time to gmt in android -

i trying convert date time format created on locale time on android device gmt . unable right value .also datetime generated local time on android.how can convert exact gmt unixtime ? string datetime="02-02-2016 8:28 pm"; simpledateformat format = new simpledateformat("dd-mm-yyyy hh:mm a"); format.settimezone(timezone.gettimezone("gmt")); date date = null; try { date = format.parse(datetime); system.out.println("date ->" + date); } catch (exception e) { e.printstacktrace(); } long unixtime = date.gettime() / 1000; try{ simpledateformat sourceformat = new simpledateformat("yyyy-mm-dd hh:mm:ss"); sourceformat.settimezone(timezone.gettimezone("utc")); log.v("current time", ""+ sourceformat.format(new date

notifications - Publish/subscribe on a single AllJoyn object -

i want use publish/subscribe model in alljoyn application. have several objects implement same interface, differ in object path. notification service seems me can select application , not specific object, while using observer can specify interface (which include objects). best way implement it? if each of objects publishes message, listener able path message. @ , aboutlistener in alljoyn_core/samples example.

java - how to orderBy string date? CriteriaBuilder -

how can orderby string date correctly(in date format) using criteria builder? because stored date in model string. my model: @column(name = "date_time") private string datetime; when try query it. criteriabuilder cb = jpa.em().getcriteriabuilder(); criteriaquery<t> cq = cb.createquery(pickup.class); root<t> root = cq.from(pickup.class); criteriaquery<t> = cq.select(root); cq.orderby(cb.desc(root.get("datetime"))); i got wrong order, how can make string date date format orderby it? i'm new it, can me? in advance. datetimeformatter datetimeformatter = datetimeformat.forpattern("yourpattern"); criteriabuilder cb = jpa.em().getcriteriabuilder(); criteriaquery<t> cq = cb.createquery(pickup.class); root<t> root = cq.from(pickup.class); criteriaquery<t> = cq.select(root); cq.orderby(cb.desc(datetimeformatter.parsedatetime(root.get("datetime")))); you can con

pagination - Page-change event not working in ng2-bootstrap -

i trying implement pagination in angular2 app ng2-bootrap. following http://valor-software.github.io/ng2-bootstrap/#pagination my app.html <div> <div class="col-lg-12 text-right"> <pagination [totalitems]="bigtotalitems" (page-changed)="pagechanged($event)" [(ngmodel)]="bigcurrentpage" [maxsize]="maxsize" class="pagination-sm" [boundarylinks]="true"></pagination> </div> </div> my component import { component, view, inject} 'angular2/core'; import { core_directives } 'angular2/common'; import { pagination_components } 'ng2-bootstrap/ng2-bootstrap'; // webpack html imports @view({ templateurl: '/scripts/src/components/demo/demo.html', directives: [pagination_components, core_directives] }) @component({ selector: 'tabs-demo', }) export class democomponent { private totalitems: number = 64;

heroku - Rails memory leak due to all function -

so keep getting memory leak. believe because have table in view shows whole database (whole database being 23k rows) is there method use without getting memory leak on heroku constantly? heres have def index @newevents = event.order("id").page(params[:page]).per(100) @ready = event.all end i cant tell 1 causing issue, haven't thought making 'event.all' paginated whgich may fix bit? sam edit view <h1>events do</h1> <table class="table"> <thead> <tr> <th>id</th> <th>eventname</th> <th>date</th> <th>time</th> <th>link</th> </tr> </thead> <tbody> <% @newevents.each |ne| %> <% if ne.eventready.blank?%> <tr> <td><%= ne.id %></td> <td><%= ne.eventname %></td> <td&

mysql - How to keep temporary mysqli table available in php during statement execution? -

i busy trying execute set of statements involve use of temporary table. my goal create temporary table, insert values , comparison of temporary tables contents table. these statements working in phpmyadmin when executed raw sql, i'm assuming table not available when try insert data. below code php function + mysqli execution: function searcharticles($tags){ global $dbconn, $statuscode; $count = 0; $tagcount = count($tags); $selecttext = ""; $result_array = array(); $article_array = array(); foreach($tags $tag){ if($count == 0){ $selecttext .= "('%".$tag."%')"; }else { $selecttext .= ", ('%".$tag."%')"; } $count++; } $query = "create temporary table tags (tag varchar(20));"; $stmt = $dbconn->prepare($query); if($stmt->execute()){ $query2 = "insert tags values ?;";

hadoop - Spark job taking a long time to finish for levenshtin algorithm processing 200MB in EMR 12 node cluster? -

i have 12 node cluster there 8 virtual cores , 12gb memory in aws emr.data proccessed near 200mb against 30 mb file.i applying levenshtein algorithm on data. command used nohup spark-submit --num-executors 48 --executor-cores 2 --executor-memory 2g textmatcher.py > outputcluster & code used is: exportrdd = sc.parallelize(exportlist) matchrdd = exportrdd.map(lambda x : (x,process.extractone(x, registerlist)[0])) outputrdd = matchrdd.map(lambda (x,y): (exportnamedict[x],establismentid[y],registerednamesdict[y])) outputrdd.saveastextfile(output_file) can tell me how optimize it?please let me know if other information required.

c# - How can I display the current day of the week in XAML using the current regional settings? -

i have following xaml: <window x:class="string_format.mainwindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:s="clr-namespace:system;assembly=mscorlib" mc:ignorable="d" title="mainwindow" height="150" width="250"> <stackpanel margin="10"> <textblock name="textblock" text="{binding source={x:static s:datetime.now}, stringformat=date: {0:dddd, mmmm dd}}"/> </stackpanel> </window> in xaml designer in visual studio 2015 in running application, displays as: "date: thursday, january 28". on german windows 7 regional settings set "

javascript - How can I submit a form via POST? -

<form id="search" action="#" method="post" style="float: left"> <div id="input" style="float: left; margin-left: 10px;" > <input type="text" name="search-terms" id="search-terms" placeholder="search websites , categories..." style="width: 300px;"> </div> <div id="label" style="float: left; margin-right: 10px;"> <button type="submit" onclick="searchbox()" for="search-terms" id="search-label" class="glyphicon glyphicon-search"></button> </div> </form> when user clicks on div id label , want toggle display property of div input . working fine. have used following code implement functionality. function searchbox(){ if ($("#input").css('display') == 'none') { $('

javascript - Angularjs FB login using factory -

i new angularjs.i using factories have written fb login code. , during last step sending data server user registered in database , token sent. here code. 'use strict' app.factory('authenticationfactory',['env','$http','$rootscope', function (env,$http,$rootscope) { return { sociallogin:function(data){ return $http.post($rootscope.apiurl+'sociallogin',data).then(function (resp) { if(resp.status == 200) { return resp.data; } }) }, fblogin: function () { var fb = window.fb; var scopes = 'public_profile,email'; var = this; fb.login(function (response) { return that.facebookstatuschangecallback(response); }, {scope: scopes}); }, facebookstatuschangecallback: function(response){ if (response.status === 'connected

Does it matter for the security of AES how the byte array is encoded in C#? -

i have byte array encrypted using aes pass phrase encrypted using sha-256. works perfect, i'm wondering last part have encode byte array result of encryption. matter, robustness of end result how byte array encrypted, base64, conversion hexadecimal values, else? logically speaking, doesn't matter since there aren't encoding methods , of time obvious one, base64, used. since i'm not versed cryptography want make sure. take byte array example (random array of bytes example): [0] 182 [1] 238 [2] 54 [3] 24 [4] 69 [5] 224 [6] 105 [7] 13 [8] 5 [9] 52 [10]112 [11]71 [12]250 [13]163 [14]234 [15]234 this gives possible result in base64 (random result, not match above): ou+yuekilfrgif3hbh08vu8a== using bitconvertor transform hexadecimal values gives (random result, not match above): a2ebca1945e8bc920532f068d27baef1 it's simple convert above results respective byte array ,

Skip html line in Twig -

i have not used twig before , rise wit problem need skip full line in twig is my html <h4 class="title">{{ 'publish' | translate }}</h4> in index require_once('lib/twig/autoloader.php'); twig_autoloader::register(); $loader = new twig_loader_filesystem('views'); $twig = new twig_environment($loader, array( //'cache' => 'cache', 'auto_reload' => true )); when render html twig error because of translate. need advice how tell twig skip these line not change symbol in html (maybe tag "translate") add fake filter translate $twig->addfilter(new twig_simplefilter('translate', function($v) {return $v;}));

If a text string contains something then return something in R -

consider have df : product category bill payment torrent power limited recharge of videocon d2h dth bill payment of airtel mobile recharge of idea mobile now if string contains "bill payment" , "mobile" both want tag category "postpaid" , if string contains "recharge" , "mobile" want tag "prepaid". i beginner in r easiest way appreciated . result should be product category bill payment torrent power limited na recharge of videocon d2h dth na bill payment of airtel mobile postpaid recharge of idea mobile prepaid we can use grep find index of 'product' both 'bill payment/mobile' ('i1') or 'recharge/mobile' ('i2'). after initializing 'category' na, replace elements based on index i1 , i2. i1 <- grepl('bill paymen

java - Applet - server communication, how can I can do it? -

i have applet , must send request web application data server in database. working objects , useful server responses me objects!! how applet can communicate server? i think web services method, rmi and... make me happy, best , reliable? as long applet communicating server can use serialized object. need maintain same version of object class in both applet jar , on server. not open or expandable way go quick far development time , pretty solid. here example. instantiate connection servlet url servleturl = new url("<url servlet>"); urlconnection servletconnect = servleturl.openconnection(); servletconnect.setdooutput(true); // allow write url servletconnect.setusecaches(false); // write message servlet , not browser's cache servletconnect.setrequestproperty("content-type","application/x-java-serialized-object"); get output stream , write object mycustomobject myobject = new mycustomobject() objectoutputstream outputtoserv

c# - How can I return a custom HTTP status code from a WCF REST method? -

if goes wrong in wcf rest call, such requested resource not found, how can play http response code (setting http 404, example) in operationcontract method? there weboperationcontext can access , has outgoingresponse property of type outgoingwebresponsecontext has statuscode property can set. weboperationcontext ctx = weboperationcontext.current; ctx.outgoingresponse.statuscode = system.net.httpstatuscode.ok;

regex - How to Extract a substring that matches a Perticular Regular expression match from a String in R -

i trying write function can substrings string matches regular expression , example : - str <- "hello brother how you" i want extract substrings str , substrings matches regular expression - "[a-z]+ [a-z]+" which results in - "hello brother" "brother how" "how are" "are you" is there library function can ? you can stringr library str_match_all function , method tim pietzcker described in answer (capturing inside unanchored positive lookahead): > library(stringr) > str <- "hello brother how you" > res <- str_match_all(str, "(?=\\b([[:alpha:]]+ [[:alpha:]]+))") > l <- unlist(res) > l[l != ""] ## [1] "hello brother" "brother how" "how are" "are you" or unqiue values: > unique(l[l != ""]) ##[1] "hello brother" "brother how" "how are" "are yo

php - Issue with file uploader -

i have following code in controller function (this ci): if(!empty($_files['filename']) && is_uploaded_file($_files['filename']['tmp_name'])) { $config['upload_path'] = './uploads/'; $config['allowed_types'] = 'gif|jpg|png'; $config['max_size'] = '1000'; $config['max_width'] = '1024'; $config['max_height'] = '768'; $this->load->library('upload', $config); $this->upload->overwrite = true; if ( ! $this->upload->do_upload('filename')){ $error = array('error' => $this->upload->display_errors()); var_dump($error); exit; } else {

mysql - Table localization - One column for a table -

i have got 1 column table when create 2 localized tables. code bellow. -- month create table `month` ( `id` int primary key not null auto_increment, ); -- month localized create table `month_loc` ( `month_id' int not null, `name` varchar(200) not null, `description` varchar(500) not null, `lang_id` int not null ); month_loc.month_id foreign key. month table holds primary key. other fields should localized. table structure correct ? thanks. if correct implies degree of normalization, , content of columns name , description vary per month_id, lang_id (which combined primary key of month_loc ), yes, design has reached 3rd grade of normlization.

cmd - Xcopy with excluding folders (sub-directories) -

i want copy files , folders in directory folder excluding sub-folders files contains it, example have large number file node_modules directory 100mb 50k+ files, don't need copy. i tried using xcopy : xcopy . c:\inetpub\civebuildcentral\ui\. /y /s /exclude:cive\ui\elist.txt and elist.txt contains : \node_modules\ but no luck, , annoying syntax , don't see optimal check-in such useless file case. any idea how solve this? well, after searching on slimier question found in stackoverflow not helpful case: xcopy command excluding files , folders ( marked duplicated , not duplicated, case if answer seemed same way, , found no answer case anyway) but found if using windows 7 or more, can use robocopy instead, found powerful tool compared old man xcopy , , no need dirty work exceptions, command achieve need replaced xcopy : robocopy . c:\inetpub\civebuildcentral\ui\. /is /s /xd node_modules for full documentation can see link : http://ss64.com/nt/r

javascript - How to create a custom angular directive which contains multiple input controls? -

i working on first angular project. better or worse, trying convert repeatable html directives. have requirement let user select time in hh:mm format. need show 2 select elements. since need give control @ quite few places, trying convert directive. directive template <div class="filterlabel">{{fieldlabel}}</div> <select class="filterddl" ng-style="{width: selecthhwidthpx + 'px'}"> <option value="none">hh</option> <option value="8">08</option> <option value="9">09</option> <option value="10">10</option> <option value="11">11</option> <option value="12">12</option> <option value="13">13</option> <option value="14">14</option> <option value="15">15</o

c# - Escape & character in string -

i want set value appconfig key,but value contains & character.i tried double && "8l&&l26x0s8@p" dont working.can me please? <add key="sap_pass" value="8l&l26x0s8@p"/> as app.config xml file, use xml entities this. specifically & coded &amp; (including semicolon) in xml .

indexing - insert whole table types in Oracle into database without index -

i have new question must solved! had created table type type ebrbktable table of ebtdccrbk%rowtype index pls_integer; rbktable ebrbktable; and insert data table following statements rbktable(inserttable).bdadduserid := 'ft_rbk_tdcc'; the last insert following statement forall in 1..inserttable - 1 insert ebtdccrbk values rbatable(i); i ask whether there ways insert type once without count(i) thanks! a forall statement not loop such. what send elements of array sql engine in 1 go, enables sql insert rows without having go pl/sql engine more data. in other words forall removes context switching have in regular loop. we can show simple trace. consider: sql> alter session set sql_trace=true; session altered. sql> declare 2 type ebrbktable table of ebtdccrbk%rowtype index pls_integer; 3 rbktable ebrbktable; 4 begin 5 6 idx in 1..100000 7 loop 8 rbktable(idx).bdadduserid := dbms_ra

NoDogSplash not block wlan0 traffic TP-Link MR3020 OpenWrt -

i have trouble configuration nodogsplash 0.9_beta9.9.6 on mr3020 openwrt 12.09. here nodogsplash config file. https://gist.github.com/anonymous/4b8834f375b073ca5a3a my network config. https://gist.github.com/anonymous/3e6a740b73d6b249dcec my wireless config https://gist.github.com/anonymous/d776daa618dfcdbe72f3 the problem phone connect directly internet through access point , doesn't open splash page. when in luci traffic graph see phones traffic, in ndsctl status i see current clients: 0. in config interface 'wifi' section specified ifname eth0 , while should wlan0 . then, in nodogsplash.conf file, should correctly set externalinterface parameter (the 1 use connect internet, check ifconfig output external ip).

PHP wont load XML file -

Image
this question has answer here: domdocument - load xml rss - failed open stream 2 answers i writing web app , trying access rss feed financial times. when run code following error. hoping tell me i've went wrong. function getftrss(){ //create object parse xml input finanial time's uk companies rss feed $rssfeed = new domdocument(); //gather information , load object $rssfeed->load('http://www.ft.com/rss/companies/uk'); $articles = array(); //lookp through elements in xml document foreach($rssfeed->getelementsbytagname('item') $newsartcle){ $title = $newsartcle->getelementsbytagname('title')->item(0)->nodevalue; $desc = $node->getelementsbytagname('description')->item(0)->nodevalue; $link = $node->getelementsbytagname('link')->item(0)->

Displays horizontal and vertical images using the CSS -

i have fixed-width tape images. horizontal displayed (the width of tape), vertical not fit on entire screen. look @ here http://didi.url.ph/design (click first block cat) :) now have: #ajaxcontent .field-item img { height: auto; width: 100%; } how make: maximum width of image - width of tape, maximum height - height of screen. so should be it not work: #ajaxcontent .field-item img { max-width: 100%; max-height: 80vh; } because image stretched disproportionately. are there ideas? you can this: css #ajaxcontent { background: #ffffff none repeat scroll 0 0; height: 90vh; margin: 40px auto; overflow: auto; position: relative; }

for loop - Unable to delete hidden files using FOR command -

i trying put command delete hidden , non-hidden .tmp files under sub-directories deep file structure using 8.3 short file names. i have been experimenting simple test directory called c:\dl\test1234567890 using following command: for /r c:\dl\test1234567890 %q in (*.tmp) del /a "%sfq" i hoping /a delete hidden , non-hidden .tmp files seems delete non-hidden files. hidden files remain. there better way of doing this? attrib /s -h "d:\wherever\whatever\*.tmp" del /s "d:\wherever\whatever\*.tmp" the first command un-hides files, second delets them (use extreme caution) you may want add -s , possibly -r list of switches in attrib command (remove "system" , "read-only" attributes)

Import code from another source (python) (windows 7,8,10) -

i having problem. 2 different codes in same directory, cannot following: from py_file1 import * considering py_file2.py , directory looks this: new folder > py_file1.py py_file2.py i want able this: #file1 contents: def a(): print("a function in file1.") and this: #file2 contents py_file1 import * a() and when run in interpreter, there no importerror . >>> function in file1. >>> it looks you're current directory not same files stored. latter not in path. you should put modules somewhere in search path of python or add directory files in search path: from sys import path path.insert(1, "path/to/lib") py_file1 import * a()

Google Drive SDK API does not lists the file uploaded by Google Drive in java -

i creating application can insert files google drive , lists it. using google drive sdk v2 api. problem is not listing files not uploaded through application. if upload directly google drive not listed in application. here method list file: private static list<file> retrieveallfiles(drive service) throws ioexception { list<file> result = new arraylist<file>(); files.list request = service.files().list(); { try { filelist files = request.execute(); result.addall(files.getitems()); request.setpagetoken(files.getnextpagetoken()); } catch (ioexception e) { system.out.println("an error occurred: " + e); request.setpagetoken(null); } } while (request.getpagetoken() != null && request.getpagetoken().length() > 0); return result; } and iterating files : list<file> files = retrieveallf

Using java cplex to solve TSP, getValues of variables gives an error -

i use cplex solve travelling salesman problem (tsp). given if x[i][j]=1 , path goes city i city j , otherwise, ther no path between these cities. corresponding matrix: ilonumvar[][] x = new ilonumvar[n][]; for(int = 0; < n; i++){ x[i] = cplex.boolvararray(n); } when cplex finishes solving, want values of x this: if(cplex.solve()){ double[][] var = new double[n][n]; for(int = 0; i<x.length; i++){ for(int j = 0 ; j < x[i].length; j ++){ var[i][j] = cplex.getvalue(x[i][j]); if(var[i][j] ==1){ system.out.print(i + " "+ j); } } } } but gives error. appreciate can give advice. error in : var[i][j] = cplex.getvalue(x[i][j]); the explain : exception in thread "main" ilog.cplex.ilocplex$unknownobjectexception: cplex error: object unknown ilocplex @ ilog.cplex.ilocplex.getvalue(ilocplex.java:6495) the entire code following: import java.io.ioexcep

javascript - External replace function not working -

why have place replace function inside str.replace statement? this works fine: str = str.replace(/&|<|>|"|'/g, function replacer(match) { switch (match) { case "&": return "&amp;"; case "<": return "&lt;"; case ">": return "&gt;"; case '"': return "&quot;"; case "'": return "&apos;"; } }); this not work, returning "reference error: match not defined": str = str.replace(/&|<|>|"|'/g, replacer(match)); function replacer(match) { switch (match) { case "&": return "&amp;"; case "<": return "&lt;"; case ">": return "&gt;"; case '"': return "&quot;"; case "'": return "&apos;"; } } why not able call rep

java - Avoiding password pop ups in JSch -

i want bypass password step/password pop-up. trying assign password internally upon pop-up. don't want user type again , again. right can pass internally clicking on ok without in textfield of password , want rid of prompt import com.jcraft.jsch.*; import java.awt.*; import java.io.ioexception; import java.io.inputstream; import java.io.outputstream; import javax.swing.*; public class jumphosts { textpanel textpanel = new textpanel(); public static string my_password = "password"; public void jumphosts(final string[] arg,final string command,final textpanel textpanel) { stringbuffer resultdisplaybuffer = new stringbuffer(); swingworker sw = new swingworker(){ @override protected object doinbackground() throws exception { try{ jsch jsch = new jsch(); if(arg.length <= 1){ system.out.println("this program expects more arguments.

django - Run startup code when mod_wsgi autoreload after file changes -

i have mod_wsgi, daemon mode, , django. i make mod_wsgi run code @ startup if provide application-group , process-group params wsgiscriptalias - https://stackoverflow.com/a/20930912/203485 (instead default it'll run on first request). but how make run same startup code after reloads workers automatically after wsgi file changes (you upload new files , touch wsgi file)? won't run startup code until first request. i need heavy initialization after workers start , preferably without server reload (it requires root). you can call function @ module scope of wsgi script.

haskell - Recursively adding to binary tree -

i'm trying recursively add binary tree in haskell. i'm following learn haskell on this, few changes, i'm getting errors, not understand: data male = male { malename :: string , maledob :: int } deriving (show, read, eq, ord) data female = female { femalename :: string , femaledob :: int } deriving (show, read, eq, ord) data familytree = emptytree | node (familytree female) (familytree male) deriving (show, read, eq, ord) singleton :: -> familytree singleton x = node x emptytree emptytree treeinsert :: (ord a) => -> familytree -> familytree treeinsert x emptytree = singleton x treeinsert x (node left right) | x == = node x left right | x < = node (treeinsert x left) right | x > = node left (treeinsert x right) here error message i'm getting: couldn't match type `female' `male' expected type: male act

c# - deserialize XML file into a list error -

i writed follow generic code deserialize xml file list: public list<t> getlist<t>(string fpath) { filestream fs; fs = new filestream(fpath, filemode.open); list<t> list; xmlserializer xmls = new xmlserializer(typeof(list<t>)); list = (list<t>)xmls.deserialize(fs); fs.close(); return list; } but got the exception on desirialize action. "an exception of type system.invalidoperationexception occurred in system.xml.dll not handled in user code" this example xml file: <?xml version="1.0"?> <arrayofadmin xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema"> <admin> <myusername>user</myusername> <mypassword>pass</mypassword> </admin> </arrayofadmin> whats cause exception? first of all, file should contain valid xml data serialized list<t> object.

javascript - Protractor page object issues -

i seem stuck in construction of page objects. read lot of docs page objects , know contain 2 things: elements present on page functions interact page when check example files see elements defined in beginning of each page object. in test, pageobject imported via require. problem see there objects aren't yet present when require happens. there way solve without having require when page loaded? thanks inadvance. regards there new protractor style guide coming (currently in review), should clear things lot, page object creation , requiring part. here current draft: protractor style guide regarding question, first of all, page objects need defined functions, declaring page object elements in constructor: var questionpage = function() { this.question = element(by.model('question.text')); this.answer = element(by.binding('answer')); this.button = element(by.classname('question-button')); this.ask = function(question) { t

sockets - BR / EDR / LE Android Kitkat combo issue -

i'm trying send 2 chunks of 20 bytes in ble central peripheral. fine. after want send image using classic socket connection. image transferred in lollipop not in kitkat or jelly bean . can me this. socket timeout exception always. note: only sending image using classic socket code in kitkat or jelly bean works without doing ble data transfer

java - How to configure YAJSW to find jnidispatch.dll on the disk? -

we using yajsw wrap our java application windows service. while testing workstation images there warning corporate mcafee antivirus because on launching service, jnidispatch.dll copied jna-4.1.0.jar new name in temporary folder. adding dll signature antivirus rules prevents showstopping error severe warning pops every time. we tried copying jnidispath.dll c:\dllfolder , adding wrapper.conf line: wrapper.java.additional.4 = -djna.boot.library.path=c:/dllfolder/ we added c:\dllfolder windows system %path% , rebooted windows. however when monitoring windows service start, can still see dll being extracted jar instead , antivirus complains. the comments in yajsw code native.java say: when jna classes loaded, native shared library (jnidispatch) loaded well. attempt made load paths defined in <code>jna.boot.library.path</code> (if defined), system library path using {@link system#loadlibrary}, unless <code>jna.nosys=true</code>. if not found, appro

post - Get all _POST vars using a loop in Yii -

i have code $str = ''; foreach ($_post $k => $v) { $str .= $k.'='.$v; } is possible make same chttprequest ? didn't find method it. need md5 in end, there no security issues. i dont think chttprequest intended post data, yii uses $_post variable, gii's default output example can this: public function actioncreate() { $model=new model; // uncomment following line if ajax validation needed // $this->performajaxvalidation($model); if(isset($_post['model'])) //<- post data var { $model->attributes=$_post['model']; //<- post data var if($model->save()) $this->redirect(array('view','id'=>$model->id)); } $this->render('create',array( 'model'=>$model, )); }

java - JGraphX Moving cells and keeping edges -

Image
i try move graph in jgraphx. first try use setgeometry, moves entire coordinate system , origin. no option me, because bit tricky when moving several graphs. my second try with object[] ver = graph.getchildvertices(graph.getdefaultparent()); graph.movecells(ver, 100, 100, false); moves cells. far good, edges start , end points change positions. after moving cells: before moving cells, edges have correct position. so how can set position of edges normal start , endpoints? alternatively, appreciate other approach move cells given position. edit: seems behaviour occurs, if add layout before. without layout, moving cells works expected. mxgraph graph = new mxgraph(); object parent = graph.getdefaultparent(); graph.getmodel().beginupdate(); try { object v1 = graph.insertvertex(parent, null, "hello", 20, 20, 80, 30); object v2 = graph.insertvertex(parent, null, "world!", 240, 150, 80,

javascript - How to get li chechbox checked status in jquery -

how li checkbox checked status in jquery. i want one, throw me undefined. $('#ul'+$id+' li:nth-child('+_index+') span input:checkbox').attr("checked") can out of one. use .is(':checked') on jquery object. $('#ul'+$id+' li:nth-child('+_index+') span input:checkbox').is(':checked');