Posts

Showing posts from May, 2015

osx - Java Performance on Macbook Pro (not GUI) -

i have java code fetch data sqlite , linguistic processing (lemmatization) data , write modified data sqlite datebase . database tables have indexes, query should fast although data joined. small program shall produce database being used in iphone app. on ubuntu pc (14.04.3 lts) program runs fast, on macbook pro (os x el capitan 10.11) runs 10 or more times slower. java -version on ubuntu pc: java version "1.7.0_80" java(tm) se runtime environment (build 1.7.0_80-b15) java hotspot(tm) 64-bit server vm (build 24.80-b11, mixed mode) java -version on macbook: java version "1.8.0_45" java(tm) se runtime environment (build 1.8.0_45-b14) java hotspot(tm) 64-bit server vm (build 25.45-b02, mixed mode) i pointed eclipse jdk 7 in java->installed jres have same version on ubuntu pc the java command generated eclipse same on both machines: /path/to/jdk7/java -dfile.encoding=utf-8 -classpath ... many jars ... my.package.myclass how same speed on macb...

javascript - Drag Bound wiith Konva.Layer -

i using konvajs in project. need implement drag bound konva.layer . layer has many other shapes , images. need restrict movement of layer 50% of it's width , height. way have done in plunkr. problem arises when user zoom-in or zoom-out layer using mouse wheel. after zoom, don't know why drag bound behaving differently. seems not able math correctly. need have same behavior i.e. way movement of layer restricted when user not perform zoom. doing: //... helper object zooming var zoomhelper = { stage: null, scale: 1, zoomfactor: 1.1, origin: { x: 0, y: 0 }, zoom: function(event) { event.preventdefault(); var delta; if (navigator.useragent.tolowercase().indexof('firefox') > -1) { if (event.originalevent.detail > 0) { //scroll down delta = 0.2; } else { //scroll delta = 0; } } else { ...

linux - How to use "ls *.c" command in java? -

i trying print "*.c" files in java i use below code public static void getfilelist(){ try { string lscmd = "ls *.c"; process p=runtime.getruntime().exec(lscmd); p.waitfor(); bufferedreader reader=new bufferedreader(new inputstreamreader(p.getinputstream())); string line=reader.readline(); while(line!=null) { system.out.println(line); line=reader.readline(); } } catch(ioexception e1) { system.out.println("pblm found1."); } catch(interruptedexception e2) { system.out.println("pblm found2."); } system.out.println("finished."); } p.s:- working fine "ls" command.when using "*" in command, aren't work. need replacement of "*" in command in java. update thanks guys. now need same result comment " ls -d1 $pwd/** "in java. list directory names full pat...

php - how to send session's content to a remember me cookie? -

i working on remember me cookie in cakephp keeps logged in 2 weeks. it working fine, passing written onto cookie: $this->request->data['user']['username'] whenever new user registered, hashed id created default. the remember me cookie generates key checks if same user , logins in backgroud. when cookie created cakephp expires (default being 4 hours), information such user id, address, etc lost. how send id checked instead? how store of those(user info) after 4 hours? (say around 2 weeks) change login function this function login() { if ($this->auth->user()) { if (!empty($this->data['user']['remember_me'])) { $cookie = array(); $cookie['username'] = $this->data['user']['username']; $cookie['password'] = $this->data['user']['password']; $this->cookie->write('auth.user', $cookie, true, ...

c++ - How to access an attribute into a struct from a void pointer? -

i given task can't see function in detail know id generally. so have function, let's call "get_button", , in documentation know "it returns pointer button struct". know button struct, it's like: struct button{ int size; char title; short keyid; }; the function like: void * get_button(int id, int group) but can't know does. now want know title, playing complier got have void pointer in return. how supposed use void pointer? asaik have use static_cast give reference it, in case struct; can't understand casting means , how make compiler know want struct. this particular case need know how parameter struct void pointer. don't know if should use static_cast or whatever (so can't understand reference it). neither need know how use propery void pointer in case! need know how can access attribute in struct. i've seen other answers here , there couldn't find valuable case. i can't understand ca...

angularjs - Jquery ellipsis plugin not working with angular directive -

i trying use jquery-ellipsis plugin within ng-repeat using directive. .directive('ellipsisitem', function () { return { restrict: 'a', replace: true, link: function (scope, element, attrs) { $(element).ellipsis(); } }; }); and dom is: <li class="list-group-item ng-scope" ng-repeat="question in questions" ellipsis-item> {{question.questiontext}}</li> but list content of {{question.questiontext}} if remove $(element).ellipsis(); works fine!! anyone? try wrap $(element).ellipsis() in $timeout(function(){});

How To Add Custom Field in Report ->Sales->Sales->Order Form In Magento -

Image
i want add new field in report->sales->sales->order->form from screenshot, understand want "add new field - order date similar date field" steps achieve that: override file app/code/core/mage/sales/block/adminhtml/report/filter/form/order.php by override, mean create custom module under /app/code/local/namespace/module after line no: 56 add below code block: $fieldset->addfield('order_date', 'date', array( 'name' => 'order_date', 'format' => $dateformatiso, 'image' => $this->getskinurl('images/grid-cal.gif'), 'label' => mage::helper('reports')->__('order date'), 'title' => mage::helper('reports')->__('order date'), 'required' => true )); so function below: protected f...

How to delete only class files with eclipse? -

i have dynamic web project in eclipse. set default output folders (my class files) in webcontent/web-inf/classes. have files in folder .properties , .xml files. problem when eclipse make clean or new compile or dont know delete files directory. u know how set eclipse delete class files , never touch other ones? put .properties , .xml files in source folder of web project , not in classes folder. doing way, eclipse directly copy files source folder classes folder after build.

mysql - sequelize - cannot read property catch of undefined -

i using sequelize mysql in project. current use case populating table 'roles_master' default roles. the function createdefaultroles implementation checks: if there rows in table if yes, , force true, deletes existing rows , inserts new rows if table empty, directly inserts new rows my code below... /** * creates pre-defined set of roles * if roles table exists , contains data, * function returns, without creating roles. * list of roles defined in file "ecp_db_defaults.js" * * @param force -- boolean flag indicate whether drop existng roles , recreate afresh **/ function createdefaultroles(force, callback) { console.log("executing createdefaultroles..."); db.role.count().then(function(result) { if (result>0) { if (force) { console.log("emptying roles table..."); db.role.destroy({force:true, where: {}}).then(function() { db.role.bulkcreate(dbconfig.roles).done(function() { ...

c# - Access is denied exception when using Process.Start() to open folder -

i have winforms application in c# have open folder. use system.diagnostics.process.start(pathtofolder); this results in following exception: system.componentmodel.win32exception (0x80004005): access denied at system.diagnostics.process.startwithshellexecuteex(processstartinfo startinfo) at system.diagnostics.process.start() at system.diagnostics.process.start(processstartinfo startinfo) at myapp.openlogfoldertoolstripmenuitem_click(object sender, eventargs e) i have checked following things: the folder exists the user has rights folder (can open in explorer) another thing if use process.start() open file inside folder, works. can give me hint? cheers edit goal open folder in explorer. pathtofolder h:\something\app.name\log according msdn ( https://msdn.microsoft.com/en-us/library/53ezey2s(v=vs.110).aspx ) system.diagnostics.process.start(string) runs file or process (and therefore not open folder). opening folder, https...

java - Importing an image from another folder into eclipse -

i have compiled entire project in eclipse , works file. i have class file embed.java ,that uses mat-lab,what shows output in mat-lab while using java api. have achieved using open source 'mat-lab control google code' my code contains 2 images,i have tried import images performing basic steps, project -> right click -> import -> general -> file system but gives me error(in mat-lab) image not exist. i have copy-pasted images in src folder(the 1 automatically created in eclipse) still gives me same error. apart have done reading of posts in forum, has not helped me. just drag , drop pictures have them on system source tree in eclipse (left side). should popup asking whether or not copy images folder or move original picture folder. the problem not pointing right place images stored in source code.

java - Is singleton approach right for accessing/maintaining database and internet connection -

so , working on app requires local db connection , uses web services send , receive data back-forth well. whenever need , database operation create object of dbconnection class (this name of class using database) , perform operations on same. similarly connecting internet use defaulthttpclient , create static object of same, , whenever need connection , call webservice create httpresponse object , response data. 1) using right approach or pattern ? 2) 1 more thing focusing on point number 2 static , singleton work same way ? am using right approach or pattern ? i don't think so. if use singleton (or static) the connection make difficult if code needs used / reused in context there may need more 1 connection; e.g. if make application multi-threaded, or turn library. singletons have problems respect testability ... generally speaking, can singletons (or statics) can context parameter of kind. dependency injection (di) frameworks provide neat ...

how to be a super user to run linux commands in python script? -

i have execute few commands in linux need super user before execute command. has done via python script scenario should execute following command in order >> su this prompts password after entering password have execute bluez commands >> hciconfig hci0 >> hcitool lescan >> hcitool lecc <address> i need in python please tell me how super user , give password via python later execute above commands in order? meaning,i want automate whole process execute commands without manual intervention. good security practice says should minimize time @ elevated privilege. 1 way put commands run root in different file , cause file run root. have several options: your script run other script sudo: subprocess.check_call(['sudo', '/we/run/as/root']); you make script 'setuid-root' , run it, no sudo needed: subprocess.check_call(['/we/run/as/root']); (however, on many systems not work because setuid-root disabled ...

javascript - convert mouse click to 3d space with orthographic camera -

three.js : rev 73 i'm using following construct find intersection of mouse click objects in 3d world (orthographic setup): function ondocumentmousedown(event) { event.preventdefault(); console.log("click"); var mouse = new three.vector2(); mouse.x = (event.clientx / window.innerwidth) * 2 - 1; mouse.y = -(event.clienty / window.innerheight) * 2 + 1; var raycaster = new three.raycaster(); // update picking ray camera , mouse position raycaster.setfromcamera(mouse, camera); // calculate objects intersecting picking ray var intersects = raycaster.intersectobjects(scene.children); console.log("intersects: " + intersects.length); (var = 0; < intersects.length; i++) { console.log(intersects[i].point); } } however, intersection inaccurate. intersection captured when click near top left of box only. jsfiddle : can please me understand why misbehaving ? also, if no object being selected,...

Reading Excel via COM interop -

my coworker have made srcript open excel , read values it. has problem read value see in file. have value 9.12345678 depending on column size returns 9.1, 9 , on. uses text propertie. have tried using value , value2 no efffect cannot 9.12345678. ideas ? in advance. as gerg said on workbook object set xlbook.precisionasdisplayed := false; and on range object use .value many thanks

php - Pagination not working correctly in laravel -

my pagination not working correctly.when pagination clicked takes time display result , when click page 1 after other ,the pages continuously loaded. why happens ...can 1 me this?????............. my view.blade.php <div class="carousel-inner" role="listbox"> <div class="item active"> <img src="{{ config::get('constants.site_url') }}public/hotel_images/{{ $rat->image }}" class="img-responsive center-object"/> </div> @if(!empty($rat->imagestore)) @foreach($rat->imagestore $image) <div class="item"> <img src="{{ config::get('constants.site_url') }}public/uploadstoreimages/{{ $image->store_image }}" class="img-responsive center-object"/> </div> @endfore...

android - ResolveInfo.loadIcon() causes warning-Spam -

in android application, displaying list of every user-app installed. everything runs fine, mentioned in below code, calling icon = info.loadicon(context.getpackagemanager()); results in 2 annoying warnings. since loading every app on device, generates huge list of warnings spamming console. despite warnings, icon loading , displaying fine. i don't warning comes from. how debug it? alternatively, can 1 disable log-output of specific code line? here wrapper class: public class appwrapper { public final drawable icon; public final string applabel; public final string packagename; public appwrapper(context context, resolveinfo info) { //warnings produced here: icon = info.loadicon(context.getpackagemanager()); /* packagemanager: no package identifier when getting value resource number 0x00000000 resourcetype: failure retrieving resources com.example.app: resource id #0x0 */ applabel = info.load...

How to write a Java class file corresponding to a new entity in Android Studio? -

i have entity class: public class item { private int m_id, m_number, m_price; public int getid() { return m_id; } public void setid(int id) { m_id = id; } public int getnumber() { return m_number; } public void setnumber(int number) { m_number = number; } public int getprice() { return m_price; } public void setprice(int price) { m_price = price; } } where should put item.java ? i'm using android studio, , want have proper project package structure. read endpoints, don't know it. can me, please? sorry bad english, hope understand. as android developer consultant see lot of different android projects different package structure. while see encouraged put entities in package called entities want why think bad idea. is, instead of having packages named after type/layer entities activities fragments services ..etc you structure package based on feature ...

objective c - iOS 8 : Background execution -

i implementing app set local notification particular time. when notification fired want set next notification based on date database execution. how can accomplish in ios. i have tried find different way of doing not able figure out yet. here issues facing. can callback when local notification fired irrespective of user action ? can perform background execution @ specific time ? how ? is there else can use? if app in foreground, can set next notification in didreceivelocalnotification method in appdelegate when app not running, can callback if user clicks notification , application has launched. here tutorial local notifications, can follow

How do Twitter clients on a phone get notified of changes? -

i playing twitter api. when unlike using api, tweet disappears in tweetbot on phone. how mobile app know change? since api rate-limited quite aggressively, guess can’t polling. there kind of notification api events? or implemented using streaming api ? it streaming api. there’s event stream contains messages likes , unlikes.

java - How to get browser logs using selinium -

i have log logs using formatting. console.log('%c%s - %s', 'color:blue; font-weight:bold;', msg.type, msg.message); i need these logs using selinium. using logentries logentries = driver.manage().logs().get(logtype.browser); (logentry entry : logentries) { system.out.println(entry.getlevel() + " " + entry.getmessage()); } prints info xyz/abc/logservice.js 45:14 %c%s - %s instead of printing value of object. how value of %s or %c formats in logs.

java - Updating image in IE11 not working -

i having application upload multiple image using browse button. calling servlet performing these operations store in databse,retreive , store in database. below code of jsp page : <%if(imagevo != null) {%> <tr> <% if (!imagevo.getimage1().equals("")) { filetype = (imagevo.getimage1().substring(imagevo.getimage1().lastindexof(".")+1,imagevo.getimage1().length())).tolowercase().trim(); system.out.println("inside if image1-=========="+filetype); if("jpg".equalsignorecase(filetype) || "jpeg".equalsignorecase(filetype)){ system.out.println("inside if222222 image1-=========="+filetype+"ireq"+ireq+"program type"+prog); %> <td align="left" colspan="4"><br/><img border="0" src="/s...

selenium - Java password encryption -

we have maven project website automation . website uses login , password enter first page . possible have below. passcord encrpted in format in property file if downloads entire maven project not visible in plain txt . selenium takes encrpted password property file , decrypts , enters website . you can use jasypt cli (command line) utility can used encrypt values of properties. download jasypt distribution , unpack it. utilities reside in bin directory. c:\jasypt-1.7\bin> encrypt input=postgres password=secret ----arguments------------------- input: postgres password: secret ----output---------------------- jd5zrepbqxun9ok0ihnxabgw7v3eog2p for detailed steps , do/don'ts can refer this page , this page

xampp - Can't access phpmyadmin after restarting computer -

my xampp has been installed correctly, i've created databases in phymyadmin already. after shutting down computer , opening again, can't access anymore. says this webpage not available control panel , running don't see reason why doesn't work. please help!!!

.net - How to add entity data model programmatically in runtime to Web Api project? -

is possible add entity framework in runtime web api project? for example/scenario; the company add 1 branch in runtime. branch's database informations such -connection string -database name stored in table of company's database. how can add branch's database connectionstring in web.config fie? , how connect database? you can initialize dbcontext connection string public mycontext(): dbcontext { public mycontext(){}; public mycontext(string connectionstring):base(connection){}; } and initilize below : var firstbranch = new mycontext("firstbranchconnection"); var secondbranch = new mycontext("secondbranchconnection");

rspec - Mocking or Stubbing mtime for File::Stat -

my object get s file on http. it so, using if-modified-since header. if files has not been modified since time in header not modified response returned , file should not fetched&written. so: class youtube #... def parse uri = uri("http://i.ytimg.com/vi/#{@id}/0.jpg") req = net::http::get.new(uri.request_uri) if file.exists? thumbname stat = file.stat thumbname req['if-modified-since'] = stat.mtime.rfc2822 end res = net::http.start(uri.hostname, uri.port) {|http| http.request(req) } file.open(thumbname, 'wb') |f| f.write res.body end if res.is_a?(net::httpsuccess) end #... end i want test both cases (in both cases, file on disk exists). so, i'd need stub either in net::http , or need stub file.stat return mtime sure online resource return new or not-modified-since. should stub (or mock) net::http ? , if so, what? or should stub mtime return date far in past or far in futu...

ipython - Unable to set up Jupyter Notebook -

i having couple problems setting jupyter notebook. have been on documentation many times , still haven't gotten working. running anaconda on windows 7 (and 10 on other computer - having same problem) workstation. unable open jupyter notebooks easily. have tried following in cmd prompt: "ipython notebook", "jupyter notebook", "jupyter-notebook", "ipython", , "jupyter" , "'xxxxxx' not recognized internal or external command". can cd c:\anaconda3\scripts , run jupyter notebook , works. there 2 problems this: first, it's band-aid not covers underlying problem , second opens c:\anaconda3\scripts , can't navigate .ipynb files are. don't have ipython notebook launcher icon change directory per follow instructions: • copy ipython notebook launcher menu desktop. • right click on new launcher , change “start in” field pasting full path of folder contain notebooks. i have spyder install , appears working p...

css - ExtJS 6 sliced Images for Internet Explorer 9 -

i have upgraded application extjs 6 extjs 4.i'm seeing 9 different folder in image directory of resource used internet explorer browser 9 only. i found these sliced images used internet explorer 9 browser only. directories extjs 6 library has sliced images 1) btn 2) btn-group 3) datepicker 4) grid-row-editor-buttons 5) panel 6) panel-header 7) progress 8) tip 9) window-header in application, have own custom theme showing images other these sliced images, css works internet explorer 9.my css work , replace sliced images in internet explorer 9. but, not sure why , browser keep requesting sliced images internet explorer 9 browser. is there way, can stop requesting these sliced images application while taking sencha build ? i want skip these sliced image folder ie 9 browser.i don't want request them i'm using customized images same.

c# - SOAP for wcf service -

this 1st time try wcf web service. i created wcf web service. testing wcf test client, works fine. when copy xml generated wcf test client postman/fiddler test web service, error 400 bad request . <s:envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"> <s:header> <action s:mustunderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://tempuri.org/icompanysvc/getlist</action> </s:header> <s:body> <getlist xmlns="http://tempuri.org/" /> </s:body> </s:envelope>` in postman/fiddler, use httppost on web service hosted in local iis url localhost:9999/companysvc.svc, use above content in body text/xml. web.config: <service name="companysvc"> <endpoint address="" binding="basichttpbinding" contract="icompanysvc"> <identity> <dns value="localhost"/> ...

uicollectionview - How to add image into collection view cell from local library in ios? -

i have used uicollectionview display images. when click insert image button, photos in local library should added uicollectioncell using uiimagepicker . declared uiimageview in custom cell racollectionviewcell . in didfinishpickingmediawithinfo delegate method of uiimagepickerview whenever writing cell.imageview.image = chosenimage . getting error undeclared identifier "cell" . please guide me how solve issue. any appreciable, in advance! here code: - (uicollectionviewcell *)collectionview:(uicollectionview *)collectionview cellforitematindexpath:(nsindexpath *)indexpath { static nsstring *cellid = @"cellid"; racollectionviewcell *cell = [self.collectionview dequeuereusablecellwithreuseidentifier:cellid forindexpath:indexpath]; [cell.imageview removefromsuperview]; cell.imageview.frame = cell.bounds; cell.imageview.image = [uiimage imagenamed:[_photosarray obje...

c# - Html agility pack parse oid -

here full html code: http://pastebin.com/wlwdcvz0 i parsed needed node agility pack. code: var html = new htmldocument(); html.loadhtml(request.get("http://www.odnoklassniki.ru").tostring()); var h1 = html.documentnode.selectsinglenode(@"/html[1]/body[1]/div[1]/div[3]/div[2]"); h1 contains: <!--{"uid":"aocrgdowcvpgtiymx0qqvblirnscijwdrcw","toolbar":true,"restrictednim":false,"restrictedmusic":false,"massuploadfix":true,"valentineactive":false,"navfactoryreqtimeout":3000,"discussionsrestricted":false,"share.urlpattern":"((?:(?:https?|ftp)://|(?:mailto:)?[-\\w!#$%\u0026'*+/\u003d?^`{|}~][-\\w!#$%\u0026'*+/\u003d?^`{|}~\\.]*@)?(?:(?:(?:(?:[\\wа-яА-Я-]+)\\.){1,5})(?:com|net|org|biz|info|name|pro|asia|aero|cat|coop|eco|jobs|mobi|museum|post|tel|travel|xxx|edu|gov|int|mil|рф|испытание|xn--[\\w-]*|[a-z]{2})|(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9...

c# - Custom Property of a Custom User Control gets reset during rebuild -

i have following properties [defaultvalue(true), category("behavior")] public bool enablebinding { get; set; } [defaultvalue(false), category("behavior")] public bool needapprove { get; set; } when changed using designer , save rebuild, new values set through designer remain property needapprove. enablebinding getting reset false. tried 1) designerserializationvisibility attributes, didnt work! visible hidden content 2) converting auto property full property worked. why? can not achieve without converting full property? you should assign initial value enablebinding property within custom user-control constructor: public partial class customusercontrol : usercontrol { public customusercontrol() { initializecomponent(); enablebinding = true; // !!! } [defaultvalue(true), category("behavior")] public bool enablebinding { get; set; } [defaultvalue(false), category("behavior...

android - RecyclerView espresso test click() not working -

i faced strange espresso instrumentation test behavior. clicking on recycler view's item not working. click not happened here : onview(withid(r.id.recyclerview)).perform(actiononitematposition(0, click())); but workaround works : onview(withid(r.id.recyclerview)).perform(actiononitematposition(0, recyclerclick())); // ... public static viewaction recyclerclick() { return new viewaction() { @override public matcher<view> getconstraints() { return any(view.class); } @override public string getdescription() { return "performing click() on recycler view item"; } @override public void perform(uicontroller uicontroller, view view) { view.performclick(); } }; } is espresso or recyclerview issue? should nothing recyclerview specifically. espresso viewactions.click() implementation sending motionevent center of target view. make s...

java - How to allow any user in JBoss config -

i have access problem in java web application , think it's because of rights of jboss. i'm using jboss 7.1. found files application-roles.properties , application-users.properties , think it's must assign rights. actually, have nothing in these files. i've searched conf don't find can me. can me give rights users please ? , maybe explain me how works please. just adding users file not going trick. here basic steps in adding authentincation , authorization in java web app. create login module , define jndi name login module in java application server. there many login modules choose such ldap, database, userproperties, certificate, etc. can point login module application-user.properties principal authentication , application-roles.properties roles definitions. then need add proper web application security-constraints in web.xml along authentication type of basic or form. pretty standard configuration. finally, add login module jndi name in jb...

android - Why my "viewpager" is not working? -

when run app, getting blank screen. have 2 fragments , xml files. following entire code: activity_main.xml <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" android:paddingtop="@dimen/activity_vertical_margin" android:paddingbottom="@dimen/activity_vertical_margin" tools:context="autogenie.designtrial.mainactivity"> <android.support.v4.view.viewpager android:layout_width="match_parent" android:layout_height="300dp" android:id="@+id/view" android:layout_ali...

Jenkins Execute Windows batch command fails for file change -

i trying change text in config file using jenkins windows batch command giving following error. (get-content config_qa.properties ) | {$_ -replace "test123", "test"} | set-content config_qa.properties ran above in jenkins windows batch command. below error message. '{$_' not recognized internal or external command, operable program or batch file. build step 'execute windows batch command' marked build failure [workspace] $ cmd /c call c:\windows\temp\hudson2235664364282200461.bat thanks are sure didn't miss operator (after first pipe)? like: (get-content config_qa.properties ) | {$_ -replace "test123", "test"} | set-content config_qa.properties edit: also, need make sure jenkins trying run in powershell, not windows batch (default)

C# equivalent to Delphi High() and Low() functions for arrays that maintains performance? -

in delphi there low() , high() functions return lowermost , uppermost index dimensions array. helps eliminate error prone for loops iterating array might fall victim insidious +1/-1 array boundary error, using <= when meant < terminating condition in for loop statement. here's example low/high functions (in delphi): for := low(ary) high(ary) for i'm using simple for loop statement in c#: for (int = 0; < ary.length; i++) i know there array method getdimension(n) has own liabilities since introduce error accidentally using wrong dimension index. guess enumerators, worry there significant performance cost when scanning large array compared using for loop . there equivalent high/low in c#? the c# equivalent intrinsic low(ary) , high(ary) functions are, respectively, 0 , ary.length-1 . that's because c# arrays 0 based . don't see reason why length property of array should have performance characteristics differ delphi's hig...

ruby on rails - Error while using rails_admin with rails5 -

i trying use rails_admin rails5 application. rails_admin 0.8.1 didn't work because bundler not find compatible versions gem "rails": in snapshot (gemfile.lock): rails (= 5.0.0.beta1) in gemfile: rails (< 5.1, >= 5.0.0.beta1) rails_admin resolved 0.8.1, depends on rails (~> 4.0) then tried using latest code github using gem 'rails_admin', git: ' https://github.com/sferik/rails_admin.git ' now getting conflicting rack dependicies. in snapshot (gemfile.lock): rack (= 2.0.0.alpha) in gemfile: rails (< 5.1, >= 5.0.0.beta1) resolved 5.0.0.beta1, depends on actionmailer (= 5.0.0.beta1) resolved 5.0.0.beta1, depends on actionpack (= 5.0.0.beta1) resolved 5.0.0.beta1, depends on rack (~> 2.x) rails_admin resolved 0.8.1, depends on rack-pjax (~> 0.7) resolved 0.7.0, depends on rack (~> 1.3) rails (< 5.1, >= 5.0.0.beta1) resolved 5...

php - how to replace values in array with values from another array? -

i'm fetching array: $sql = select id, name, state table order name $result = mysqli_query($conn, $sql); $rows = array(); $dict = ["a","b","c"]; while ($row = mysqli_fetch_array($result)) { //replace state value here before next line $rows[] = $row; } values in state field can 0,1,2. want replace value in key=state of $row value $dict 0=>a, 1=>b, 2=>c. value in state field equals position of $dict array. ex. if $row=["id"=>"1","name"=>"john", "state"=>"1"] new $row=["id"=>"1","name"=>"john", "state"=>"b"] you can use that: $dict = array("a","b","c"); $i = 0; while ($row = mysqli_fetch_array($result)) { $rows[$i]['id'] = $row['id']; $rows[$i]['name'] = $row['name']; $rows[$i]['state'] = $dict[$value[...

c# - An object refference is requied for non-static field, method or property -

this question has answer here: error: “an object reference required non-static field, method or property…” 6 answers i following error when compiling application: an object refference requied non-static field, method or property this code: using system; using system.collections.generic; using system.linq; using system.text; using system.threading.tasks; namespace consoleopener { class program { public static int casse; random rnd = new random(); public static int openit(int casse) { int32 skin = 0; if (casse==1) { skin = rnd.next(1, 3); } return skin; } public static void main(string[] args) { console.writeline("choose 1 of cases:"); console.writeline("1. test case"); ...

sql server - SQL to separate YYYY MM to fiscal year -

i have column states month , year yyyy mm . i've separated 2 columns ( year , month ). problem is, year calendar year whereas ideally need fiscal year use ( apr 01 mar 31 - never change). other solutions i've seen based on date format, whereas original column string. i need statement returns fiscal year new year column instead of calendar year. my current statement is: select month, parsename(replace(month,' ','.'),1) monthm, parsename(replace(month,' ','.'),2) year tbltrade which works separate columns. so expected results example: feb 15 becomes feb , 2015. apr 15 becomes apr , 2016. please advise. sql server: declare @date datetime = getdate(); select (year(dateadd(month,-((datepart(month,@date)+5) %12),@date))) financial_year assuming april month 1

wordpress - WP_Query to include all posts from category and also include all private posts (private posts may not be in category that was included) -

i've been struggling wp_query work want to. i want fetch posts category test , fetch posts flagged private, thing posts flagged private may not in category test. i cannot work, i've tried several of queries without luck, latest 1 came closest success one: $args = array( 'post_status' => array('private, publish'), 'relation' => 'or', 'category_name' => 'test' ); this 1 seem fetch posts in test category, posts private , outside test category not displayed. any ideas?

php - I found Error in query when i join with another table -

when join 1 table got error. put keyword not working give me error field not found how can solve error code: product::leftjoin('reviews','products.id','=','reviews.productid') ->select(array('products.*', db::raw('avg(rating) ratings_average') )) ->where(function($query) use ($categoriesid,$brands,$pricearray,$ratingarray) { $query->wherein('categoryid',$categoriesid); if(count($brands) > 0) { $query->wherein('brandid',$brands); } $query->wherebetween('productsellingprice',$pricearray); if(count($ratingarray) > 0) ...

inkscape - Make stroke-width of a SVG path depend on position -

i have big (12 mb) svg file containing many curved paths having same stroke width. i'd transform stroke-width in way depends on mathematical function takes coordinates of path segment (or better: of actual points on path segment) input. the way found far cut paths in segments using inkscape , modifying stroke-width using etree library python. want continuously decreasing/increasing stroke width in inkscapes calligraphy tool.

javascript - Django debug toolbar wrong paths -

Image
i have created django app , deployed server. use django features such django-debug-toolbar installed requirements.txt file using pip . when run app locally, on localhost, works fine , features loaded successfully. here right structure of sources loaded: but when run app server reason paths not correct. and in browser's console these errors: all these paths installed packages django-debug-toolbar , wouldn't make sense change them. example, toolbar.js file loaded command: <script src="{% static 'debug_toolbar/js/toolbar.js' %}"></script> which can found in the: lib/python2.7/site-packages/debug_toolbar/templates/debug_toolbar/base.html file, created after installed packages requirements.txt file. that should work fine. work fine when run locally, doesn't when run on new server. ideas? as mentioned in comments, need call collectstatic when make changes static files. what command copy static files static fold...

linux - How to get the pid of a process started using system call? -

in c program, in main calling system function using system() . want pid of process started system() . there way pid ? no, , in general it's not useful. when call of system() returns program, child process has terminated , been reaped, there's no process (not zombie process) reference. if need start process , retain pid, you'll need fork() child (noting returned value in parent), , in child, exec() command. in parent, have pid, , can use (e.g. in waitpid() ).

c++ - How can one have smartphone/tablet -like GUI on a Raspberry Pi? -

i'm planning of developing application run on raspberry pi 2 equipped touch-screen, , should have , feel of smartphone/tablet application. this means list views , other scrollable widgets should scroll via touch gestures, , not clicking on narrow scroll-bars on side. also, simulation of momentum (widget scrolls little while longer, gradually lower speed, if scrolled fast enough , let go of screen) should applied scrollable items. i prefer develop in c++, , i'm used qt, preferable well. however, qt widgets designed pc in mind, don't scroll hand gestures , have no simulation of momentum. of course, derive own classes qt classes , implement these features myself, simpler if such gui classes existed. you can use qml build gui if want mobile. here , here have how integrate qml c++ objects, can implement logic c++. in qml can use tableview can scroll via touch table.

spring - Deploying dynamically created BPMN model using Activiti REST API -

i new activiti. working on project in should able create process dynamically using spring mvc. have come acrossed http://stacktrace.be/blog/2013/03/dynamic-process-creation-and-deployment-in-100-lines/ is possible deploy dynamically created process using rest api directly or should create bpmn-20.xml , deploy it. there example creating complex process such using boundary events dynamically. thanks it possible through endpoint /activiti-rest/service/deployment ! please check this forum thread further infos + sample code. you not have create file on disk, simulate inputstream of sort: multipartentitybuilder builder = multipartentitybuilder.create(); builder.addbinarybody("deployment", new bytearrayinputstream((<put-something-here>).tobytearray()), contenttype.default_binary,"test.bpmn20.xml")

wordpress - How do I remove a hidden iframe I did not create? -

i scanned 2 wordpress websites using quttera find out if clean. lets call these blogs website1.com , website2.com respectively. found 5 hidden iframes on website1.com: iframe sandbox=\"allow-scripts\" security=\"restricted\" src=\"http:\/\/www.website1.com\/about\/embed\/\" width=\"600\" height=\"338\" title=\"embedded wordpress post\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\" class=\"wp-embedded-content\" iframe sandbox=\"allow-scripts\" security=\"restricted\" src=\"http:\/\/www.website1.com\/contact-us\/embed\/\" width=\"600\" height=\"338\" title=\"embedded wordpress post\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"class=\"wp-embedded-content\" iframe sandbox=\"allow-scripts\" security=\...

java - How to deal with DirectVmConsumerNotAvailableException -

i have camel based application direct-vm routes, directvmconsumernotavailableexception s after redeployment our continuous integration server. redeployment done using karaf 's commands: features:uninstall my-feature/snapshot-version features:removeurl mvn:my-package/my-feature/snapshot-version/xml/features features:addurl mvn:my-package/my-feature/snapshot-version/xml/features features:install my-feature/snapshot-version my feature consists of several bundles, broken direct-vm route between 2 of them. is there way how automatically reconnect from/to direct-vm route? there better way how redeploy camel application? there way how detect broken routes before used? since camel 2.16 there option failifnoconsumers can set false , if ok you, have failing exchanges, appear @ startup, when bundle, defining route not yet loaded, other bundle, using endpoint is. disadvantage is, during normal use, errors not acceptable , need handling. i had same problem once (prior 2.1...

php - Expanding page navigation splitted Query result -

i have results of query getting split pages. done using following code: <?php if (isset($_get["page"])) { $page = $_get["page"]; } else { $page=1; }; $start_from = ($page-1) * 10; $sql = "select * profiles hoofdrubriek = '".$rubriekpage2."' order bedrijfsnaam limit $start_from, 10"; $rs_result = mysql_query($sql); while ($row = mysql_fetch_assoc($rs_result)) { echo result.... } ?> next creating navigation seperate pages: <?php if(mysql_num_rows($rs_result)!=0){ ?> <br /><div style="margin-left:200px;width:300px;text-align:center;background-color:">pagina's:<br clear="left"> <?php $sql = "select count(bedrijfsnaam) profiles hoofdrubriek = '".$rubriekpage2."'"; $rs_result = mysql_query($sql); $row = mysql_fetch_row($rs_result); $total_records = $row[0]; $total_pages = ceil($total_records / 10); if ($tota...

Gunicorn+Django+Heroku. Python Path Issue -

i'm running django app used deploy heroku gunicorn without hitch. mean run foreman start on localhost , able understand whether application work in production environment. made decision move of our project's applications subfolder named 'applications'. meant editing django_settings_module environment variable among other files. after doing this, experimented foreman , gunicorn until got local server , running. @ point deployed production. needless say, there error: running `gunicorn --workers=4 applications.rocketlistings.wsgi -b 0.0.0.0: -k gevent` attached terminal... up, run.8052 traceback (most recent call last): file "/app/.heroku/python/bin/gunicorn", line 9, in <module> load_entry_point('gunicorn==0.17.2', 'console_scripts', 'gunicorn')() file "/app/.heroku/python/lib/python2.7/site-packages/distribute-0.6.34-py2.7.egg/pkg_resources.py", line 343, in load_entry_point return get_distribution(d...

Kendo UI [Grid Sorting] - Disable sorting/filter for individual columns -

i using kendo ui grid table. how can disable sorting " action " column , disable filter " availability " column online demo <th data-field="availability" data-filterable="false" >availability</th> <th data-field="actions" data-sortable="false" >actions</th> demo also check post

c++ - How will the sorting be done with vector<pair<int,pair<int,int>>>? -

in code sort(a.begin(),a.end()); a defined vector<pair<int,pair<int,int>>> a; . if call sort method, on basis sorting done? it compare using operator < std::pair , specified here . it compares elements lexicographically on first element first, , if equal, on second element. given complex type here pair<int,pair<int,int>> , may better idea give std::sort algorithm custom comparator. make sure functor provided fulfils requirements of compare concept, being strict weak ordering .

java - weird Null Pointer Exception -

i trying implement array using 2 stacks named stack , buffer. stack filled random values, myarrayi interface contains 2 functions: getitemat(int index) , setitemat(int index, int item). , implemented in mystackarray class. whenever run program null exception error, have tried trace cause till found stack isn't filled initial data - maybe. whenever try access stack or buffer nullpointerexception error. , when try print elements inside array stack, still silly npe error !!! public class mystackarray implements myarrayi { private int[] buffer; private int[] stack; private int maxsize; public mystackarray(int s){ maxsize = s; int[] buffer = new int [maxsize]; int[] stack = new int [maxsize]; for(int i=0; i<maxsize; i++) stack[i]=i; // initiallizing array random values. } public void print(){ // tried check contents of stack array. for(int i=0; i<maxsize; i++) system.out...