Posts

Showing posts from September, 2013

java - How can I find the target of a Java8 method reference? -

i want capture calls mock object public interface service { public string stringify(object o); } service = mockery.mock(service.class); mockery.allowing(service::stringify).with(42).will(() -> "42"); so inside allowing have function<object, string> is there reflecto-magic let me find service function created method reference? public withclause allowing(function<t,r> f) { object myservicebackagain = findtargetof(function); .... } i know function come these method references, i'm happy down-cast as necessary. this not same question related is possible convert method reference methodhandle? because, start isn't same question, in related area. , if can methodhandle, can't target it. using trick this post can find target. important method below findtarget . turns out, lambdas indeed capture targets, , can access them serializedlambda . however, pretty nasty reflection hack , it's break in future versions. no...

jquery - Apply anchor tag to all the h3 tag under a class -

im trying find way add anchor tag h3 tag.the content dynamic in nature . i want add dynamic anchor tag h3 tags only <div class="class1"> <h2>main heading</h2> <h3>heading1</h3> <h1>some content1</h1> <h3>heading2</h3> <h1>some content2</h1> <h3>heading3</h3> <h1>some content3</h1> </div> i tried below jquery code creating nothing $("h3.class1").append('<h3>'); var al = $("h3.class1 >"); al.append('<a href="#"></a>'); $('div.class1 h3').each(function (){ $(this).wrap('<a />'); });

git pull - Why does git log not show anything new after git fetch? -

i learning working git remotes reading relevant section of pro git book . if clone repository, command automatically adds remote repository under name "origin". so, git fetch origin fetches new work has been pushed server since cloned (or last fetched from) it. it’s important note git fetch command fetches data local repository; doesn’t automatically merge of work or modify you’re working on. have merge manually work when you’re ready. here tried. cloned repository , edited file. in original repository, updated same file , pushed. then, i ran git fetch . showed update progress message. however, git log did not show update. did misunderstand git fetch does? missing something? i ran git pull , , got error: local changes 'hello_world.c' overwritten merge. aborting. please, commit changes or stash them before can merge. here, believe it's merging , avoid accidental data loss, aborts. edit: answers. before looking @ answers, trying mys...

opencv - Capture video using FFmpeg in Android -

i've made simple camera app learn how capture video on android device. clip recorded of mediarecorder library. preview shown in videoview before recording starts, , continues show during actual recording. have understood, recording of videos can done creating intent , calling external activity, result in previous activity paused , destroyed (correct?). anyways, project prefer first approach, not leave activity. unfortunately, experience issues mediarecorder library due known bug (which way seems have been around years). have come across ffmpeg , "touchtorecord" (link below) demo project uses ffmpeg recorder javacv capture videos touching screen. awesome! except not want start camera new activity, in example. want remain in same activity , see preview , record in videoview directly. touch videoview record isn't necessary. think it's possible use same library (javacvvideorecorder), creator of demo project have been using, this? or there better way have not yet...

How to or can I start up virtual host on vmware esxi directly, not from vsphere client? -

now, have installed desktop operating system(as windows 8.1) on vmware esxi, can start directly on vmware esxi, not vsphere client? thanks! of course, can start vm via esxi directly. first, must access ssh esxi host. and start vm vm-cli. refer vm cli document in vmware.com.

javascript - How to Calculate PV and FV Formula in JS? -

i want compute pv , fv in javascript, before working in excel had function pv , fv function did me , i'm searching in javascript please me out if has implemented pv , fv formula in js here fiddle after tried @mariya davydova answer https://jsfiddle.net/46sbsxf6/5/ but geting n.an pv in excel answer 1,982,835.27 <div>rate <input type="text" class="rate" value="0.128/12"/>per <input type="text" class="per" value="63"/>nper <input type="text" class="nper" value="0"/>pmt <input type="text" class="pmt" value="-3872917.00" />fv <input type="text" class="fv" /> </div> <button class="calcpv">calculate pv</button> <button class="calcfv">calculate fv</button> <br/> <input type="text" class="total" placeholder=...

javascript - A 'documentation coverage' of grunt-ngdocs -

to generate documentation of project use ng-docs: https://github.com/m7r/grunt-ngdocs i have report of elements (controllers, directives,...) not yet documented using grunt-ngdocs. ideally report added directly documentation, or in way locate files missing documentation. such grunt task or plugin exist?

All falsey values in JavaScript -

what values in javascript 'falsey' , meaning evaluate false in expressions if(value) , value ? , !value ? there some discussions of purpose of falsey values on stack overflow already , no exhaustive complete answer listing falsey values are. i couldn't find complete list on mdn javascript reference , , surprised find top results when looking complete, authoritative list of falsey values in javascript blog articles, of had obvious omissions (for example, nan ), , none of had format stack overflow's comments or alternative answers added point out quirks, surprises, omissions, mistakes or caveats. so, seemed make sense make one. falsey values in javascript false 0 , -0 "" , '' null undefined nan document.all - weird one, it's falsey object, typeof undefined . microsoft-proprietory function in ie before ie11, , added html spec "willful violation of javascript specification" sites written ie wouldn't break...

How to understand git remote message? -

i have create new local repository (using git init, followed adding , committing files). later added remote repository: $git remote add br /home/user/work/git/bare/ i can see through command git remote -v git fetch br successful when switch repo, gives following message: $ git checkout br/master note: checking out 'br/master'. in 'detached head' state. can around, make experimental changes , commit them, , can discard commits make in state without impacting branches performing checkout. if want create new branch retain commits create, may (now or later) using -b checkout command again. example: git checkout -b new_branch_name head @ a155c68... added makefile.in` i did not understand above text? 'detached head' state? just add: $ git branch * (no branch) master $ i @ no branch, how/why? you checked out commit pointed remote branch (you can list them using git branch -r ). if it’s not pointed local branch, results in deta...

linux - need to one more thing mini length =8 -

this pam file here per-package modules (the "primary" block) password required pam_cracklib.so difok=1 minlen=8 dcredit=-1 ucredit=-1 ocredit=-1 lcredit=0 password [success=1 default=ignore] pam_unix.so use_authtok sha512 here's fallback if no module succeeds password requisite pam_deny.so prime stack positive return value if there isn't 1 already; avoids returning error because nothing sets success code since modules above each jump around password required pam_permit.so and here more per-package modules (the "additional" block) password optional pam_gnome_keyring.so end of pam-auth-update config

android - How can i rotate,zoom and scale multiple Imageview on camera surfaceview -

i using http://judepereira.com/blog/multi-touch-in-android-translate-scale-and-rotate/ link code useful imageview,i want multiple imageview @ time >package logicstree.selfitextcom; import java.io.filenotfoundexception; import java.io.fileoutputstream; import java.io.ioexception; import java.util.arraylist; import android.app.activity; import android.app.dialog; import android.graphics.bitmap; import android.graphics.bitmap.config; import android.graphics.canvas; import android.graphics.color; import android.graphics.matrix; import android.graphics.paint; import android.graphics.pointf; import android.hardware.camera; import android.hardware.camera.picturecallback; import android.hardware.camera.shuttercallback; import android.os.bundle; import android.text.layout.alignment; import android.text.staticlayout; import android.text.textpaint; import android.util.floatmath; import android.util.log; import android.view.motionevent; import android.view.surfaceholder; import android...

html - How to fetch textbox value in radio button value in php -

i have 3 radio buttons in form. 2 of them have static values , 3rd 1 has radio button should have same value number entered in textbox. able fetch first 2 radio buttons values using $_post method on next page 3rd radio button, value null. please me textbox value 3rd radio button. code : <input type="radio" name="radio" value="500000" checked="checked" />purchase more 5 lakhs <input type="radio" name="radio" value="2000000" />purchase more 20 lakhs <input type="radio" name="radio" value="" />purchase more : <input type="text" name="radio" /> if want solve using php, try approach: <input type="radio" name="radio" value="500000" checked="checked" />purchase more 5 lakhs <input type="radio" name="radio" value="2000000" />purchase more 2...

javascript - How to use JQuery UI components in Aurelia getting started app (navigation app) -

i able run aurelia app following steps provided in getting started tutorial. have used bootstrap nav-bar in skeleton application. possible use jquery ui components in aurelia app. if yes, please explain me how achieve this. thanks in advance. yes, it's possible! i've made jqueryui tabs example you: tabs.html <template> <ul> <li repeat.for="tab of tabs"> <a href="${'#' + $parent.id + '-' + $index}">${tab.title}</a> </li> </ul> <div repeat.for="tab of tabs" id="${$parent.id + '-' + $index}"> <p>${tab.text}</p> </div> </template> as can see, i've copied boilerplate html of jqueryui tabs component, , created bindable property tabs which array of objects that: [{title: "", text: ""}] . tabs.js import {bindable, inject} 'aurelia-framework'; import $ ...

mysql - How to write if else condition in sql -

in following sql, how can add if-else control structure. select tblcabbooking.id id, concat(tblcabstatus.`status`,' ', ifnull(concat("(inr",tblbookingcharges.totalbill,")"),'')) `status`, tblcomplaint.id com_id, tblcomplaint.statusid com_status, tblcabbooking.csr_id emp, concat(tblcabbooking.dropaddress,tblcabbooking.droparea) drop_area, tblbookingcharges.totalbill, tblcabbooking.booking_reference ref, tblmasterpackage.master_package booking_type, concat(tblcabbooking.pickupdate," ",tblcabbooking.pickuptime) ordertime, concat(tblclient.clientname," ",tblappid.`type`) partner, concat(tblcablistmgmt.name,', ',tbldriver.firstname,"(",tbldriver.contactno,")") vehicle, concat(tbluserinfo.firstname,"(",tbluserinfo.mobno,")") clientname, concat(tbldriver.firstnam...

ios - Regex for date and replace its occurrence in string using stringByReplacingMatchesInString -

i need regex date this, "dd/mm/yyyy hh:mm:ss pm" , want separate string components using regex match in nsstring . for example if string is, 30/06/15 11:46:37 pm: person1: testing 30/06/15 11:46:40 pm: person1: hello... 30/06/15 11:46:52 pm: person2: hi 30/06/15 11:47:06 pm: person1: how doing and output components in array should be, person1: testing person1: hello... person2: hi person1: how doing you can suggest better idea parse string contains chat text above mentioned. try this, nsstring *string = @"30/06/15 11:46:37 pm: person1: testing 30/06/15 11:46:40 pm: person1: hello... 30/06/15 11:46:52 pm: person2: hi 30/06/15 11:47:06 pm: person1: how doing"; nserror *error = nil; nsregularexpression *regex = [nsregularexpression regularexpressionwithpattern:@"([0-9]{1,2})+\/+([0-9]{1,2})+\/+([0-9]{1,2})+ +([0-9]{1,2})+:+([0-9]{1,2})+:+([0-9]{1,2}) +(am|pm): " options:nsregularexpressioncaseinsensitive error:&error]; nsstring *m...

android - Why using LayoutInflater is not same to xml? -

Image
i created layout <linearlayout android:id="@+id/list" android:layout_width="0dp" android:layout_height="wrap_content" android:orientation="horizontal" android:layout_margintop="10dp" android:layout_marginbottom="20dp" android:layout_weight=".7" > <relativelayout android:layout_width="70dp" android:layout_height="wrap_content"> <imageview android:id="@+id/icon" android:layout_width="50dp" android:layout_height="50dp" android:layout_margintop="10dip" android:layout_marginright="10dip" android:layout_marginleft="10dip" android:src="@mipmap/icon" /> <imageview android:layout_width="wrap_content" android:layout_height="wrap...

Where am I going wrong with Sentinel or break in this Python code -

okay program done keeps running. need figure out sentinel or break needs go. have far in python. program suppose read pres on list , print them. there slice removing first 2 , last two.then prints list size 6 , proceeds give me 6 pres in alpha reverse order. have working other repeating end indefinitely. there has while loop display elements in list returned playlist. pres = ['kennedy','johnson','nixon','ford','carter','reagan',\ 'bush','clinton','bush','obama'] pres2 = pres[2:8] def main(): names in pres: print(names) pr3=playlist(pres2) while playlist !='6': pr3 in pres2: print(pr3) def playlist(pr): size = len(pr) print('list size now', size) pr.sort() pr.reverse() return pr main() now should when run it. kennedy johnson nixon ford carter reagan bush clinton bush obama list size 6 reagan ...

PHP/Jquery - Variable that stores the number of files in a folder and then use it as a loop counter -

short version need creating variable stores number of files in folder , use loop counter. full version: thought found answer here , isn't working me. since don't have enough reputation, can't comment on old thread here am. i created jquery function add images portfolio page. is: $(document).ready(function() { (i = 1; <= 9; i++) { $('.flex-container').append('<aside class="flex-item"><img src="images/portfolio/' + + '.jpg" alt="blah blah"></aside>'); } }); as can see, started 9 images. however, i'd site automatically update when additional images added 'images/portfolio' folder. (images named in numerical order such 1.jpg, 2.jpg, etc.) based on thread linked above, created php file named numberoffiles.php . file contains: <?php return iterator_count(new directoryiterator('../images/portfolio')); ?> (my root directory contains both 'imag...

iphone - IOS: Passing session credentials between app and website -

i doing ios application has uiwebview. user login in ios side passing php api , after login have uiwebview use same credentials. keep user login without asking him credentials. is possible it? yes can store credentials in key chain , in webview can use javascript identify elements (textfields) , populate values accordingly

c# - Invisible differences in XML files - breaking self-made XML parser -

i have 2 programs interact well-defined xml file. first program (model) reads in, parses it, , uses content file direct running of model. second program (controller) opens , rewrites xml file, allowing different settings run in model. model written in c++, worked in vs2010 , vs2012, has no gui, , uses home-made (is correct term?) xml parser has worked many years without fail - checked svn revisions files make - nothing since 2013. controller written in c#, in vs2012, gui has drop downs set content of xml file, , uses xmldocument class read in, edit, , print out xml file . suddenly, controller no longer spits out xml files can read model. when model tries read xml file, first character encounters reads '-17'. far have been able tell means doesn't recognize utf-8 character. cause model cout error , crash. older xml file (which looks identical ones written controller) reads in fine. below examples of files - ignore content inside elements please. of may con...

php - RegExp extract minecraft mod's name -

[17] => link_info-mc1.7.10-0.3.1.litemod [18] => mantle-1.7.10-0.3.2.jar [19] => micdoodlecore-1.7-3.0.11.333.jar [20] => minetweaker3-1.7.10-3.0.9c.jar [21] => modtweaker 2-0.8.0.jar [22] => mousetweaks-2.4.4-mc1.7.10.jar [23] => neiintegration-mc1.7.10-1.0.9.jar [24] => notenoughitems-1.7.10-1.0.5.110-universal.jar i've got of these elements in php array , need extract except: -1.7.10-1.0.5.110-universal.jar so tried use regular expression this: /[\d\-|\.]*\.jar/ but extracts modname string example 2-0.8.0.jar . so need make more flexible. if understand correctly, want match every filename except 1 containing 'universal'. so, can use negative lookbehind pattern this: /[\w\d\-|\._ ]*(?:(?<!universal)(\.jar)|(\.litemod))/ demo: https://regex101.com/r/mi2fm8/3 in case want match name (without version number, ...) should enough: /^[^\- ]+/ demo: https://regex101.com/r/mi2fm8/5

spring - ¿Restful Service opening socket connection and reuses the same connection in all requests? -

i connect transactional server socket server. requirement asked have 1 connection socket, , in same connection transactions sent. i'm working java ee, spring, jboss server. idea create restful service, other applications connect , send transactions. possible open client socket connection, , in same connection open send , receive messages client - server? i have no idea how it, because every time invoke service rest, application attempt create new socket connection server, , not reuse open connection. if want open 1 socket , keep open can use incase have spring 4.0 websockets http://docs.spring.io/spring/docs/current/spring-framework-reference/html/websocket.html using websocket can create 1 tcp/ip connection between client/server , keep open during whole time make bidirectional transactions , being reused transactions want.

mysql - Count 2 columns for occurrence -

so basically, require query return display name, amount of kills , amount of deaths. i have 2 tables need pull from. the 2 tables are player id | name 2334324 | user 4353454 | user2 where id unique identifier , name display name. the second table is: player_kill id | killer | victim | 1 | 2334324 | 4353454 | 2 | 2334324 | 4353454 | 3 | 4353454 | 2334324 | where killer / victim columns contain unique identifier of player table. i'd able count occurrences of player id in killer , victim query returns: name | kills | deaths user | 2 | 1 user2| 1 | 2 where number under kills amount of occurrences playerid has in killer column , same deaths hope provided enough information. what have far: select `player`.`name`, count(distinct `player_kill`.`id`) `kills`, count(distinct `player_kill`.`id`) `deaths` `player` left join `player_kill` on `player`.`id`=`player_kill`.`killer` left join `player_kill` on `player`.`id`=`player_kill`....

How to put css code in php request id? -

i add css code (display:none) against class (rows) in php request id when request id called. can me on this? in particular id no. 434, want add css code against class named "rows". when 434 id called, class named "rows" hidden css code (ex. display:none). how going it. right have done this: <?php if($_request['id']=='434'){ ?> <?php } ?> need kind on this. the page structure going put code following: <?php defined('_jexec') or die; jhtml::_('formbehavior.chosen', 'select'); ?> <div class="search<?php echo $this->pageclass_sfx; ?>"> </div> you can add css definition in html file in case request id equal 434. use !important keyword override css definition in main css file. <html> <head> <link rel="stylesheet" href="yourmainstylesheet.css"/> <?php if($_request['id']=='434'){ ...

erlang - The Server State which error_logger print, is the State when handling "Last message in was"? -

forgive poor english, i mean when gen_server crash, error_logger print "last message in was" , "when server state" , server state value state before handle last message? in gen_server, state stored generic part of code, supposed robust. changed callback functions have return new state value result. when system reports error, state reported 1 passed parameter callback responsible crash.

ios - Custom Edit Buttons to Segmented Control TableViews -

i have tableviewcontroller segmentedcontrol. works great, data show suppose on each tableview , can switch between each segment control. i add swipe delete feature each segmentcontrol's tableview. want segment1 have 1 button, , segment2 have 2 buttons. ex: segment 1 button: more segment 2 button: more button: delete how can this, @ moment keep getting blank space on segment1 crashes app when clicked. there anyway hide blank space/button segment1? override func tableview(tableview: uitableview, editingstyleforrowatindexpath indexpath: nsindexpath) -> uitableviewcelleditingstyle { var table:uitableviewcelleditingstyle = uitableviewcelleditingstyle.none switch (self.segmentcontrol.selectedsegmentindex) { case 0: table = uitableviewcelleditingstyle.delete case 1: table = uitableviewcelleditingstyle.delete default: break } return table } override func tableview(tableview: uitableview, editactionsforro...

android - How to make a button go to another page? -

okay have section_home layout has button code. <button style="?android:attr/buttonstylesmall" android:layout_width="wrap_content" android:layout_height="wrap_content" android:background="@color/transparent" android:text="apply" android:textcolor="@color/white" android:elevation="0dp" android:id="@+id/button" android:layout_aligntop="@+id/linearlayout" android:layout_alignparentleft="true" android:layout_alignparentstart="true" /> what want when click's "apply" button go other layout that's called section_apply <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match...

android - How to get text from EditText within ListView with multiple Views? -

i have listview contains 2 textviews , 1 edittext in each row. have searched , searched , cannot figure out how text user enters edittext. recent attempt implements textwatcher. public void addingredienttomeal(string ingredientname) { ingredient_list = (listview) findviewbyid(r.id.ingredients_in_meal_listview); int numberofingredients = ingredient_list.getchildcount(); listadapter adapter = new listadapter(); adapter.name_array = new string[numberofingredients+1]; (int = 0; < numberofingredients; i++) adapter.name_array[i] = (string) ingredient_list.getitematposition(i); adapter.name_array[numberofingredients] = ingredientname; ingredient_list.setitemscanfocus(true); ingredient_list.setadapter(adapter); } private class listadapter extends baseadapter{ public string[] name_array, qty_array; @override public int getcount() { // todo auto-generated method stub if(name_array != null && name_array.l...

python - Dynamic updating a Matplotlib 3D plot -

i trying update 3d plot using matplotlib. collecting data using ros. want update plot data. have looked around , found this, dynamically updating plot in matplotlib but cannot work. new python , not full understand how works yet. apologize if code disgusting. i keep error. [error] [walltime: 1435801577.604410] bad callback: <function usbl_move @ 0x7f1e45c4c5f0> traceback (most recent call last): file "/opt/ros/indigo/lib/python2.7/dist-packages/rospy/topics.py", line 709, in _invoke_callback cb(msg, cb_args) file "/home/nathaniel/simulation/src/move_videoray/src/move_filtered.py", line 63, in usbl_move if filter(pos.pose.position.x,pos.pose.position.y,current.position.z): file "/home/nathaniel/simulation/src/move_videoray/src/move_filtered.py", line 127, in filter plt.draw() file "/usr/lib/pymodules/python2.7/matplotlib/pyplot.py", line 555, in draw get_current_fig_manager().canvas.draw() file "/usr...

javascript - Creating closures in loops -

this question has answer here: javascript closure inside loops – simple practical example 31 answers i learning closures , have basics on , how work. i got following code mdn , know solution since it's in same article. don't how possible: <p id="help">helpful notes appear here</p> <p>e-mail: <input type="text" id="email" name="email"></p> <p>name: <input type="text" id="name" name="name"></p> <p>age: <input type="text" id="age" name="age"></p> function showhelp(help) { document.getelementbyid('help').innerhtml = help; } function setuphelp() { var helptext = [ {'id': 'email', 'help': 'your e-mail address'}, {'id': 'name...