Posts

Showing posts from July, 2011

User running a scheduled job in Rundeck -

is there way force scheduled job runs performed user, instead of user enabled scheduling? thanks edit: sorry, maybe didn't explain myself properly. meant rundeck user, not node user, defined in realm.properties file. let's have 2 users defined: user1 , user2. user1 logs rundeck , starts job. in recent executions list job appear performed "by user1". user1 edits job , enables "schedule run repeatedly" option. when job starts on schedule reported ran "by user1". what need way tell rundeck jobs have "schedule run repeatedly" enabled should run user (such user2) instead of user edited them , enabled scheduling (user1). why want this? 2 reasons: 1. cleanliness: want automated jobs listed ran "rundeck service" user. 2. issues ldap , acls: our rundeck users imported ldap , rundeck acls set ldap groups. when job run on schedule rundeck not call ldap server retrieve group list, user treated having no group , consequen

php - Foreach overwrites previous records in multidimensional array -

Image
i have multidimensional array, , want show array in tabular form like +------+-----+--------+-------+-------+ | name | red | yellow | green | white | +------+-----+--------+-------+-------+ | abc | 8 | 2 | 4 | 0 | | xyz | 2 | 8 | 0 | 0 | +------+-----+--------+-------+-------+ the following array i've [0] => array( 'label'=> 'red', [value] => array ( [0] => array ( [count] => 47 [firstname] => syst ) [1] => array ( [count] => 2 [firstname] => xyz ) [2] => array ( [count] => 8 [firstname] => abc ) ) [1] => array( 'label'=> 'yellow', [value] =>

sql server - T-SQL concatenate & convert string to date time -

Image
i have table (once again implemented bio-metric software) stores date , time strings in different columns. date column stores date 20160128 january 18 2016 , time column stores time 220747 ( 10:07:47 pm ). how can concatenate both strings , convert valid datetime value? i have referred few of other questions asked here , found many of them refers date part, missing time factor if can manipulate strings format sql server can natively parse, can cast - e.g. yyyymmdd hh:mm:ss format: declare @date char(8) set @date = '20160128' declare @time char(6) set @time = '220747' select cast(@date + ' ' + substring(@time, 1, 2) + ':' + substring(@time, 3, 2) + ':' + substring(@time, 5, 2) datetime)

python - Python3 Gtk3+: How to hide a cell of a row -

i have searched whole internet this, found nothing helpful. beginning think impossible do, must have had requirement of type. my app: i use treestore list parents (folders) , childs (files); minimizing column list, have name, path (hidden column), size (relevant childs - easy masked parent since of type str()), progress bar (i want displayed - showed in treeview childs, not parents). why need functionality: i want application show progress bar each file treestore have defined; being treestore, files have parent (folder); i don't want display progress bar folder, since useless point of view , bad. i have researched options/functions available couldn't find 1 specific cell specific row. the functions have found come close need (but still unusable) are: gtk.cellrenderer.set_visible(cellrendererprogress, false) - makes whole cellrenderer invisible; gtk.treeviewcolumn.set_visible(false) - makes whole column invisible; setting "none"

ruby - Correct way to add a comments to existing view rails -

i have rails application wih scaffold displays images via controllers show action. want add comments every picture. right way this? tried making second controller+model+view, rendered comments form partial in images show view , passed image id via parameter. works, don't think how it's supposed done. if know example project implements aomething please send me, couldn't find anything. thank help. this typically handled nested resources : #config/routes.rb resources :images #-> url.com/images/:id resources :comments, only: [:create, :update, :destroy] #-> url.com/images/:image_id/comments end #app/controllers/images_controller.rb class imagescontroller < applicationcontroller def show @image = image.find params[:id] @comment = @image.comments.new end end #app/controllers/comments_controller.rb class commentscontroller < applicationcontroller def create @image = image.find params[:image_id] @comment = @image.com

javascript - How to call correctly this function in Ajax? -

i have code: function changeeventstatusclass(object){ if ($(object).hasclass("fa-circle")) { $(object).removeclass("fa-circle").addclass("fa-circle-o"); //alert("adevarat"); } else { $(object).removeclass("fa-circle-o").addclass("fa-circle"); } } function changeeventstatus(eventid, status) { console.log(eventid, status); $.ajax({ type:'post', data: { eventid: eventid, status: status, }, url: "<?php echo $this->serverurl().str_replace('public','',$this->basepath()).'/user/ajaxupdateappointmentstatus'; ?>", success: function (result) { if (result.success) { console.log(eventid); changeeventstatusclass(eventid); //here problem } } }); } $(".crad").on('click', function(){ var

excel - Auto filling formula VBA -

Image
looking vba function i have data on 2 sheets need perform index match on. the data size vary every time compare run. i have coded vba call data , populate both sheets running comparison causing problem. i have created below function, running without error not populating formula in cell starting j2 end of j range. sub formulafill() dim strformulas(1 1) variant thisworkbook.sheets("export worksheet") strformulas(1) = "=index('sheet1'!e:e,match('export worksheet'!a2,'sheet1'!a:a,0))" .range("j:j").filldown end end sub any appreciated. w image after updated code applied you writing formula array variable, not cell, tried fill entire column using j:j . means trying fill entire column contents of cell j1 , top cell, not j2 . here code corrections. sub formulafill() thisworkbook.sheets("export worksheet") .cells(2, 10).formula = "=index('sheet1'!e:e,match(&#

sql - Sum of time differences of unknown number of rows in mysql -

i need sum of times difference of unknown number of date rows. can sum of list using, select sec_to_time(sum(time(o.discontinued_date))) . but need sum of time differences. example, 2014-09-24 01:17:28 2014-09-24 01:17:41 2014-09-24 01:17:48 answer list should 00:00:20 but in case not know number of rows. not know should sum of differences. please help. sorry english. if need more details please comment. thank you if understood correctly.. doesn't matter whether have 2 rows or 20, since intrested in smallest , biggest time. so query should simple: select max(discontinued_date) - min(discontinued_date) yourtable; in case want each id/day or dont know, should use group this:(i.e. sum per day) select discontinued_date,max(discontinued_date) - min(discontinued_date) yourtable group discontinued_date;

java - What is the best way to share variables between a large number of classes? -

i'm using java complicated calculations, , have lot of classes need access lot of same variables. these variables set @ different stages of calculations, in different classes. problem code getting quite messy being forced pass same parameters lot of different methods. i looking peoples thoughts on best approach here be? 1 idea have make superclass these variables set in , extend class everywhere needed. another option pass object holding information around method method seems overly complex. neither of these solutions feel cleanest approach me. thoughts or suggestions of design patterns/ideas may me appreciated. help. i'm going suggest using wrapper object best way this. make sure fields immutable ( final keyword in java). use builder or prototype pattern create new objects return.

html - Table is using more than 100% width of its parent element, how can this be fixed by CSS only? -

Image
i have root div using 100% width , want children not overlap ( overflow:hidden ) , not use more width 100%. this works fine when work inner <div> s, if <table> s used, table gets wide, using more parent 100% div . how can fixed while keeping table ? here jsfiddle . screenshot: you should give word-break: break-word; td text , because text large length, or can give td text word-break: break-all; breaking text. updated css code #wrapper table td{ word-break: break-word; } demo fiddle: https://jsfiddle.net/nikhilvkd/klt1mec8/3/

Can't create IBAction ctrl-dragging UIButton to ViewController (Xcode Version 7.2) -

Image
in middle of creating app, xcode quit allowing me ctrl-drag uibuttons vcs creating ibactions. happens on every vc (nine in all). allow creating outlets, though. (pls see image -> no action selection showing) xcode version 7.2 (7c68) build target ios9. is there way fix this? some things try: make sure using 1 of "sent events" create ibaction - not triggered segue (that describing) or other connection. try connecting not via ctr-drag, via right click menu or connections menu. try adding code: @ibaction func myaction() { } ... clear circle should appear, can connected via dragging button in ib. create touch inside event. finally, restart project , try again.

How to convert class with generic type to class with object as generic type in C# -

hello i'm using visual studio 2005 (because need compact framework support) , problem generics. i have created abstract class called abstractdao base from creating other classes documentdao,headerdao etc represent different tables on database what wish retrieve number of above mentioned dao classes, abstractdao (the abstract class has number of concrete implementations wish use) what tried abstractdao<object> dao = new documentdao(); abstractdao<object> dao = (abstractdao<object>)new documentdao(); abstractdao<t> dao = new documentdao(); i need above because have created function transfers data 1 table similar table in different database, (if worked) go this abstractdao<object> dao_local = new documentdao(local_database); abstractdao<object> dao_remote = new documentdao(remote_database); do_transfer(dao_local,dao_remote) void do_transfer(abstractdao<object> from, abstractdao<object> to) { list<object&g

c++ - Declare a vector in a function call and pass it by reference -

i'd declare vector way: myfunction(new std::vector<stuff>{}); with vector passed reference: void myfunction(const std::vector<stuff> &myvec); you don't need new argument (which in case returns pointer, not lvalue). can pass temporary: myfunction(std::vector<stuff>{}); a temporary can bind const lvalue reference.

Advantage of counting-semaphore -

can tell me counting semaphore? advantage of counting semaphore? can write snippet code counting semaphore in c. in cases have n available resources counting semaphore can keep track of number of remaining resources. when thread access 1 of semaphores counter of semaphore reduce 1 , when thread release semaphore counter increase one. if counter reaches 0 , thread ask resource thread blocked till thread release semaphore. known application of semaphore producer-consumer. can find description producer consumer problem here: https://en.wikipedia.org/wiki/producer%e2%80%93consumer_problem includes simple code looking for. also semaphores can initialized limit maximum number of resources controls. if limit 1 called binary semaphore has 2 states sema = 1 or sema = 0 binary , counting semaphores compared here: differnce between counting , binary semaphores

haskell - How to get/set session data in Yesod handler tests? -

is possible session data within yesod handler test? example i'd current userid. later on, i'd test 2 simultaneous browser sessions interacting yesod app in turns. getrequestcookies return session, in encrypted state.

android - How to handle Twitter and facebook request code -

how handle twitter , facebook request code on activityresult. @override protected void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); // if request code of facebook call other function , if // request code of twitter call other function // how can seprate both request code. } you have 2 options : 1) on click of fb or twitter button, set boolean value true , check button clicked determine method want call. @override protected void onactivityresult(int requestcode, int resultcode, intent data) { super.onactivityresult(requestcode, resultcode, data); if (fb_clicked == true) { //call callback manager's onactivityresult } else if(twitter_clicked == true) { //call twitter login button's onactivityresult } } 2) or can use auth token determine button clicked auth token generated when click on loginbutton (twitter or facebook , o

Sitecore Lucene Index Update Strategy: syncMaster -

i using syncmaster lucence index strategy (because want real time data) <strategies hint="list:addstrategy"> <strategy ref="contentsearch/indexupdatestrategies/syncmaster" /> </strategies> i using luke - lucene index toolbox view index documents.the question want ask is, when rebuild index my_country_index . , know there 6 country items in sitecore rebuild index. luke see 6 documents. for 1 of above item id ' {dea26cda-9ea9-4f67-bb3f-13caf6a68061} ' every update item see additional document added (i see like). in index have item old , new data. correct behavior syncmaster strategy. yes normal behaviour in sitecore if index related master database. on web database have 1 version every language of item. you can implement custom crawler overrides custom behaviour: public class customindexcrawler : databasecrawler { protected override void indexversion(item item, item latestversion, sitecore.search.indexupdatec

javascript - Add class to LI element depending on data-size attributes -

Image
i using gridster wordpress control arrangement of masonry style grid layout. gidster allows site admins reorder / resize posts in realtime (see screenshot) now rule use number of grid sizes (1x1, 1x2, 2x2). markup grid output following: 1x1: <li data-sizex="1" data-sizey="1" class="gs_w"> 1x2: <li data-sizex="1" data-sizey="2" class="gs_w"> 2x2: <li data-sizex="2" data-sizey="2" class="gs_w"> you can see grid size determined html 5 data attributes 'data-sizex' , 'data-sizey'. use jquery check these attributes on page load , add classes respectively.. for example element grid size of 1x1 (data-sizex="1" data-sizey="1") have class of '1x1' i believe need use attribute selector little unsure how proceed. $("li[data-sizex='1']") you can use each parse , data elements make class $('li

How to write a snabbdom loader in webpack.config.js -

i start work snabbdom technology. binder, use projects, webpack. when try run project on node.js (' npm run build '), shows me mistake: error in ./app/main.js module parse failed: d:\user\webworkspace\snabbdom\snabbwebpack\app\main.js line 3: unexpected token may need appropriate loader handle file type. | "use strict"; | | import snabbdom 'snabbdom'; | import counter './counter'; | are here know how write snabbdom loader in webpack.config.js file? it's not snabbdom , es2015 syntax. need babel-loader : npm install --save-dev babel-loader babel-core npm install babel-preset-es2015 --save-dev echo '{ "presets": ["es2015"] }' > .babelrc and in webpack.config.js : module: { loaders: [ { test: /\.js$/, exclude: /node_modules/, loader: "babel-loader"} ] }

java - How to avoid database auto clear when running Play Framework test? -

i want run serveral unit test , functional test on play framework app(play 1.4.0). test class like: public class statistictest extends unittest { @test public void testoutputstatistics() { //code } } and have data in database test class need read. play test clear data in database automatically. have import data via sql using fixtures.executesql() every time. lowers efficiency. want know how can avoid auto clear. in application.conf, set test.jpa.ddl "update" rather "create". %test.jpa.ddl=update

python - Find substring in pandas -

i have data, there words in rows. example: test string (test1) string test (string1) i need find substring in brackets using pandas. so, output here ['test1', 'string1'] i tried this, can't find word in brackets. df['column'].str.extract('([a-z]\w{0,})') you can use following regex pattern: in [180]: df['text'].str.extract(r'\((\w+)\)') out[180]: 0 nan 1 test1 2 string1 name: text, dtype: object so looks words present in brackets, here brackets need escaped \( example, want find words w+ needed here. if want list can call dropna , tolist : in [185]: df['text'].str.extract(r'\((\w+)\)').dropna().tolist() out[185]: ['test1', 'string1']

ssh keys - Can't get SSH ProxyCommand to work (ssh_exchange_identification: Connection closed by remote host) -

i'm unsuccessfully trying use ssh proxycommand connect server via jump box. config below, i'm running command: ssh 10.0.2.54 -f ssh.config -vv host x.x.x.x user ec2-user hostname x.x.x.x proxycommand none identityfile /users/me/.ssh/keys.pem batchmode yes passwordauthentication no host * serveraliveinterval 60 tcpkeepalive yes proxycommand ssh -w %h:%p -q ec2-user@x.x.x.x controlmaster auto controlpersist 8h user ec2-user identityfile /users/me/.ssh/keys.pem the result is: openssh_6.2p2, osslshim 0.9.8r 8 dec 2011 debug1: reading configuration data ssh.config debug1: ssh.config line 9: applying options * debug1: auto-mux: trying existing master debug1: control socket "/users/me/.ssh/mux-ec2-user@10.0.2.54:22" not exist debug2: ssh_connect: needpriv 0 debug1: executing proxy

noclassdeffounderror - Could not find class/NoClassDefFound error on Android running 4.3/ pre L -

i have android application seems run fine on android l+ devices. however, when try run pre l devices, seem exception on could not find class or noclassdeffounderror , these classes seem different project on project dependent upon. i tried java.lang.noclassdeffounderror on android devices kitkat , noclassdeffounderror in 4.4 kitkat not in 5.0 lollipop - not find class , recommended me disable multidex in build.gradle, did not find issue , started getting transformclasseswithdexfordebug errors listed @ unexpected top-level exception: com.android.dex.dexexception: multiple dex files define , recommended me turn multidex enabled. here sample stacktrace of errror: 01-28 17:09:21.214 15125-15125/<app> i/dalvikvm: not find method <xxx>, referenced method <yyy>.findzygotepid 01-28 17:09:21.190 15125-15125/<app> e/dalvikvm: not find class '<zzz>', referenced method <aaa>.broadcast 01-28 17:09:21.229 15125-15125/<aaa> e/androidru

jquery - making images smaller after mutiple selection of images using shift or control and click -

hi selecting multiple images present in div , trowing images in div using jquery ui sortable.when selecting multiple images.i want club or animated images single image effect using jquery.can 1 me.how in jquery..thanks. i have found beautiful drag , drop plugin using jquery... hope work you... thanks... http://dragsort.codeplex.com/

convert xlsx files to xls inside folders and subfolders in Excel VBA or Python -

i trying convert xlsx files xls using vba macro or python code.so far,i on converting files in single folder using below code: sub processfiles() dim filename, pathname, savefilename string dim wb workbook dim initialdisplayalerts boolean pathname = "" filename = dir(pathname & "*.xlsx") initialdisplayalerts = application.displayalerts application.displayalerts = false while filename <> "" set wb = workbooks.open(filename:=pathname & filename, _ updatelinks:=false) wb.checkcompatibility = false savefilename = replace(filename, ".xlsx", ".xls") wb.saveas filename:=pathname & savefilename, _ fileformat:=xlexcel8, password:="", writerespassword:="", _ readonlyrecommended:=false, createbackup:=false wb.close savechanges:=false filename = dir() loop application.displayalerts = initialdisplayalerts end sub i tryin

php - Task schedular of laravel not working properly on server -

i able execute individual artisan commands on server using putty cli. eg. php artisan inspire and other custom commands related database, work fine while using putty. put them in kernel.php 's schedule funtion this protected function schedule(schedule $schedule){ $schedule->command('customcommand:execute')->everyminute(); } when run command using putty php artisan schedule:run it works fine. problem not able execute schedule:run command via servers cron job.. command looks on server php -d register_argc_argv=on /path/to/artisan schedule:run >> /dev/null 2>&1 funny thing able execute individual commands via servers cron job i.e. php -d register_argc_argv=on /path/to/artisan customcommand:execute >> /dev/null 2>&1 works well... only schedule command not working. also not show errors.. also if dont add '-d register_argc_argv=on', exception 'errorexception' message 'invalid argument supplie

python - Edit file while executing in PyCharm -

i working on project in pycharm involves extensive computations, long runtimes. i following: come version of code; run it, edit code more; however, run started before still only uses old version of code (i.e. snapshot @ point of running). is possible in pycharm? i run project selecting run 'projectname' option run menu. i understand run works pre-compling .py files .pyc files stored in __pycache__ folder. however, don't know following. will saving file in pycharm cause .pyc files replaced new versions? want avoid since want 1 run use 1 snapshot of source tree, not multiple versions @ different points of execution. what if python class needed, say, 20 minutes after run has started. .pyc file created @ beginning of run, or on-demand (where corresponding .py file might have changed)? i use pycharm in classes. experience required code, including imported modules, compiled @ runtime. if change in suite need start running scratch take effect. i'

c++ Is there a way to find sentences within strings? -

i'm trying recognise phrases within user defined string far have been able single word. example, if have sentence: "what think of stack overflow?" is there way search "what you" within string? i know can retrieve single word find function when attempting 3 gets stuck , can search first. is there way search whole string in string? use str.find() size_t find (const string& str, size_t pos = 0) its return value starting position of substring. can test if string looking is contained in main string performing simple boolean test of returning str::npos: string str = "what think of stack overflow?"; if (str.find("what you") != str::npos) // contained the second argument can used limit search string position. the op question mentions gets stuck in attempt find 3 word string. actually, believe misinterpreting return value. happens return single word search "what" , string "what you" have coincide

javascript - Why isn't this function reading and displaying cookie? -

i have written code. isn't displaying cookie. displays prompt again , again, whenever open page. how can correct it? <body onload="myfunc()"> <script> function createcookie(value, exdays) { var date= new date(); var d= date.settime(date.getdate()+(exdays*10000)); var e = date.toutcstring(d); var g = document.cookie= "user="+value+";"+" "+"expires="+e; return g; } function readcookie() { var h = document.cookie; var i= h.split(";"); return i[0]; } function myfunc() { var a= readcookie(); if(a!="") { alert("welcome"+a); } else { var b = prompt("enter name", ""); createcookie(b, 5); } } javascript case sensitive: var date = new date();

php - CakePHP: Use value from dropdown to populate a view -

this 1 of things feel should easier i'm making it. have dropdown list populated values table. want user select list item , have list item id returning set of rows on subsequent view. here dropdown code view: echo $this->form->input('mission_id', array('label' => 'mission id')); echo $this->html->link(__('view'), array('action' => 'index')); and here simple browse controller, returns in table: public function browse() { $this->set('requirements', $this->paginator->paginate('requirement')); } i cannot figure out how make controller receive value user selects can filter next view. when "view" clicked, should return 500 rows contain selected id. don't know put after 'action' => 'index' carry on browse controller. you need wrap input in form submits index action , replace link submit button:- echo $this->form->create(null,

Maintain server time even in offline mode (javascript/html5) -

i stuck in design scenario have javascript/html5 based application runs in offline mode . browser based , there crud operations happen. now when in offline mode maintain server time in application. server time needed crud operations etc how maintain server time using javascript/html5 when running locally? note : application contacts server first time , downloads data, can fetch time too. ** i cannot calculate server time using device's local time because user can change device's time , create fraud entries. ** you can't, there's no way of stopping users changing time on device , can't contact online server if have no network connection. if verifiable audit crucial should record time when updates hit server rather attempting record time updates hit device. of course, nothing stopping doing both.

angularjs - angular factory - how do i evaulate function and get property value -

i have following code in angular service. var tstobject = { isallow: false, }; var getdata = function () { var tstdata = tstservice.get(_mydata); if (tstdata != null) return tstdata else return tstobject; } factory.auth = getdata(); i trying isallow property in controller following if (!myservice.auth().isallow) { } it complains auth() not function. how can property value? when initialising auth executing getdata function. mean factory.auth contain result, in case object, not function. so, fix that, should doing is: factory.auth = getdata; , auth refer getdata function.

html - Responsive images reflow -

we developing responsive site allow user upload images. we preserve original , generate thumbnail image served users lower resolutions. the issue has been raised when image switched in logic smaller screen size there visible re-flow of elements around it. i unsure how prevent images of inconsistent height cannot set initial height on containing element. any ideas appreciated. i looked @ this: http://andmag.se/2012/10/responsive-images-how-to-prevent-reflow/ but seems scenarios know ratio i.e. 16:9, 4:3 etc i assume thumbnails have fixed maximum size. you can put image inside box maximum height/width set orientations (landscape, portrait, square) doesn't matter. give fixed whitespace around image. you can generate whitespace in thumbnail giving fixed width/height in images.

c++ - QKeyEvent in my app does not work -

i want program retro snaker responds keyevents, here's code: paint.h #ifndef paint_h #define paint_h #include<qwidget> #include<qpaintevent> #include<qkeyevent> #include<qtimer> class paint:public qwidget { q_object public: paint(qwidget*parent=0); ~paint(); protected: void paintevent(qpaintevent* ); void keypress(qkeyevent* keyevent); public slots: void autorun(); private: int snake[100][2]; int length; qtimer *timer; int flag; }; #endif paint.cpp #include"paint.h" #include<qtgui> paint::paint(qwidget*parent):qwidget(parent) { flag=1; snake[0][0]=45; snake[0][1]=45; length=4; timer=new qtimer; timer->start(1000); connect(timer,signal(timeout()),this,slot(autorun())); } paint::~paint(){} void paint::paintevent(qpaintevent* ) { qpainter p(this); p.setwindow(0,0,810,810); qrectf border(45-20,45-20,16*45+40,16*45+40); qrectf inter(45,45,16*45,16*45); p.setpen(qt::nopen); p.setbrush(qbrush(qt

scala - Akka - test supervision strategy -

i have following scenario: parent supervisor actor creates child each message using factory (function) passed in constructor. class supervisoractor(childactormaker: actorreffactory => actorref) extends actor actorlogging{ def receive: receive = { case "testthis" => val childactor = childactormaker(context) childactor!"messageforchild" } override val supervisorstrategy = oneforonestrategy() { case _ => stop } } class childactor extends actor { def receive:receive = { case _ => /** whatever **/ } } in test override child receive force exception. expectation child actor stopped every time because of supervision strategy set. "when child actor throws exception supervisor actor " should " " + " stop it" in { val childactorref = testactorref(new childactor() { override def receive = { case msg: string => throw new illegalargumentexception(&qu

c - Is there a standard way to reconstruct lowered struct function arguments? -

i have structure type: typedef struct boundptr { uint8_t *ptr; size_t size; } boundptr; and want catch arguments of function of type. e.g. in function: boundptr sample_function_stub(boundptr lp, boundptr lp2); on 64bit machine, clang translates signature to: define { i8*, i64 } @sample_function_stub(i8* %lp.coerce0, i64 %lp.coerce1, i8* %lp2.coerce0, i64 %lp2.coerce1) #0 { question: is there better way reconstruct such arguments? is possible forbid such argument lowering, while keeping same abi external calls? some more context: so in llvm ir, guess, according platform abi, compiler broke down structure separate fields (which not worst case, see 1 ). btw, reconstructs original 2 parameters lp , lp2 later in function body. now analysis, want 2 parameters lp , lp2 in full, out of these 4( lp.coerce0 , lp.coerce1 , lp2.coerce0 , lp2.coerce1 ). in case, can rely on names ( .coerce0 means first field, .coerce1 - second). i not approach: i not sure,

android - Ajax json cross domain request not working with cordova app -

i doing cordova android app. in want user login functionality authenticated rest api. in mobile device giving ajax error code '0' , thrownerror blank. have attached device desktop system testing app. while in desktop browser working fine. have used below code, apiurl = "http://xxx.xxx.xxx.xxx/restapi/"; $.ajax({ url: apiurl+'user-signin/login', type: 'post', datatype :'json' crossdomain: true, beforesend:function(){ $.mobile.loading( 'show' ); }, complete: function() { $.mobile.loading( 'hide' ) }, success: function (res) { alert(res.status); if(res.status == "success") { goinsert(res.result.user_id, res.result.user_name, res.result.user_password); window.location="dashboard.html";

android - Dynamically added RatingBar does not show up -

i adding ratingbar linear layout dynamically. rating bar not visible of phone visible in tablet. following code creating ratingbar. view newwidget = new ratingbar(appcontext); linearlayout.layoutparams layoutparams = new linearlayout.layoutparams(viewgroup.layoutparams.wrap_content, viewgroup.layoutparams.wrap_content); layoutparams.gravity = gravity.center_horizontal; newwidget.setlayoutparams(layoutparams); ((ratingbar) newwidget).setstepsize(1.0f); try below code: ratingbar ratingbar = new ratingbar(context, null, android.r.attr.ratingbarstylesmall); try set style rating bar before loading view runtime. hope work you. thanks!!!

spring - Refresh cache triggered by changes in database is it possible? -

in application i'm using spring, hibernate , ehcache. problem database being modifiy application. is possible, there implemented solution refresh cache based on database changes? can use additional column versioning etc. any ideas? what looking know read-write through caching. ehcache supports it. from ehcache documentation: write-through caching caching pattern writes cache cause writes underlying resource. cache acts facade underlying resource. pattern, makes sense read through cache too. write-behind caching uses same client api; however, write happens asynchronously. ehcache-2.0 introduced write-through , write-behind caching. while file systems or web-service clients can underlie facade of write-through cache, common underlying resource database. here detailed article: http://www.ehcache.org/documentation/2.8/apis/write-through-caching.html#write-through-and-write-behind-caching-with-the-cachewriter-

python - What are the pros and cons of using a structured array in Numpy instead of several arrays? -

i use numpy gather objects same properties in efficient way. don't know choose between using 1 structured array or several arrays. for example, let's consider object item , properties id (4 byte unsigned integer), name (20 unicode characters), price (4 byte float). using structured array: import numpy np item_dtype = np.dtype([('id', 'u4'), ('name', 'u20'), ('price', 'f4')]) # populate: raw_items = [(12, 'bike', 180.54), (33, 'helmet', 46.99)] my_items_a = np.array(raw_items, dtype=item_dtype) # access: my_items_a[0] # first item my_items_a['price'][1] # price of second item using several arrays, wrapped in class convience: class items: def __init__(self, raw_items): n = len(raw_items) id, name, price = zip(*raw_items) self.id = np.array(id, dtype='u4') self.name = np.array(name, dtype='u20') self.price = np.array(price, dtype=

python - How to call a custom function along with the event when a file is modified? -

i need in being able make call my_custom_function when file being modified. want have state of file file_change, file_delete, etc available. i've used watchdog, supports predefined functions first parameters schedule(). should able make custom call , operations on it. use case file content before file modifications , after file modifications, using watchdog. import sys import time import logging watchdog.observers import observer import os def my_custom_function(): print "---" if __name__ == "__main__": logging.basicconfig(level=logging.info, format='%(asctime)s - %(message)s', datefmt='%y-%m-%d %h:%m:%s') path = os.path.abspath(".") my_event = my_custom_function() observer = observer() observer.schedule(my_event, path, recursive=true) observer.start() try: while true: time.sleep(1) except keyboardinterrupt: observer.s

Passing references in java -

this question has answer here: is java “pass-by-reference” or “pass-by-value”? 74 answers i know fact primitives being passed value in java. references being passed by? reference, or value? can't find clear answer. indeed, passed reference. remember though objects in java stored pointers. when pass object, passing reference pointer, no object itself.

ibm - How to automatically update FileNet P8 data design in multiple environments -

i find changing data design via acce slow process , might cause human errors. propagating changes 1 environment seems quite tedious (for example dev test). is there way propagate data design changes other p8 environments? maybe it's possible write kind of update scripts? filenet ships program called "filenet deployment manager" fdm. this helps take tediousness away pushing changes dev through prod. if prod environment established, need rebuild dev environments first deploying production backwards. i suggest looking tool, learning strengths , weaknesses. has helped out bunch. btw fdm has vastly improved 4.5.1 5.2.1. can deploy global objects marking sets etc.

html - How do I target the last N sibling elements only when there are Y siblings in CSS? -

is possible target last n sibling elements when there y siblings? for example have list of items, if , only if there 8, 11, 14... etc sibling elements want last 2 different (so 8 + 3n ). if there other amount of children want them same. the easiest way far target each of 2 elements want style own set of pseudo-classes. the last child, state, represented 3n+8 (8, 11, 14...). follows penultimate child 3n+7 (7, 10, 13...). li:nth-last-child(1):nth-child(3n+8), li:nth-last-child(2):nth-child(3n+7) { color: red; } ul { counter-reset: item; list-style-type: none; } li { display: inline; padding: 0.25em; } li::before { content: counter(item); counter-increment: item; } <ul><li><li><li><li><li><li><li><li></ul> <ul><li><li><li><li><li><li><li><li><li></ul> <ul><li><li><li><li><li><li><l

javascript - Traverse an object tree and render a menu tree based on object property condition -

hello i'm trying create html menu given object following , wondering if there library can me traverse object, instead of reinventing wheel. var root = { category1: { depth: 0, categories: { category1: { depth: 1 }, category2: { depth: 1, products: [1, 2, 3, 4, 5] }, category3: { depth: 1, categories: { category1: { depth: 2, products: [1, 2, 3, 4] }, category2: { depth: 2, products: [1, 2, 3, 4, 5, 6, 7] }, category3: { depth: 2 } } } } }, category2: { depth: 0, category1: { depth: 1, }, categ

In JavaScript, can I check to see if a string can be evaluated without actually evaluating it? -

i attempting write function convert function. function should work follows: check see if function , if returns it. check see if string , if there global function name, if return that. check see if string can evaluated , if return lambda (anonymous) function evaluates string. if previous attempts convert value function fail, return lambda (anonymous) function returns value. how handle other variable types (numbers, null, undefined, boolean, objects , arrays). function caneval(str){ try { eval(str); } catch (e){ return false; } return true; } function tofunc(v){ if(typeof(v) == "function") return v; if(typeof(v) == "string"){ if( window[v] != undefined && typeof(window[v]) == "function" ) return window[v]; if(caneval(v)) return function(){eval(v)}; } return function(){return v;}; }; the problem code caneval evaluates code, in circumstances not want code (in string) run more once. evaluates str

python 2.7 - How to send automatically the same email to several users from code in Odoo8? -

i sending email in odoo 8 python code several users. to using send_mail method email.template model, but, have pass 1 user id method, have loop send mail users: for user in users: if user.partner_id , user.partner_id.email: mails_sent &= self.pool.get('email.template').send_mail( self.env.cr, 1, template.id, user.id, force_send=true, context=context) my question is: how can send 1 email users instead of 1 email each user? you need see hr odoo 8 inherit class mail.thread _inherit = ['mail.thread'] #..... #after can call id_msg = self.message_post( cr, uid, false, body=message, partner_ids=[id1,id2,id3], subtype='mail.mt_comment', context=context ) i hope :)

Regex to extract multiple URLs -

i extract category values doubleclick urls sit within of web source code across full site ; <script type="text/javascript"> var axel = math.random() + ""; var = axel * 10000000000000; document.write('<iframe src="https://1234567.fls.doubleclick.net/activityi;src=1234567;type=examp123;cat=examp999;ord=1;num=' + + '?" width="1" height="1" frameborder="0" style="display:none"></iframe>'); </script> <noscript><iframe src="https://1234567.fls.doubleclick.net/activityi;src=1234567;type=examp456;cat=examp888;ord=1;num=1?" width="1" height="1" frameborder="0" style="display:none"></iframe></noscript> what extract follows; cat 1 = examp999 cat 2 = examp888 i have tried below @ankitmishra answer; https:\/\/(?:.*.doubleclick.net).*cat=([^;]*); this returns both values - tool using crawl pages of w

How to add Perspective Bar Switcher to pure eclipse 4 rcp application -

Image
i have created pure eclipse e4 rich client platform application application model. created multiple perspectives using perspective stack, unable switch other perspective because there no default perspective bar or switcher icon present in eclipse e4. how implement perspective switcher in pure eclipse e4? epartservice.switchperspective actual switch, have design , implement ui. you use toolbar in window trim bar buttons each perspective. alternatively combo tool control list of perspectives, you. to put control @ right of trim bar need add 2 tool control objects trim. like: the first tool control spacer fill center of bar. on tags tab control add word stretch tell e4 stretch control on space possible: you have specify class control. needs create empty composite occupy space. example: public class spacercontrol { @postconstruct public void postconstruct(final composite parent) { composite body = new composite(parent, swt.none); body.setla

How to delete/invalidate a php session different to the current one -

i want prevent user login website multiple browsers simultaneously. server backend written in php. idea invalidate session user when logs in again. to know session user has last logged in, store session id in mysql database (as varchar). but how can invalidate session different current 1 in php? please check answer provided on below urls how prevent multiple logins in php website how prevent multiple user login same user name , password?

MySQL Error "Can't get hostname for your address" in PHP -

i having trouble connecting sql database pointing domain. connect.php returns following warning: warning: mysqli::mysqli() [mysqli.mysqli]: (hy000/1042): can't hostname address connect.php <?php $server = "agenciaeficacia.com.br"; $user = "my-user"; $pass = "my-password"; $db = "my-db"; // cria conexÃo $conexao = new mysqli($server, $user, $pass, $db); // checa conexÃo if ($conexao->connect_error) { echo "falha ao conectar com o banco de dados."; } date_default_timezone_set('america/sao_paulo'); ?> the weird thing connection works on localhost , not when upload server (unless use localhost instead of domain). have tried skip-name-resolve solution, didn't work. is there way solve problem? i had problem time , worked when disabled dns lookup. if option can change my.cnf or my.ini [mysqld] skip-name-resolve

java ee - Modify configuration properties of ejb-jar.xml during deployment in GlassFish 4.0 -

i have ejb-jar.xml contains configuration information 1 of mdb. in there configuration of: <activation-config-property> <activation-config-property-name>addresslist</activation-config-property-name> <activation-config-property-value>mq://test.server.uk:7676</activation-config-property-value> </activation-config-property> as project built , packaged , distributed off users need able make sure value can modified users have different server addresses. currently have option set address in properties file. there anyway modify xml during deployment on glassfish 4.0 property value? if not going have set value every time wants application , re-build it? i open putting configuration else need have dynamic users can set server addresses in properties file. one thing can try use @aroundconstruct interceptor set value on mdb @ runtime. it's worthwhile note while possible use placeholders in ejb-jar.xml, it's cont

google apps script - How to get the date of the form submitter or the document in a published add-on -

Image
in google apps script add-on simply send , try capture timestamp. timestamp (using e.response.gettimestamp().tostring(); ) formatted est, timezone (the timezone of master script file). what have either timezone of person submitting form, or timezone of form document add-on installed on. if has cool trick information appreciated. if assume user running add-on in same timezone form, getting user's time zone should sufficient. the calendarapp has gettimezone() method return time zone of user's primary calendar. template.timezone = calendarapp.gettimezone(); below quick forms add-on demo display time zone in dialog. time zone returned string, name of time zone listed joda.org . format used google apps script triggerbuilders, example: // schedule trigger execute @ noon every day in us/pacific time zone scriptapp.newtrigger("myfunction") .timebased() .athour(12) .everydays(1) .intimezone("america/los_angeles") .create()

python - How to get the groups generated by "groupby()" as lists? -

i testing itertools.groupby() , try groups lists can't figure out how make work. using examples here, in how use python's itertools.groupby()? from itertools import groupby things = [("animal", "bear"), ("animal", "duck"), ("plant", "cactus"), ("vehicle", "speed boat"), ("vehicle", "school bus")] i tried (python 3.5): g = groupby(things, lambda x: x[0]) ll = list(g) list(tuple(ll[0])[1]) i thought should first group ("animal") list ['bear', 'duck'] . empty list on repl. what doing wrong? how should extract 3 groups lists? if want groups, without keys, need realize group generators go, per docs : because source shared, when groupby() object advanced, previous group no longer visible. so, if data needed later, should stored list. this means when try list -ify groupby generator first using ll = list(g) , before

vba - Exporting Microsoft Office 16.0 Office Library and use it with Excel 2013 -

i used excel 2016 create excel table vba program generate word document report automatically. macro generates compile error when used on excel 2013 older office library. i tried following without success: using older version of excel save macro (no improvement). changing code (e.g: word.application -> object) proposed on other threads. main problem program ~2000 lines long , when fix something, compile error arise few lines later. plus, formatting in word document altered. updating office 2016 not solution either various compatibility reasons other programs. the remaining solution can see export microsoft office 16.0 office library , microsoft excel 16.0 library computers running excel 2013 , adding them vba references. i cannot locate these 2 libraries. path shown in tools->references window cut because window short (and of course not possible resize). what path , file name 2 libraries? do think solution work , if not, know better 1 or workaround?

spring - Jersey custom ExceptionMapper not called on 400 Bad Request (when validation fails) -

i'm using jersey spring web services. catching exceptions , formatting response sent caller have added implementation of exceptionmapper. though being called when explicitly throw exception within controller, when json field validation fails exception mapper not called , response sent **may not null (path = checknotification.arg0.tyres, invalidvalue = null) ** @provider public class genericexceptionmapper implements exceptionmapper<throwable> { @override public response toresponse(throwable ex) { system.out.println("exception mapper !!!"); return response.status(404).entity(ex.getmessage()).type("application/json").build(); } } <servlet> <servlet-name>jersey-servlet</servlet-name> <servlet-class> org.glassfish.jersey.servlet.servletcontainer </servlet-class> <init-param> <param-name>jersey.config.server.provider.p