Posts

Showing posts from July, 2015

python - Pyorient query To Json -

i'm using orientdb python 3.5 , create api records. problem got records need serialize these records. here code. from flask import flask, request flask_restful import reqparse, abort, api, resource import pyorient app = flask(__name__) api = api(app) client = pyorient.orientdb("localhost", 2424) client.set_session_token( true ) # set true enable token based client.db_open( "intera", "admin", "admin" ) ### store token somewhere sessiontoken = client.get_session_token() ### destroy old client, equals user/socket/ip ecc. del client ### create new client client = pyorient.orientdb("localhost", 2424) ### set previous obtained token re-attach old session client.set_session_token( sessiontoken ) ### dbopen not needed perform database operations ### set flag again true if want renew token client.set_session_token( true ) # set true client.db_open( "intera", "admin", "admin" ) new_sessiontoken

sonata admin - Symfony 2.8: How to prevent editing user's service fields -

i'm newby in symfony, excuse ignorance. in project use sonata user bundle, user entity extended several fields. of them can edited user himself, while others serviceable , can edited admin. question is: how ensure security when editing information user? see 2 ways: 1. use custom validation constraints check user's role. 2. use one-to-one related entity own admin. perhaps there standard ways accomplish task? thanks in advance! upd: problem there 1 entity (user) can edited different places: admin area , public area. naturally, forms admin , public areas different, there possibility attacker can forge form , edit fields accessible administrator. therefore, want protect them @ level of entity. possible? there many cases of security. can use @security has_role('role_admin') annotation action or in twig is_granted display or not field or use custom voter check if user can edit or delete un objet @ this. describe need you.

signals - Can I send a ctrl-C (SIGINT) to an application on Windows? -

i have (in past) written cross-platform (windows/unix) applications which, when started command line, handled user-typed ctrl - c combination in same way (i.e. terminate application cleanly). is possible on windows send ctrl - c /sigint/equivalent process (unrelated) process request terminate cleanly (giving opportunity tidy resources etc.)? the closest i've come solution sendsignal 3rd party app. author lists source code , executable. i've verified works under 64-bit windows (running 32-bit program, killing 32-bit program), i've not figured out how embed code windows program (either 32-bit or 64-bit). how works: after digging around in debugger discovered entry point behavior associated signal ctrl-break kernel32!ctrlroutine. function had same prototype threadproc, can used createremotethread directly, without having inject code. however, that's not exported symbol! it's @ different addresses (and has different names) on different versions

android - Path to sdk not working when trying to run calabash backdoors -

i trying run calabash-android console run backdoors on project i'm working on every time try run error: $ calabash-android console app//build/outputs/apk/app-debug.apk starting calabash-android console... loading /var/lib/gems/2.3.0/gems/calabash-android-0.9.0/irbrc running irb... warn: did not find 'adb' in standard directory of '/media/jack/os/users/jackb/appdata/local/android/sdk'. calabash therefore take longer load warn: did not find 'aapt' in standard directory of '/media/jack/os/users/jackb/appdata/local/android/sdk'. calabash therefore take longer load warn: did not find 'zipalign' in standard directory of '/media/jack/os/users/jackb/appdata/local/android/sdk'. calabash therefore take longer load error: not locate android dependency error: can read how calabash searching android sdk , how can here: error: https://github.com/calabash/calabash-android/blob/master/documentation/installation.md#prerequisites however ha

java - Issue when compiling android application -

good evening. taking course in android , having issues compiling app. i following this tutorial. have earlier set requestqueue requests. this mainactivity.java file: package com.ticketapp.emailaddresss.ticketapp; import android.content.intent; import android.net.uri; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.util.log; import android.view.view; import android.widget.button; import android.widget.textview; import com.android.volley.request; import com.android.volley.requestqueue; import com.android.volley.response; import com.android.volley.volleyerror; import com.android.volley.toolbox.stringrequest; import com.facebook.accesstoken; import com.facebook.graphrequest; import com.facebook.graphresponse; import com.facebook.httpmethod; import com.facebook.login.loginmanager; import com.facebook.share.model.sharehashtag; import com.facebook.share.model.sharelinkcontent; import com.facebook.share.widget.sharedialog; import java.ut

sql - Group by clause - output is not as expected -

below sql query list of dates table. select t2.counter_date mydates table1 t1; output: mydates 2014-03-14 00:00:00 2014-05-11 00:00:00 2014-11-03 00:00:00 2014-12-23 00:00:00 2015-01-12 00:00:00 2015-08-08 00:00:00 2016-03-14 00:00:00 2017-03-14 00:00:00 2017-03-19 00:00:00 below solution: select min(t1.counter_date) olddate,max(t1.counter_date) latestdate table1 t1; in following demo can see query giving correct results. problem must in data. edit: after edit clear problem is. once perform following query: select min(date), max(date) tab group date than min(date) has equal max(date) since there 1 date in group.

Django How to catch ModelForm unique together errors -

i have modelform has unique_together constraint on fields. when pass data form , call form.is_valid(), returns false if record exists , if other error occurs. so, want in case record exists(unique_together validation fails) , thing in case form.is_vaid() returns false due other reasons. how achieve ? it have modelform code , traceback errors in both cases give more accurate answer, workaround parse form.errors, corresponding type error or message error , write corresponding code. ps : message should comment under post lack few reputation points, sorry that.

firefox - Stop page from loading after command executed -

is possible have imacros script force firefox stop loading page after executed previous command. set !timeout_step 1 set !errorignore yes tag pos=1 type=input:submit form=id:flg-addspray attr=name:submit wait seconds = 10 [stop page load] [next commands] for whatever reason, script gets stuck after submit button executed, never loads next page, or gets stuck on next page. , script halts not moving along long string of commands. it's in loading infinite loop. want stop. , move on. i think should use built-in variable !timeout_page : set !timeout_step 1 set !errorignore yes set !timeout_page 15 tag pos=1 type=input:submit form=id:flg-addspray attr=name:submit set !timeout_page 60 wait seconds = 10

forms - How to add [disabled]='!f.valid' to submit button using ng-content in angular 4? -

have form component contains email, password field , submit button passed through ng-content login form 'login' button can showed , register form 'register' button can showed. form component template code: <form #f="ngform" (ngsubmit)="onsubmit(f.value)"> <div class="form-group"> <label for="email">email</label> <input type="email" class="form-control" placeholder="enter email address" name="email" ngmodel > </div> <div class="form-group"> <label for="password">password</label> <input type="password" class="form-control" placeholder="enter password" name="password" ngmodel > </div> <ng-content select="[submitbtn]" ></ng-content> code of f

java ee - How to use long-polling for pushing server side events? -

i know basics stuff: how mechanism works, limits, etc. however, want utilize long-polling allow other developers in team push events client (in case, browser) when convenient. i working java ee, can use asyncservlet . thinking of creating server side api (java) client side (javascript) hide implementation details under nice abstraction. my initial idea create api similar exposed jms , other message oriented middlewares (like apache artemis or rabbitmq). think? there library offers high level api long-polling (for java ee)?

Replacing characters in a string based on mapping two sets of characters in Java -

i have edited 2 strings , can covert them character maps. trying think through best way map , replace based off of these 2 strings. example: have word append front of alphabet based on user input. in example cat(catdefghijkl..). take sentence , replace characters in based on new alphabet. (now c, b a, c t). not looking code input on best way accomplish this. can map 2 strings or character maps , replace based on mappings? you can use map<character, character> . the key regular alphabet letter, , value new letter. map<character, character> newalphabet = new hashmap<>(); list<character> regularalphabet = arrays.aslist('a', 'b', 'c');//put complete alphabet here public void updatealphabet(list<character> newletters) { assert (newletters.size() == 26);//or 52 uppercase atomicinteger = new atomicinteger(0); newalphabet.clear(); regularalphabet.stream() .foreach(letter -> newalphabet.put(le

feature extraction - Uniform LBP giving Better Performance than Uniform LTP on CK+ 7 Expression Dataset -

well working on fer problem , started basic lbp , ltp feature descriptor. have used uniform variant , performed experiments on ck+ 7 expression dataset , using plsregession classifier. after performing 10-cv getting better performance lbp ltp. ltp threshold has taken 10 has been referred work on fer using ltp. the thing confusing me "ltp should give better performance lbp". trying since long time, changed parameters not getting satisfactory results. please me out. thanking

python - Increment times if date has changed? -

i have list of strings, , 1 of them looks this: 'thu jun 18 19:58:02 2015 ...many lines of data... txup: 19:59:47 txdown: 20:05:22 rxup: 21:43:17 rxdown: 22:13:01' but may this: 'fri jun 19 23:12:12 2015 ...many lines of data... txup: 23:39:47 txdown: 23:57:22 rxup: 00:01:17 rxdown: 01:13:01' as can see, in cases time might cross midnight. when happens, using above string example, date associated time jun 20 instead of jun 19. i need write code compares 'rxup' time date/time @ start of string , recognizes if , when increases day because passed midnight (all relative date/time @ beginning). if hasn't crossed midnight , same day, i'm done. if has crossed midnight, need take difference between time , time @ beginning timedelta object, , add increment onto copy of time @ beginning. how this? if times grow monotonously can compare them in lexicographic order. '00:01:17' less '23:39:47', each time next timestamp l

npm install npm -g won't update npm to the latest version -

Image
i using npm v5.3.0. want update npm v5.4.1.to type following in terminal: npm install -g npm without errors.however when type npm -v version 5.3.0 not 5.4.1 i have mention have changed npm prefix directory. ideas? use ubuntu 17.04 that's console output : to upgrade, run: sudo npm install npm@latest -g the npm module available download @ https://registry.npmjs.org/npm/-/npm- {version}.tgz.

executing a php script from a different location -

i have php script located in /var/log/myscript.php , want execute /home/user/run. keep getting following errors below. if go directly in folder , run php myscript.php script execute. strange, suggestions. have included script bellow php notice: undefined variable: f in /var/log/myscript.php on line 73 php warning: fclose() expects parameter 1 resource, null given in /var/log/myscript.php on line 73 <?php $host = "some_destination"; $user = "postgres"; $pass = "postgres"; $db = "some_database"; $con = pg_connect("host=$host dbname=$db user=$user password=$pass"); $line = 1; $files = array(); $dir = opendir('.'); while(false != ($file = readdir($dir))) { if(($file != ".") , ($file != ".."){ $files[] = $file;. } } natsort($files); // sort. foreach($files $file){ if ( strpos($file,'syslog.1') !== false ) { echo "\n" .$file; $f = fopen($file,"r") or

c# - Change Layouts from Navigation Drawer (UWP) -

Image
i know basic question none of tutorials found explain me. so have mainpage.xaml has navigation drawer. then have transferpage.xaml has different content on it. tried doing this: private void mylistbox_selectionchanged(object sender, selectionchangedeventargs e) { frame frame = new frame(); if (startlistboxitem.isselected) { frame.navigate(typeof(transferpage), null); } } but didn't work. need transfer page 1 page 2 while keeping navigation drawer. please ask me more specific before downvoting. as @codexnz said frame instantiated not on page. requirement, set frame splitview.content following: <splitview.content> <frame name="myframe"/> </splitview.content> and navigate page it, more detail refer code sample . private void mylistbox_selectionchanged(object sender, selectionchangedeventargs e) { if (mainitem.isselected) { myframe.navigate(typeof(homepage)); } else if (fav

java - How to run a plugin as the first task when a mvn command (ex: mvn clean install) is given in command line? -

in maven project. want have pom.xml.template (the original pom.xml having version values parameters) , versions.properties file (where have value versions) , need generate pom.xml file when user gives mvn clean or mvn install or similar command. if create plugin it. when , can trigger plugin first action command executing custom plugin. try using properties maven plugin

javascript - Confusing webpack/ES6 project setup -

i trying setup first es6 , webpack "application" , want use classes , modules. everytime want transpile application via webpack command following error: $ webpack hash: c91db5651ec9123b8959 version: webpack 3.5.6 time: 2319ms asset size chunks chunk names app.bundle.js 354 kb 0 [emitted] [big] main index.html 978 bytes [emitted] [0] ./src/app.js 14 kb {0} [built] + 1 hidden module error in ./src/app.js module not found: error: can't resolve 'radar' in 'c:\dev\git\my-first-app\src' @ ./src/app.js 7:13-29 child html-webpack-plugin "index.html": 1 asset [0] ./node_modules/html-webpack-plugin/lib/loader.js!./src/index.html 1.37 kb {0} [built] [2] (webpack)/buildin/global.js 509 bytes {0} [built] [3] (webpack)/buildin/module.js 517 bytes {0} [built] + 1 hidden module i have got following files package.json { "name": "my-firs

ios - UICollectionView.reloadData() works after adding first item, then seems to run one behind -

i have empty uicollectionview array of strings datasource. when add first string array , call reloaddata() on collectionview works expect. when add second string , call reloaddata() nothing happens, array has grown. when add third item , call reloaddata(), second item appears not third. each new addition results in previous string appearing. if call reloaddata() without adding string, last item appears. my code adding collection: func addkeyword(keyword: string) { keywords.append(keyword) newkeywordtext.text = "" keywordcollection.reloaddata() } and collectionview relevant code: func collectionview(_ collectionview: uicollectionview, numberofitemsinsection section: int) -> int { print("keywords: @ refresh \(keywords.count)") return keywords.count } func collectionview(_ collectionview: uicollectionview, cellforitemat indexpath: indexpath) -> uicollectionviewcell { let keyword = keywords[indexpath.row] let

javascript - CSS div disabled -

Image
having issue css on page. i not original owner or creator of html page therefore don't know in files fix problem. issue: have auto-populate script input productid , productsku fields url parameter once page loads(tested , works on other pages except this). now, suspect jquery in files causing field input form div disabled until select calender date/time shown in picture below. dont know or built-in function couldve came from. appreciated. it shows "step final disabled" once select calender date , time, turn "step final". think issue on why auto-form populate not working im not 100% sure. first off, disabled class. doesn't disable input (it's on div anyway). secondly, coming easy appointments plugin @ 1 of these line numbers: js/frontend-bootstrap.js:377: jquery(element).addclass('disabled'); js/frontend-bootstrap.js:400: calendarel.parent().next().addclass('disabled'); js/frontend-bootst

vb.net - How to NOT make new column in DGV before current column is completely filled -

i making application small store management , using dgv input of transaction. the problem is: want dgv make new column after current column filled and if there >0 filled column, , next column totally empty, , press enter or tab, focus changed btn enter.

Add Tachyons to angular 4 cli build -

i using angular 4 template @ https://github.com/ngx-rocket/starter-kit how can add css utilities call tachyons build bundle use angular cli. since pure css file not javascript , not css module well, impossible require 'tachyons' jquery or bootstrap include build can other dependency. any idea how do? guys in .angular-cli.json configuration file, can specify styles include (including specifying pure css files of third party packages). as result styles section can this: "styles": [ "../node_modules/bootstrap/dist/css/bootstrap.css", "../node_modules/font-awesome/css/font-awesome.css", "../node_modules/animate.css/animate.min.css", "styles.sass" ], more info can founded in wiki angular-cli project: global styles

The Huxley: java.util.NoSuchElementException: No line found -

i having problems when submiting answer on https://www.thehuxley.com . when run code on eclipse, goes ok, on huxley, this: exception in thread "main" java.util.nosuchelementexception: no line found @ java.util.scanner.nextline(scanner.java:1540) @ huxleycode.main(huxleycode.java:12) and here code itself: import java.io.*; import java.util.*; public class huxleycode { public static void main(string args[]) { scanner in = new scanner(system.in); int menor = 0, pos = 0, entradas = 0, temp; entradas = in.nextint();// watch out line in = new scanner(system.in); string valores = in.nextline(); entradas = 0; (string val : valores.split(" ")) { temp = integer.valueof(val); if (entradas == 0) { menor = temp; } else if (temp < menor) { menor = temp; pos = entradas; } entradas++; } in.close(); system.out.println("menor valor: " + me

spring - Java server application, can i access remote computers in same network and retrieve computer info threw ip address or computer name -

im working on new project , try create spring boot server application in java retrieve computer info operationsystem, model etc.. im creating oshi api . possible retrieve info remote computer in same domain or same network entering computer name or ip address ?

Python/Javascript parsing - having trouble with a particular string -

trying parse table under "wolfsburg" this site can't seem figure out data formatted in way. novice eyes there doesn't seem sort of logical structure make able converted else json or xml , parsed way. the relevant part of script follows , info i'm interested in stats each individual player : <script type="text/javascript"> var matchstats = [[33,'wolfsburg',6.27928571428571,[[['blocked_scoring_att',[3]],['accurate_pass',[139]],['att_miss_left',[1]],['won_contest',[7]],['total_scoring_att',[9]],['total_throws',[26]],['aerial_won',[33]],['total_pass',[263]],['att_miss_high_left',[1]],['att_miss_right',[1]],['total_tackle',[23]],['total_offside',[7]],['shot_off_target',[6]],['aerial_lost',[29]],['fk_foul_lost',[7]],['won_corners',[3]],['possession_percentage',[29.4]],['att_miss_high',[3

Excel VBA Range variables and Autofill -

i'm adding columns end of table. first headings , formulas in column underneath. want autofill formulas whole list. believe variable declaration problem. keep on getting error @ autofill section @ bottom. dim lastcol long, lastrow long dim ooscol long, lcell long dim lrange range dim ws worksheet set ws = application.activeworkbook.activesheet ws .name = "summary" lastcol = .cells(51, .columns.count).end(xltoleft).column .cells(51, lastcol + 1).value = "oos no soo" .cells(52, lastcol + 1).formular1c1 = "=if((rc[-21]=4)*and(rc[-20]=0)*and(rc[-19]=0)*and(rc[-3]=""roster"")*and(rc[-4]=""listed""),1,"""")" .cells(51, lastcol + 2).value = "oos soo" .cells(52, lastcol + 2).formular1c1 = "=if((rc[-22]=4)*and(rc[-21]>0)*and(rc[-20]>0)*and(rc[-4]=""roster"")*and(rc[-5]=""listed""),1,"""")

cmake - How to use Jenkin declarative pipeline to build and test on multiple platforms -

i'm trying feel should simple do, can't figure out how. basically have jenkins master (running on linux) , 2 slaves, 1 on windows , other on macos. i want build project on 3 platforms , run gtest tests on 3 platforms too. i can build , run test, junit step doesn't seem collect test results. i tried put post block everywhere, doesn't work. if try put post block in test stage or sibling of stages , following error: required context class hudson.filepath missing perhaps forgot surround code step provides this, such as: node caused agent none - post block doesn't know run. so tried put post block inside node block in parallel step test stage, doesn't seem - doesn't show in console output. here's jenkinsfile: pipeline { agent none stages { stage ('clean') { steps { parallel ( "linux" : { node ("linux") {

PHP Cron Job - Set created folder owner / group to Apache -

i have cron job executes shell script runs php program creates folders used internal site. issue job creates folders root owner , not allow access folder when user accesses application via browser. folders created correctly when created through browser app. i have been trying different techniques site , others few days including using "apache" or "www-data" cron job, neither works. when use "apache" job appears in log, not executing script. when use "www-data" cron job not execute. tried switching user apache in script, error stating "this account not available". environment: centos 6.2,,php 5.3.3 crontab entry executes , creates folder root owner * * * * * root /path/script.sh >> /log/script.log 2>&1 entry "apache user" - shell not execute, no error messages * * * * * apache /path/script.sh >> /log/script.log 2>&1 entry "apache user" - shell not execute, c

vue.js - Editing a form with save and cancel options -

i'm new vuejs. i'm trying create form simple save , cancel functionality. when binding model form fields updated inputs changed, don't want tight binding. instead, want able save , submit when "save" button pressed , revert changes when "cancel" button pressed. what's suggested vue way of doing this? it ideal if can show server save status , indicate on form if submission failed. if know of examples or samples hugely helpful. thanks! see in jsfiddle <template> <div id="app"> <div> first name: <input type="text" v-model="user.firstname" :disabled="!isediting" :class="{view: !isediting}"> </div><div> last name: <input type="text" v-model="user.lastname" :disabled="!isediting" :class="{view: !isediting}"> </div> <button @click="i

android - Error:(44, 5) error: method does not override or implement a method from a supertype -

indefinite.java main code , there someproblem code.any appreciated. package mycompanycom.indefinite; import android.content.intent; import android.support.v7.app.actionbaractivity; import android.os.bundle; import android.support.v7.app.appcompatactivity; import android.view.menu; import android.view.menuitem; import android.view.view; import android.widget.button; import android.widget.edittext; import android.widget.relativelayout; public class indefinite extends actionbaractivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_indefinite); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.menu_indefinite, menu); return true; } @override public boolean onoptionsitemselected(menuitem item) { // handle action bar item clicks here. action bar // automatically handle click

java - Spring boot Could not resolve placeholder application.yml -

i'm new in spring , have trouble it. when run application intellij idea works perfect, when compile .jar application give me error java.lang.illegalargumentexception: not resolve placeholder 'jwt.secret' in value "${jwt.secret}" this application.yml located @ src/main/resources #config application jwt: header: authorization secret: mysecret expiration: 604800 route: authentication: path: auth refresh: refresh token: check when change works perfect. // @value("${jwt.secret}") @value("mysecret") private string secret; what i'm doing wrong? note: i'm using maven this pom.xml <?xml version="1.0" encoding="utf-8"?> <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"

javascript - Google Tag Manager Removing some {{Click Text}} -

i want track link clicks i've set tag label {{click text}} however, if have following html, returns "hello world dont want text" <a href="http://example.com"> hello world <span><p> dont want text </p></span> </a> how exclude "i dont want text" result? thanks i presume have trigger type click-just links . then, achieve hello world in tag need following: 1) create variable: type: custom javascript code: function () {return $({{click element}}).clone().children().remove().end().text();} name: click text without children 2) in trigger, can use variable {{click text without children}} return hello world you

seq - Creating a repeating vector sequence in R -

this question has answer here: r: generate repeating sequence based on vector 1 answer i need help. how create following vector sequence: 1 1 1 1 2 2 2 3 3 4 i tried use (rep) , (seq) still unsucessfull. try this: rep(1:4,4:1) output: [1] 1 1 1 1 2 2 2 3 3 4

java - Spring @PropertySource set path dynamically -

i developing core java application using spring core.and application work executable jar. this application has configuration file load using @propertysource , path set "class-path:". i install executable jar on different different machine. executable jar folder path different. i need put projectconfig.properties outside jar file user can able set configuration per requirement. how can this? how can set path dynamically? import org.springframework.beans.factory.annotation.autowired; import org.springframework.context.annotation.propertysource; import org.springframework.core.env.environment; import org.springframework.stereotype.component; @component @propertysource("classpath:com/org/abc/xyz/properties/projectconfig.properties") public class projectconfig { @autowired private environment env; public string getproperty(string propname) { return env.getproperty(propname); } } enter image description here thank in advance! i suggest

twitter - Error in DirSource("TheRock") : empty directory -

i tried analyze twitter data on rock (#therock) using tutorial : https://www.slideshare.net/ajayohri/twitter-analysis-by-kaify-rais however, when execute code below error : "error in dirsource("therocknew") : empty directory" library(tm) library(wordcloud) therocknew="c:/users/admin/desktop/therock" k=corpus(dirsource("therocknew"), readercontrol = list(language = "eng")) inspect(k) i've been looking solution online, can't seem find answer. tried changing directory folder "documents" (standard) desktop, changing code dirsource(directory = "therocknew") etc. nothing seems work.

javascript - JQuery Button to Show and Button to Hide -

i have list of button table (table1) if clicked button, append table (table2), , button hide. @ table2, there's button remove/delete table2 , button @ table1 displayed again. here's code far: var rownum = 0; $('.addrow').on('click', function () { rownum++; var barang = $(this).parent().find("input[name='rfdn']").val(); var barangid = $(this).parent().find("input[name='rfdid']").val(); var price = $(this).parent().find("input[name='rfdp']").val(); var harga = $(this).parent().find("input[name='rfdpx']").val(); var qty = $(this).parent().find("input[name='rfdq']").val(); var row = '<tr id="rownum' + rownum + '">'; row += '<td class="left"><input type="hidden" name="pitem[]" value="' + barangid + '" /&