Posts

Showing posts from August, 2012

hibernate - HQL : Order by varchar2 as INT -

i'm working on statement in hql , have results sorted numbers. kind of results can have : dr71 frein resf-37 r-37 ... i have sorted numbers composed of. i had : select distinct r.type reference r order replace(replace(replace(r.type, '-', ''), 'f', ''), ' ', '') it enough because @ beginning, r, - , f used. have solution supporting every characters. i tried : order cast(r.type int) but gives sql error: 1722, sqlstate: 42000 any idea how ?

ruby on rails - Turbolinks not rendering code on page change -

i'm using segment.io tracking on site. have live chat widget i'd displayed on every page. i'm unable figure out how make work. i've created analytics.js loads in body (i've tried adding analytics.page(); body without results): window.analytics = window.analytics || []; window.analytics.methods = ['identify', 'group', 'track', 'page', 'pageview', 'alias', 'ready', 'on', 'once', 'off', 'tracklink', 'trackform', 'trackclick', 'tracksubmit']; window.analytics.factory = function(method){ return function(){ var args = array.prototype.slice.call(arguments); args.unshift(method); window.analytics.push(args); return window.analytics; }; }; (var = 0; < window.analytics.methods.length; i++) { var key = window.analytics.methods[i]; window.analytics[key] = window.analytics.factory(key); } win

I have tried to make code for inbuild javascript function (touppercase).Does this helpfull or not? -

this code use inbuilt fuction of javascript touppercase shortformat benificial interview .sometimes need not use inbuilt functions ..so there code them. //change lower case upper case function change_upper_case() { var a1 = [], a6 = [], = 0; // define variables a1 = document.getelementbyid('enterstring').value; //get value enter while(i < a1.length) { //check condition true or false var a2 = a1[i]; var a3 = a2.charcodeat(0); //get ascii value of char in number format var a5 = a2; if(a3 >= 97 && a3 < 123) { // = 97 , z=122 var a4 = a3-32; a5 = string.fromcharcode(a4); //change ascii value of a4 in char format } a6[i] = a5; i++; } document.getelementbyid('showstring').innerhtml = a6.join(''); //print input string on browser } //change lower case upper case function change_upper_case() { var a1 = [], a6 = [], = 0; // define variables

angularjs - how to design a state with ui-router that replaces the content only of index.html with two files and two controllers -

how design state ui-router replaces content of index.html 2 files , 2 controllers. have views/dishdetail.html & views/comment.html , i`m trying this: .state('app.dishdetail',{ url: 'menu/:id', views: { 'content@' : { 'discomment': { templateurl : 'views/dishdetail.html', controller : 'dishdetailcontroller' }, 'mycomment': { templateurl : 'views/comment.html', controller : 'dishcommentcontroller' } } } }); please help this should way .state('app.dishdetail', { url: 'menu/:id', views: { 'content@': { template: '<div ui-view="discomment" /></div>' + '<div ui-view="mycomment&qu

javascript - App API design advice specifically around security -

i'm building app , feedback on approach building data sync process , api supports it. context, these guiding principles app/api: free: not want charge people @ use app/api. open source: source code both app , api available public use wish. decentralised: api service supports app can run on server, , made available use users of app. anonymous: user should not have sign service, or submit personal identifying information stored alongside data. secure: user's data should encrypted before being sent server, access server should have no ability read user's data. i implement instance of api on public server selected in app default. way initial users of app can sync data straight away without needing find or set instance of api service. on time, if app popular users set other instances of api service either or make available other users of app should wish use different instance (or if primary instance runs out of space, goes down, etc). may access api in own apps. es

How to style Android SearchView like in Google Play Store app? -

Image
i trying style searchview in toolbar / behave searchview in google play store app . seems wrap searchview in cardview seems integrate button / drawer toggle behavior. this main activity searchview, has integrated drawer toggle when click on it, drawer toggle changes arrow (that when clicked remove focus search view) when click on app in store, go app detail page , have looks iconified version of search view collapsed action item button: finally if click on search icon expands action item (with kind of ripple animation) , displays way across screen , incorporates button: when try myself have lot of problems. tried wrap searchview in cardview , put in toolbar. works there padding on left side can't remove (i tried contentinsetstart, doesn't work): <android.support.v7.widget.toolbar android:id="@+id/activitycatalogtoolbar" android:layout_width="match_parent" android:layout_height="?attr/actionbarsize" a

jsf - PrimeFaces ManyCheckbox ArrayList not Updating inside modal dialog -

this question has answer here: understanding primefaces process/update , jsf f:ajax execute/render attributes 3 answers i have modal dialog, user can select , deselect roles based on user , submit database updated. however, after debugging, arraylist backs manycheckbox doesn't updated, , selectedroles arraylist remains was. for example: i load application there 1 user in database role 'admin' i try edit user , dialog opens up, 'admin' checkbox selected. i click 'user' role checkbox , click submit the selectedroles array still 'admin' instead of 'admin' , 'user' here dialog modal: <p:dialog header="editing user id: #{usersview.viewuser}" id="edituserdialog" widgetvar="edituserdialog" modal="true" appendto="@(body)"> <h:form id="ed

PHP exception naming and error codes best practices? -

what's piece of advice on exception naming these days ? standard (java-style, old?) convention keep them @ root of namespace exception suffix: example\project\configurationexception symfony splits them purpose/components ( source ): example\project\user\banneduserexception example\project\graphs\notenoughdataexception facebook store them , keep exception suffix classes: facebook\exceptions\facebooksdkexception.php ( source ) braintree keep exceptions inside exception folder: braintree\exception\notfound ( source ) stripe has ditched entirely word exception in sdk , keep them inside same folder: stripe\error\invalidrequest . ( source ) there seems as ways there's developers out there... there written convention or what's trend out there used of ? also, set error code part of exceptions ? if so, how manage code ? i've got bunch of constants in example\project\errors , braintree does .

angularjs - Angular 1.5 unit test controller that requires parent component's controller -

i'm trying unit test (child) controller of angularjs 1.5 (with webpack) component requires parent component , controller module. child controller structure: function childcontroller () { var vm = this; vm.searchtext = ''; vm.submit = function() { var data = {}; data['srch'] = vm.searchtext; vm.parentctrl.submittextsearch(data); }; } module.exports = childcontroller; child component: var template = require('./child.html'); var controller = require('./child.controller'); var childcomponent = { require: { parentctrl: '^parent' }, template: template, controller: controller, controlleras: 'vm' }; module.exports = childcomponent; so mock out parentctrl that's required in childcontroller's submit()-function. i've been unable find how this. i've found similar child-parent directive solutions , tried those, e.g. injecting parent controller through fake html-element described

python - Number of rows into a HDF5 -

there's method have number of rows of .hdf5 without load in ram ? i'm using python 3.4 pydev on liclipse (windows 10) thanky if use h5py library, can run len(dataset) or dataset.len() (which recommended). see here more infos.

unity3d - Unity: Spawn element on accurate position over time -

i wish spawn enemies moving on same speed @ specific position repeating every x milliseconds. the problem update() function in unity occurs in non deterministic time, cannot spawn in accurate position, , delays , inaccurate positions of elements. how can solve this? coroutines useful trigger methods periodically. you can check this unity forum post see how works. ienumerator spawndelay() { spawn(); //your spawn method yield return new waitforseconds(5); startcoroutine("spawndelay"); //restarting coroutine after 5 sec delay }

windows - Multi select drop down list in UWP -

i want multi select drop down list mvvm cross uwp app. there predefined control? or need implement custom control achieve this. any or suggestions appreciated. thank you there no built-in multi-select combobox in uwp, can build own - issue multiselect combobox control in windows 8 . basically can add checkboxes each item in combobox , create logic gather selected items , provide bindable way access them. to make simpler, can create special class have ischecked property , add checkbox two-way binding property. ensure checking of box in ui reflected in class , can enumerate items find have ischecked set true .

dependencies - What are the preferred steps to avoid Dependency Hell in Java? -

recently in pretty trouble dependency hell problem in java. there proper set of procedures avoid in future? first, use dependency manager maven or gradle. no lib folder contains third party jars, no copying classes or *.java files other project yours. sorry if obvious saw lot of projects built using such technique. the next phase optimization of dependencies. can use library , b both use library c. fine if both use library c of same version. hell starts if depend on different versions of library c. in cases not cause problem , can not aware on fact. may cause problems. avoid i'd recommend time time check dependency tree of project, find duplicates , if exist use exclude instruction of dependency manager exclude older version. this can fail because, of incompatibility of these versions of library. in case there no general way solve problem. have downgrade 1 (or several) of dependencies in order make them work , wait newer version uses newer version of library c (i

devexpress - Combo Box Column binded to Enum -

how define combo column in gridview bind enum (as possibilities), has default value coming object coming list bind grid view? the problem coming bindlist display different options in combo should list of string... kind of: 'none', 'true', 'false', 'maybe'... and default value coming object.field1 coming of list binded grid view. get it!! settings.columns.add(column => { column.fieldname = "field_name"; column.editorproperties().combobox(p => { p.datasource = enum.getnames(typeof(definition_of_enum)); }); }); by deveexpress support...

javascript - How to two-way bind select element with prop in React -

whats approved way create select element in react, 2 way bound prop of selection containing component? default selection should present attribute of prop (may generated, because value arbitrary, , on selection prop attribute should reflect selection. also, should possible write value directly selection field. there isn't "approved" way such, should note couple of things: the change event triggered on element, not element. controlled , uncontrolled components defaultvalue set differently . this generic example of controlled dropdown menu var mydropdown = react.createclass({ getinitialstate: function() { return { value: 'select' } }, change: function(event){ this.setstate({value: event.target.value}); }, render: function(){ return( <div> <select id="fruit" onchange={this.change} value={this.state.value}>

scala - Akka: How to wrap a message content into an HTTP response? -

in akka-http route specific message , want wrap content error message like: val response:future[t] = (actor ? command).mapto[t] response match { case err : future[invalidrequest] => httpresponse(408, entity = err.map(_.tojson).????) case r : future[t] => r.map(_.tojson) } case class invalidrequest(error:string) implicit val invalidrequestformat = jsonformat1(invalidrequest) but doesn't work. how can map text in json format? i think can provide generic solution trying do. can start creating method returns route follows: def service[t:classtag](actor:actorref, command:any) (implicit timeout:timeout, _marshaller: toresponsemarshaller[t]):route = { val fut = (actor ? command).mapto[serviceresponse] oncomplete(fut){ case util.success(ir:invalidrequest) => complete(statuscodes.badrequest, ir) case util.success(t:t) => complete(t) case util.failure(ex) => complete(statuscodes.interna

python 2.7 - Whats means the : operator in str.format()? -

take {:.2f}.format(x) example. gives me output fixed-point number precision 2 output. : means? have question: why upper function doesn't work when give input x = 7.5643915285818e+210+4.6951592215e+280j ? colon (:) used instead of % in formatting. refer link

c# - MS Office 2013 Addon Click Once, change install directory -

i use click once deploy office 2013 addon, written in .net 4.5.1 works fine , addon installed here; c:\users[user]\appdata\local\apps\2.0.... but need change destination path of installation to: c:\users[user]\appdata\roaming... thing how can that, or not possible? thanks you can try copying installation folder want in update click once setup.exe there. from command line navigate installer folder then: setup.exe /url="c:\users[user]\appdata\roaming\" if want change installer installs every time not possible see: https://social.msdn.microsoft.com/forums/en-us/5c7d00c2-2473-4fd5-b815-30066383eb47/change-installation-folder-for-a-click-once-app?forum=winformssetup

java - Spring websocket connection not being established -

i followed this tutorial build spring websocket application. i've kept each file i'm neither using maven nor gradle. run index.html file on tomcat server. when click connect get: opening web socket... http://localhost:8080/hello/info 404 (not found) whoops! lost connection undefined in chrome's developer window. why happening? link may help. here have given whole example. for require stomp.js, sockjs on client side , spring-websocket & spring-messaging 4.2.6.release jar in server side,

ruby on rails - ActiveRecord insert return PG::DatetimeFieldOverflow error -

i searched on , find answer error issue little different. have error: pg::datetimefieldoverflow: error: date/time field value out of range: "24/05/2016 17:00" hint: perhaps need different "datestyle" setting. if @ logs pry(#<webexsync::sync>)> attributes => {:webex_external_id=>1025, :user_id=>2565, :lesson_times=>[2016-05-24 17:00:00 +0200], :status=>"invited"} pry(#<webexsync::sync>)> userwebex.create! attributes user load (1.4ms) select "users".* "users" "users"."id" = $1 limit 1 [["id", 2565]] webex load (0.6ms) select "webexes".* "webexes" "webexes"."external_id" = $1 order "webexes"."start_date" desc limit 1 [["external_id", 1025]] userwebex exists (0.5ms) select 1 one "user_webexes" ("user_webexes"."user_id" = 2565 , "user_webexe

sql - Can't compare XXXX-XXXX integer format to text -

i have database have not created. in table tablea, there field fielda defined "long integer", , of values have format "0000-0000" (with other numbers different 0). i have created table field fieldb, same kind of data of fielda tablea. need compare fieldb , fielda (where fielda = fieldb), can't. i can't define fieldb "long integer" because can't input values "0000-0000". don't understand how guy created database managed in fielda. if define "short text" , try "where fielda = fieldb", type mismatch error. if define "short text" , try "where cstr(fielda) = fieldb" or "where str(fielda) = fieldb" no rows returned. not blank row, looks error. i can't modify tablea change type of fielda string due irrelevant reasons. any highly appreciated. thanks create fieldb long , assign format: 0000-0000 you can enter, say, 75522 , displayed as: 0007-5522

junit - How can i run a a unit Test in Apache Camel -

i want know comand line in maven run unit tests apache camel. please? regard you can use normal maven test commands mvn clean test if have run specific unit test have use mvn -dtest= testclass # testmethod test where testclass junit test class , testmethod actual method run . more camel testing can accessed here.. http://camel.apache.org/spring-testing.html

sockets - Android bluetooth connection cannot be established on the first try -

i'm trying connect bluetooth device in android application have problem. seems i'm never able connect bluetooth device on first try. i have following code in bluetoothconnectthread: public class bluetoothconnectthread extends thread { private bluetoothsocket mmsocket; private bluetoothdevice mmdevice; private context context; private bluetoothmanager manager; public bluetoothconnectthread(bluetoothdevice mmdevice, uuid uuid, context context, bluetoothmanager manager) { this.context = context; this.manager = manager; this.mmdevice = mmdevice; this.uuid = uuid; } public void run() { try { system.out.println("try connect"); mmsocket = (bluetoothsocket) mmdevice.getclass().getmethod("createrfcommsocket", new class[]{int.class}).invoke(mmdevice, integer.valueof(1)); mmsocket.connect(); } catch (exception connectexception) { connect

php - Get both insert_id and updated row id in insert_update query -

i have query this: set @uids = ''; insert tbl1 (name,used,is_active) values (1,0,0),(2,0,0),(24,0,0) on duplicate key update id = last_insert_id(id) , used = (select @uids := concat_ws(',', last_insert_id(), @uids)) , used = used+1 , is_active = case when used > 3 1 else 0 end; select @uids; see here figure out way of getting updated row id. i updated row ids' in @uids if updates rows if row inserted, can't id of that. how both inserted row id , updated row id? or how execute (select @uids := concat_ws(',', last_insert_id(), @uids)) in insert before on duplicate key... ? time's short , long you can't it, because there no way fill @uids while inserting needs select clause , not allowed use select clause within insert statement unless query can transformed insert ... select . long answer as long don't try insert mixed values may result in both updating , inserting ( which do ) there nast

java - Navigation drawer use at another activity only, not in main activity -

i have project containing different activities like: main activity, signup activity, login activity , track activity. want create activity contain navigation drawer. , point "i don't want use navigation drawer @ other activity". all example far found @ searching @ net provide example using main activity. don't want use navigation bar @ main activity. if using android studio, follow these steps, 1. right click on app. 2. new -> activity -> navigationdraweractivity this way new activity have navigation drawer.

github - Git cloning stucks on receiving objects -

when i'm cloning git repository stucks on receiving objects receiving objects: 13% (126/963), 22.08 mib | 7.03 mib/s with command 'git clone https://github.com/hadevs/gitpolichat.git --verbose' cloning 'gitpolichat'... post git-upload-pack (155 bytes) remote: counting objects: 963, done. remote: compressing objects: 100% (569/569), done. receiving objects: 8% (78/963), 2.55 mib | 2.45 mib/s also it's in github desktop thank help

c# - Multiple Combo Boxes with shared Binding - Display error after first selection from box -

i've been stumped on issue i've run across in last few days , figuring out. i'm developing wpf application on first run prompt user manually assign detected serial ports arbitrary 'channels', used throughout application , later interface displaying data etc. one of key features once port has been assigned in combo box, no longer available selection in others (using .isenabled property of comboboxitem class). the issue i've run while works fine - each combo box set, opening next sees previous selection greyed out - if attempt go combo box i've set displays empty drop down . looks if drop-down still active window contains items hasn't been sized properly. screen captures: items disabled in subsequent combo boxes returning selected box results in blank drop down (blue circle) here's xaml code combo boxes: <stackpanel grid.column="1" name="combopanel" margin="5, 20, 5, 5"> <combobox m

javascript - How can i get form input values by id in meteor -

i new in meteor framework. practice in local server. have added data meteor want edit data. have tried edit data unable values. below code. <head> <title>login page</title> </head> <body> {{> facebooktest}} {{> usersdetails}} </body> <template name="usersdetails"> <table class="userdetailstable"> <tr> <th>#id</th> <th>email address</th> <th>name</th> <th>username</th> <th>password</th> <th>created</th> <th>edit</th> <th>delete</th> </tr> {{#each returnregistrationdata}} <tr> <td>{{_id}}</td> <td>{{email}}</td> <td>{{name}}</td> <td>{{username}}</td> <td>{{created}}</td> <td>{{password}}</td> <

clojure - Can't build a jar using Leiningen -

i'm trying make stand alone jar bare-bones clojure project using leiningen plugin in intellij's cursive. to create project, created project.clj file, opened it, , cursive offered import project. project.clj: (defproject watertimer "1" :description "a timer reminds drink water" :main tone-producer/main) tone-producer.clj: (ns tone-producer (:require [general-helpers :as g]) (:import [javax.sound.midi midisystem synthesizer midichannel]) (:gen-class)) (defn main [& args] (println "test!")) when run "uberjar" task, following output: warning: specified :main without including in :aot. implicit aot of :main removed in leiningen 3.0.0. if need aot uberjar, consider adding :aot :all :uberjar profile instead. warning: main-class specified not exist within jar. may not executable expected. gen-class directive may missing in namespace contains

javascript - Angularjs with Material design md-menu-item multi-column -

i have created menu per demo of angularjs material. in demo menu is dynamic. have created menu manually. , every thing working fine. i wanted know that, possible make menu in multi-column rather make single drop-down. some of code <md-toolbar> <div class="md-toolbar-tools"> <md-menu md-position-mode="target-left bottom" md-offset="-22 6"> <md-button aria-label="plan & book" ng-click="$mdopenmenu($event)"> parent item 1 </md-button> <md-menu-content width="4"> <md-menu-item> <md-button>item 1</md-button> </md-menu-item> <md-menu-item> <md-

Excel vba speed optimization for importing data from excel to excel table -

having trouble speed of vba script importing data excel table. hoping here can help. comments in code state script takes 8 seconds import 100 rows of data. love bring down fractions of second. sub importmydata() dim filter, caption, importfilename string dim importwb workbook dim targetsh, validationsh worksheet dim targettb listobject dim importrg, targetrg, validationrg range dim i, j, k, targetstartrow integer ' set speed related application settings (this restored on exit) application .screenupdating = false .calculation = xlcalculationmanual .displaystatusbar = false .enableevents = false end ' set definitions set targetsh = thisworkbook.sheets("mytargetsheet") set targettb = targetsh.listobjects("mytargettable") set targetrg = targettb.databodyrange set validationsh = thisworkbook.sheets("myvalidationsheet") set validationrg = validationsh.rang

google adwords api php library -

i have setup account mcc account , executed examples reporting code campaign performance report 1 of customerclient id. this code: <?php // include initialization file require_once __dir__ . '/examples/adwords/auth/init.php'; require_once __dir__. '/src/google/api/ads/adwords/util/v201601/reportutils.php'; function downloadcriteriareportwithawqlexample(adwordsuser $user, $filepath, $reportformat) { // optional: set clientcustomerid reports of child accounts $user->setclientcustomerid('731-721-7585'); // prepare date range last week. instead can use 'last_7_days'. // $daterange = 'all_time'; // create report query. $reportquery = 'select campaignname, impressions, clicks, ctr, averagecpc, ' . 'cost, date,conversions,conversionrate, costperconversion,campaignstatus campaign_performance_report ' . 'where campaignstatus = enabled during this_month'; // set additional options.

c# - Console Window doesn't appear after re-opening project in Visual Studio -

i wrote program in c# convert binary string other digital number systems , int , worked fine , saved , closed it. when reopen it, exception: $exception {"cannot read keys when either application not have console or when console input has been redirected file. try console.read."} system.invalidoperationexception this because have console.readkey(); @ end of program. when remove this, console window doesn't appear @ , process ends though program asks user input. here program reference: > using system; using system.collections.generic; using system.linq; > using system.text; using system.threading.tasks; > > namespace test { > class program > { > static void main(string[] args) > { > int arr_length = 16; > string c_array = "\0"; > int[] array = new int[arr_length]; > console.writeline("input 2 byte string:"); > (int = 0;

matlab - Circle Detection Image Processing boolean output -

Image
i working on implementing hough transform circle detection in image in camera preview. image going follows after thresholding. i introduced hough transform , using following code. [rows,columns] = size(circle); acc = zeros(rows,columns); r=9; x=1:columns y=1:rows if(circle(y,x)==0) ang=0:360 t=(ang*pi)/180; x0=round(x-r*cos(t)); y0=round(y-r*sin(t)); if(x0<columns && x0>0 && y0<rows && y0>0) acc(y0,x0)=acc(y0,x0)+1; end end end end end how use accumulator return boolean value(e.g true if there circle else false). please let me know if there simpler ways can using hough transform. thank you. there matlab function problem use http://de.mathworks.com/help/images/ref/imfindcircles.html or want write hough-transform yourself?

How to create MySQL trigger -

i have table users 2 fields id (numeric) , email (with full email adress) how add trigger can prevent adding new email records specific domains eg: *@somedomain.com ? the trigger this: delimiter $$ create trigger user_insert before insert on user each row begin if new.email '%@somedomain.com' signal sqlstate '99999' set message_text = 'invalid domain'; end if; end$$ delimiter ;

Excel custom sorting -

Image
for past 2 hours i've been trying figure out how sort list of chinese vocabulary. i've thing i've tried doesn't seem work, i've read different kinds of forum posts, , watch whole bunch of videos on it, nothing works. the spreadsheet this: cell word, cell b pronunciation, cell c definition. need sort cell different list of words while still keeping cells b , c. when try doing this, ignores custom list , looks @ first character in each word , sorts that. here screenshot showing layout: does have idea doing wrong? has been driving me crazy trying figure out, , need fixed.

html - How to load static files in python django -

i have tried modify in settings.py file allow loading css files of html code still doesn't appear style, run in terminal command "python manage.py collectstatic" , says files copied still doesn't appear effect. here modified lines in settings.py file static_root = '/static/' staticfiles_dirs = [ os.path.join(base_dir, "static"), ] static_url = '/static/' in settings.py provide: staticfiles_finders = [ 'django.contrib.staticfiles.finders.filesystemfinder', 'django.contrib.staticfiles.finders.appdirectoriesfinder', ] base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) staticfiles_dirs = (os.path.join(base_dir, 'static_files'), ) static_root = os.path.join(base_dir, 'static', ) static_url = 'http://example.com/static/' so if static files finders defined , static_files declared source static files, whatever place in /your_root/stati

angularjs - Angular translate static files loader with html-backend -

i have json traslations page gets loaded static files loader works fine, when use $httpbackend simulate api calls doesnt load. config looks this: $translateprovider.usestaticfilesloader({ prefix: "assets/lang-", suffix: ".json" });*/ $translateprovider.useinterpolation('textbreaksinterpolation'); $translateprovider.preferredlanguage('en'); i have whitelisted assets in htmlbackend this: $httpbackend.whenget(/assets.*/).respond(200, ''); any suggestions? thanks. i suggest not use lazy loading @ all. (of course, if don't have many languages). just build text json file bundle: import textsen 'texts.en.json'; import textsde 'texts.de.json'; import textses 'texts.es.json'; .config($translateprovider => { $translateprovider.translations('en', textsen); $translateprovider.translations('de', textsde); $translateprovider.translations('es&#

Prolog term_expansion not working -

i trying perform following term_expansion swipl: a(asda). a(astronaut). term_expansion(a(x),b(x)). but not work, i.e. there no b/1 consulted. have tried few variations: term_expansion(a(x),[b(x)]). user:term_expansion(a(x),b(x)). user:term_expansion(a(x),[b(x)]). user:term_expansion(user:a(x),[user:b(x)]). none of works. problem? as explained @mat, need define term_expansion/2 predicate before clauses want expand loaded. also, term_expansion/2 predicate multifile , dynamic predicate defined user pseudo-module. thus, should write: :- multifile user:term_expansion/2. :- dynamic user:term_expansion/2. user:term_expansion(a(x), b(x)). this ensure expansion code work if move module. if portability other prolog systems term-expansion mechanism (which, btw, far standard), consider moving term-expansion code own file, loaded before source files want expand.

Logout from Facebook Programatically iOS -

i know question has been asked on lot of pages, unfortunately non of them worked me!! problem facebook use safari when logged in, when try logout app keep credentials , cookies of safari. in other words, way logout correctly open safari , logout facebook. question is, there work around way? fbsdkloginmanager *loginmanager = [fbsdkloginmanager new]; [loginmanager logout]; i tried [fbsdkaccesstoken setcurrentaccesstoken:nil]; [fbsdkprofile setcurrentprofile:nil]; although being called inside logout method :( finally tried removing cookies nshttpcookiestorage* cookies = [nshttpcookiestorage sharedhttpcookiestorage]; nsarray* facebookcookies = [cookies cookiesforurl: [nsurl urlwithstring:@"http://login.facebook.com"]]; (nshttpcookie* cookie in facebookcookies) { [cookies deletecookie:cookie]; } no luck @ !!!!

json - REST - best practice for returning constants/enums and handling it by JavaScript -

i developing web app, partially based on ajax calls. specifics not important here. 1 of entities uses constant ints status , need information in front end show string , conditionally show buttons/info. const status_ordered = 1; const status_will_be_returned = 2; const status_received = 3; const status_delayed = 4; const status_archived = 5; i have several ideas how include data in json response , how handle in javascript. looking best way this. ideas: send status string (converted using swich or associative table) - approach make easier show status, including in logic involve string comparison send int , convert string on front end site - logic, string has generated somwhere anyway (this seems suitable approach me) send int translation table - works nice if string value needed, makes front more independent, not change here, cause need check status on front end site anyway

Python-2.7: No SIGINT possible in while loop with locks -

i implemented while loop locks in python-2.7 (see example) handle 2 lists loaded values other thread each. code works, not handle sigint (ctrl-c) anymore. example: while true: lock1: if 0 < len(data_buf1): foo(data_buf1.pop(0)) lock2: if 0 < len(data_buf2): bar(data_buf2.pop(0) what enable keyboard commands again? update loop runs in main python process.

dataframe - How to create a similar data frame in R that is empty? -

i new r , need help. please me out in... how create data frame (say mydata2) in r similar existing data frame (say mydata1 5 columns), blank. is, new data frame has 5 columns in mydata1 has no data in rows. i want output have "0 obs. of 5 variables". here, assuming column names , `data types. however, can change according requirements mydata2<- data.frame(x= character(0), y= numeric(0), = character(0), b= integer(0), c = numeric(0)) mydata2 # [1] x y b c # <0 rows> (or 0-length row.names) str(mydata2) # 'data.frame': 0 obs. of 5 variables: # $ x: factor w/ 0 levels: # $ y: num # $ a: factor w/ 0 levels: # $ b: int # $ c: num dim(mydata2) # [1] 0 5 class(mydata2) # [1] "data.frame"

To develop a testing tool -

now, trying develop testing tool, can make unit testing. mean want use junit in testing tool test other projects. don't know how insert junit testing tool. possible , how? , there other open-source testing tool can inserted testing tool? to use junit api make sure got jar in classpath to use junit tests need testing class extend systemtestcase4 , function have @test annotation above if want code run before test use function @before , if want after use function @after public class basetest extends systemtestcase4 { @before public void beforeeachtest() throws exception { } @test @testproperties(name = "test test ") public void testtest() throws exception { //run tested code } @after public void aftereachtest() throws exception { } as how test projects depend tests want do? unit testing add own tests inside projects integration, functional or other tests need understand how "attack" it, meaning if it's ui tests web use tools (seleni

ant - Get XML property when there is more than one property that matches -

i have xml file this: <vrmlist> <vrm version="4" product="prod1" platform="windows"/> <vrm version="1" product="prod1" platform="web"/> <vrm version="6" product="prod2" platform="windows"/> </vrmlist> the file used other purposes changing it's structure difficult. access version each item independently using <xmlproperty> task. example <xmlproperty file="test.xml"/> <target name="test"> <echo>version: ${vrmlist.vrm(version)}</echo> </target> results in test: [echo] version: 4,1,6 what want able access properties each <vrm> independently given product , platform can use in build file. example of want (does not work): <echo>${vrmlist.vrm[@product="prod1" , @platform="windows"](version)}</echo> test: [echo] version: 4 is p