Posts

Showing posts from April, 2010

linux - How to make a list of files that don't exist from a list of files -

i have text file a.txt contains list of files: photo/a.jpg photo/b.jpg photo/c.jpg etc i want list of files don't exist. you can use: xargs -i % bash -c '[[ ! -e $1 ]] && echo "$1"' _ % < a.txt > b.txt xargs run bash -c each line in a.txt . [[ ! -e $1 ]] check non-presence of each entry.

Ruby map function for "pig latin" -

i attempting write ruby function takes in string of words , turns pig latin . breaking string array, , attempting iterate on each element. when "eat pie" put in, result "eat ie", unsure why. string = "eat pie" array = string.split(" ") array.map |word| if word[0].chr == "a" || word[0].chr == "e" || word[0].chr == "i" || word[0].chr == "o" || word[0].chr == "u" word = word + "ay" elsif word[1].chr == "a" || word[1].chr == "i" || word[1].chr == "o" || word[1].chr == "u" temp = word[0] word[0] = "" word = word + temp word = word + "ay" elsif word[2].chr == "a" || word[2].chr == "i" || word[2].chr == "o" || word[2].chr == "u" temp = word[0] + word[1] word[0] = "" word[0] = "" word = word + temp word = word + "ay" else ## 3 ...

android - Delay by Activity pause timeout for ActivityRecord when starting new activity -

whenever start new activity (even plain, empty one) inside app, see relatively large delay (1 2 seconds). checking logcat see this: // transition currentactivity newactivity 03-01 14:59:00.195: i/activitymanager(515): start {act=android.intent.action.get_content ...} pid 9382 03-01 14:59:00.242: d/newactivity(9382): intent started 03-01 14:59:00.242: d/currentactivity(9382): activity.onpause 03-01 14:59:00.359: d/dalvikvm(515): gc_concurrent freed 824k, 20% free 10419k/12871k, paused 2ms+12ms 03-01 14:59:00.476: i/cat(416): <4>[22335.131317] cpu1: booted secondary processor 03-01 14:59:00.476: i/cat(416): <6>[22335.138885] switched nohz mode on cpu #1 03-01 14:59:00.742: w/activitymanager(515): activity pause timeout activityrecord{4131c158 current-activity} 03-01 14:59:01.179: d/dalvikvm(9382): gc_concurrent freed 1562k, 68% free 10961k/33415k, paused 2ms+6ms 03-01 14:59:01.937: d/newactivity(9382): newactivity.oncreate note works ok, no crashes, weird delay. if pu...

python - Finding and removing vowels in a word: my program does not deliver the consonants -

here program import time print('hello, consonants finder , going find consonants in word') consonants = 'b' 'c' 'd' 'f' 'g' 'h' 'j' 'k' 'l' 'm' 'n' 'p' 'q' 'r' 's' 't' 'v' 'w' 'x' 'y' 'z' word = input('what word: ').lower() time.sleep(1) print('here word/s in consonants') time.sleep(1) print('calculating') time.sleep(1) in word: if == consonants: print((i), ' consonant') here output: hello, consonants finder , going find consonants in word word: hello here word/s in consonants calculating #no output how come output not give consonants this output should be: hello, consonants finder , going find consonants in word word: hello here word/s in consonants calculating hll you list comprehensio...

c# - Wrapping ioc resolve with parameter override -

so, here's problem i'm thinking , use with. firstly, i'm using unity ioc, , want use resolve , produce instances of wrapper sql calls. this, have sqlwrapper implements isqlwrapper. has 2 contructors. here's relevent code snippet. public interface isqlwrapper : idisposable { string commandtext { get; set; } void execute(); } public class sqlwrapper : isqlwrapper, idisposable { public sqlwrapper(string connectionstring); public sqlwrapper(idbconnection sqlconnection); string commandtext { get; set; } void execute(); } obviously isn't complete code, it's illustrate relevent part of implementation. for application, i'm using contructor connectionstring. so, in ioc container, i've registered following... _unitycontainerontainer.registertype<isqlwrapper, sqlwrapper>( new injectionconstructor(typeof(string))); now, things interesting. implement method allow me resolve instance of isqlwrapper. i've boilder...

swift - Parse for iOS - Undefined symbols for architecture i386 - iPhone 4s, iPhone 5 -

i getting few similar undefined symbols architecture i386: ... "_objc_class_$_pfanalytics", referenced from: errors while building iphone 4s simulator or iphone 5 simulator. with iphone 5s-> works great. doing wrong? i have parse , facebook sdk's installed via cocoapods: target 'my app' platform :ios, '8.0' pod 'parse' pod 'fbsdkcorekit' end update 1: i have architectures selected this: //debug, release archs = $(archs_standard) //debug, release valid_archs = arm64 armv7 armv7s i got working of cocoapods community. problem deriveddata. cleaned deriveddata project (in xcode 7, window -> projects) , started working again. more details https://github.com/cocoapods/cocoapods/issues/4736 .

java - JavaFX 2.2 TextField maxlength -

i working javafx 2.2 project , have problem using textfield control. want limit characters users enter each textfield can't find property or maxlength. same problem existing swing , solved this way. how solve javafx 2.2? this better way job on generic text field: public static void addtextlimiter(final textfield tf, final int maxlength) { tf.textproperty().addlistener(new changelistener<string>() { @override public void changed(final observablevalue<? extends string> ov, final string oldvalue, final string newvalue) { if (tf.gettext().length() > maxlength) { string s = tf.gettext().substring(0, maxlength); tf.settext(s); } } }); } works perfectly, except undo bug.

Calculate cumulative binomial probability in R -

i calculate cumulative probability of binomial series: a=choose(5,0)*0.5^0*0.5^5 b=choose(5,1)*0.5^1*0.5^4 c=choose(5,2)*0.5^2*0.5^3 d=choose(5,3)*0.5^3*0.5^2 e=choose(5,4)*0.5^4*0.5^1 f=choose(5,5)*0.5^5*0.5^0 cumulative=sum(a,b,c,d,e,f) is there way single command? for cumulative probability use pbinom : pbinom(0:5,5,0.5) [1] 0.03125 0.18750 0.50000 0.81250 0.96875 1.00000 for individual values, dbinom : dbinom(0:5,5,0.5) [1] 0.03125 0.15625 0.31250 0.31250 0.15625 0.03125 and summing cumulatively use cumsum : cumsum(dbinom(0:5,5,0.5)) [1] 0.03125 0.18750 0.50000 0.81250 0.96875 1.00000

How can I perform an action if a users input is the name of a file in a directory. Python -

i trying make program user can create sets of data, having difficult time figuring out how handle user picking user picking name out of list of files edit or view. here how display files can choose from. how can allow them choose 1 of available files without hardcoding each individual one? available_files = os.listdir('./dsc_saves/') print(available_files) user_input = input('file name: ') what avoid doing following: if user_input == available_files[0]: #do action elif user_input == available_files[1]: #do action 2 elif user_input == available_files[2]: #do action 3 as mentioned, can using in on list of available files follows: available_files = os.listdir('./dsc_saves/') print(available_files) while true: user_input = input('file name: ') if user_input in available_files: break print("you have selected '{}'".format(user_input)) alternatively, make easier type, present user numeric...

jquery - Javascript String replace -

i wanted know how following function in javascript or jquery! there function return following string. have write function convert input given shown below. hello world&nbsp;<img draggable="false" class="emoji" alt="🌞" src="36x36/1f31e.png">&nbsp;how all! ! ! !<img draggable="false" class="emoji" alt="🌻" src="36x36/1f33b.png">&nbsp;all best<img draggable="false" class="emoji" alt="💪" src="36x36/1f4aa.png"> if above string input! want output like hello world&nbsp;1f31e&nbsp;how all! ! ! !1f33b&nbsp;1f4aa how this.. please suggest me best possible way! thank in advance!! you $('body').text() if had no encoded characters unfortunately $.text() automatically decodes them. in order around it, need write custom function. $.fn.gettext = function() { var text = ''; $(this).contents() ...

javascript - Making a D3 widget scrollable -

i'm sticking d3 tree widget web app. grows children , appends them tree. however, when tree gets big, starts go off page. that's fine since don't want individual tree nodes small, nice if add scroll bar. however, i've tried doing normal way, overflow: auto , doesn't work. maybe it's d3 svg stuff. here's code tree 2 nodes: <div id="graph"> <svg width="100%" height="10%" id="svg" overflow="auto" display="block"> <g transform="translate(40,0)"> <path class="link" d="m0,20c213.75,20 213.75,20 427.5,20"></path> <g class="node" transform="translate(427.5,20)"> <circle r="4.5" style="fill: rgb(255, 255, 255);"></circle> <text x="10" dy=".35em" text-anchor="start" style="fill-opacity: 1;">1</text> ...

ios - Animating a UIButton to fullscreen -

Image
so have simple button when clicked goes fullscreen , when clicked again goes same position in. reason works without animation. when uncomment animation part when click button nothing, second time click enlarges. third time click animates it's smaller original size... why animating opposite way? - (ibaction)viewimage1:(id)sender { uibutton *btn = (uibutton*) sender; if (btn.tag == 0) { cgrect r = [[uiscreen mainscreen] bounds]; /*[uiview animatewithduration:0.5f delay:0.0f options:0 animations:^{*/ [sender setframe: r]; /*}completion:nil];*/ btn.tag = 1; } else { btn.tag = 0; [sender setframe:cgrectmake(0,0,370,200)]; } } there 2 solutions problem either of work: disable autolayout. (discouraged) can in interface builder opening file inspector in right pane , unchecking respective check box. however, if want use autolayout constraining other ui elements in view (which quite idea...

javascript - Create a fixed rectangle layer on top of basemap with Leaflet -

Image
i have managed add layer on top of base map , looks this: have made rectangle direct style modifying jquery - width , height , overflow:hidden . not sure it's correct way this, please advise if there better ways. what need when pan map mouse dragging, want top rectangle layer stay in same place content changed respectively rectangle mask on top of basemap. see, panning in leaflet being applied -webkit-transform: translate3d(185px, 178px, 0) (i in chrome) setting top: 0 , left: 0 doesn't , rectangle moves map on panning it's sticked map. i sure dealt same task please advise me. update: have added fiddle illustrates problem better: suggestion #1 you create clip mask , change rect in opposite direction of panning.. something http://jsfiddle.net/gaby/dgwzk/23/ var overlay = { top: 50, left: 50, width: 200, height: 200 } map.on('move', repositionmask) ; map.fire('move'); function repositionmask() { var ...

javascript - When using Jasmine's exceptGET / $httpBackend, what's the benefit of having .respond()? -

i using book called angularjs , running. gives example of using exceptget . example: mockbackend = $httpbackend; mockbackend.exceptget('/api/note') .respond([{id:1, label: 'mock'}]); my question is, isn't point of unittesting server calls make server call , verify server call expect be? with above code, not make server call , force response equal [{id:1, label: 'mock'}] ? what's point of doing if aren't able check actual response is? because later on in code, checks response so: mockbackend.flush(); expect(ctrl.items).toequal([{id:1, label: 'mock'}]); wouldn't equal [{id:1, label: 'mock'}] because that's forced response equal? what's benefit of having .respond() , controlling response? if hit api endpoint on server in unit test, it not unit test anymore - involve more component under test (controller/service/provider etc) - network, web server, backend itself, database etc - becomes integrat...

arrays - Javascript Objects: Using Arguments as object property -

i reimplementing memoize function using arguments object. wondering why work. example, passing in 2 arguments: var args = array.prototype.slice.call(arguments); // input: 1,2 then store args array object. example, var obj = {}; obj[args] = 2; if call object, see as: { 1,2: 2 }/*shows this*/ { [1,2]: 2 }/*but not this*/ not wanted second object, curious happening under hood. call javascript coercion? object property names strings. when do: obj[args] = 2; it treats as obj[args.tostring()] = 2; and tostring() method of arrays equivalent .join(",") , above equivalent to: obj[args.join(",")] = 2; which matches result saw.

logstash nil import errors -

i'm getting errors attempting data import in logstash. i'm seeing every "geo" field have. here of config files input { jdbc { jdbc_driver_library => "c:\binaries\driver\ojdbc6.jar" jdbc_driver_class => "java::oracle.jdbc.driver.oracledriver" jdbc_connection_string => "jdbc:oracle:thin:@random:1521/random" jdbc_user => "user" jdbc_password => "password" statement => "select a.*, myfunc() geo foo a" type => "sometype" } } filter{ if [type] == "sometype" { mutate { rename => { "sometype_id" => "id" } remove_field => ["gdo_geometry"] add_field => [ "display", "%{id}" ] } # parses string json json{ source => "geo" target => ...

DB2 SQL: Grouping records with same id in result? -

if have table 2 columns text | id --------- aaa | 1 bbb | 1 eee | 1 mmm | 2 zzz | 2 ... is possible write query groups id , outputs following result: id | text ------------------ 1 | aaa, bbb, eee 2 | mmm, zzz ... thanks! give try, select id, substr(xmlserialize(xmlagg(xmltext(concat( ', ',text))) varchar(1024)), 3) tablename group id;

osx - MacOS Get default application for file type -

i working on mac app. want use default app icons within app. info.plist , resource folder of app can .icns file , convert image format need. need know default application associated particular file extension, if any. so how default application system associates given file extension? don't go digging in other apps' bundles. it's best work @ level of abstraction suits question want ask. if want icon finder (or mail attachment, etc) display file of particular type, use nsworkspace iconforfiletype: method.

asp.net - Adding an icon to a textbox in mvc5 -

Image
i'm trying add icon text box in mvc5. i'm quite new asp.net , can't figure out how it. use <i class="fa fa-icon"></i> . within input area, have: @html.textboxfor(m=> m.emailaddress, new {@placeholder = "email address"}) any appreciated. if using bootstrap asp.net mvc 5 (which default part of new mvc 5 application), can use bootstraps class achieve that <div class="form-group has-success has-feedback"> @html.textboxfor(m=> m.emailaddress, new {@class="form-control" @placeholder = "email address"}) <span class="glyphicon glyphicon-ok form-control-feedback" aria-hidden="true"></span> </div> this code display success icon text box. below snapshot. for more details on same bootstrap documentation here .

How can I write a vba to delete all x lables for all charts in the spreadsheet? -

i have 7 stacked column charts in 1 tab. want write vba remove vertical labels on left hand side in charts. thought simple it's not! so want "delete x labels" or "remove vertical labels on left hand side"? reads though first referring horizontal x-axis , vertical y-axis - bit confusing. helps if use excel terminology - vertical or horizontal axis. , remove axis, axis title or axis tick labels? that aside... can loop through chart objects in worksheet this: sub loopcharts() dim integer = 1 activesheet.chartobjects.count 'do stuff chart next end sub for example, if want delete vertical axis: sub delvertaxisallcharts() dim integer = 1 activesheet.chartobjects.count activesheet.chartobjects(i).chart.axes(xlvalue).delete next end sub if want remove horizontal tick labels: sub remhorizticklabels() dim integer = 1 activesheet.chartobjects.count activesheet.chartobjects(i).chart.axes(xlcategory).ticklabelposi...

visual studio - Build C++ Universal App from command line without MSBuild -

in same spirit question can download visual c++ command line compiler without visual studio? see if easy bundle appropriate part of visual studio build universal app written in c++ . following answer @alek aforementioned question, managed create an archive can unzip , use. traditional desktop (i say, command-line) programs. tried similar thing universal app , there couple of issues the official way (i.e. visual studio under hood) use msbuild . unfortunately, not know , how of dependencies. seems require significant configuration effort well. there no documentation on how build resources (e.g. generate c++ source , headers xaml), how generate .appx . if possible, makefile template appreciated. the reason ask because visual studio failed me many times. instance, november update messed entire system; sdk installer fail @ 96% , rolled back. previously, upgrade vs2015 (from 2013) messed me entirely. seems solution these problems complete uninstall. having portable archive can ...

ruby - How do I match repeated characters? -

how find repeated characters using regular expression? if have aaabbab , match characters have 3 repetitions: aaa try string.scan(/((.)\2{2,})/).map(&:first) , string string of characters. the way works looks character , captures (the dot), matches repeats of character (the \2 backreference) 2 or more times (the {2,} range means "anywhere between 2 , infinity times"). scan return array of arrays, map first matches out of desired results.

grails - strange behavior for save action -

i have strange behavior domain saving , here domain: class ads { string adtitle string addetails string duration date datecreated static belongsto = [user:users] static constraints = { category (nullable:false) adtitle (nullable:false, maxsize:100 ) addetails(nullable:false, maxsize:500 ) duration (inlist:["7 days", "14 days", "30 days"],nullable:true) } static mapping ={ duration (sqltype:"datetime") } } here save action in controller: @transactional def save(ads adsinstance) { if (adsinstance == null) { notfound() return } if (adsinstance.haserrors()) { respond adsinstance.errors, view:'create' return } adsinstance.user=users.get(springsecurityservice.currentuserid) def adcreationdate = new date() switch (adsinstance.duration) {//here i'm modifying duration case "7 days": adsinstance.duration=adcreationdate...

HTML: how to set background color of item in select element -

how set background color of item in html select list? select.list1 option.option2 { background-color: #007700; } <select class="list1"> <option value="1">option 1</option> <option value="2" class="option2">option 2</option> </select>

What is R's crossproduct function? -

i feel stupid asking, intent of r's crossprod function respect vector inputs? wanted calculate cross-product of 2 vectors in euclidean space , mistakenly tried using crossprod . 1 definition of vector cross-product n = |a|*|b|*sin(theta) theta angle between 2 vectors. (the direction of n perpendicular a-b plane). way calculate n = ax*by - ay*bx . base::crossprod not calculation, , in fact produces vector dot-product of 2 inputs sum(ax*bx, ay*by) . so, can write own vectorxprod(a,b) function, can't figure out crossprod doing in general. see r - compute cross product of vectors (physics) according function in r: crossprod (x,y) = t(x)%*% y faster implementation expression itself. function of 2 matrices, , if have 2 vectors corresponds dot product.

javascript - Pass json data from Google Maps to MVC controller with AJAX -

i want store data addresses , coordinates of markers on map, i'm creating button in infowindow redirect me form on view (also controller). want form filled data coordinates , address. have function called on button click ajax code in send json data method in controller. problem after clicking on button controller method isn't called (although function call works while debugging). i've been searching lot solution, don't know did wrong. call addmarker : google.maps.event.addlistener(marker, 'click', function (event) { if(infowindow) infowindow.close(); infowindow = new google.maps.infowindow({content: data}); infowindow.open(map, marker); var buttonadd = document.getelementbyid('addbutton'); buttonadd.onclick = function() { addmarker(event.latlng, address); } }); js function ajax: function addmarker(location, fulladdress) { var data = j...

html - Will I be able to test this PHP? -

this question has answer here: remote mysql connection in php 2 answers so have 2 websites. 1 hosted on domain , 1 local on computer (viewing using brackets live preview). i used hosted website (#1) create mysql database. then local website (#2) created login page , created index.php document handle submission. in index.php of local website told connect mysql database of hosted website. then when try preview local page , submit it, error "cannot /post?name=johndoe&password=123" so wondering, since sql database hosted online, can test website locally or not? if provider doesn't allow direct access mysql port (usually 3306) outside not able use remote db. i suggest try creating dump of remote db , restore in local instance of mysql. it's better approach develop in local , publish modifications after testing database can modifi...

ios - Bug detection terminal in Swift cites variable as issue - variable doesn't exist -

Image
the first view controller of project crashed when segue'd view controller - not when loads. error message: 2016-01-05 20:06:33.836 collaboration[48812:1788623] -[collaboration.createaccountviewcontroller loginexisting:]: unrecognized selector sent instance 0x796cc950 2016-01-05 20:06:33.849 collaboration[48812:1788623] *** terminating app due uncaught exception 'nsinvalidargumentexception', reason: '-[collaboration.createaccountviewcontroller loginexisting:]: unrecognized selector sent instance 0x796cc950' *** first throw call stack: ( 0 corefoundation 0x00396a14 __exceptionpreprocess + 180 1 libobjc.a.dylib 0x022c5e02 objc_exception_throw + 50 2 corefoundation 0x0039fd63 -[nsobject(nsobject) doesnotrecognizeselector:] + 275 3 corefoundation 0x002dd6bd ___forwarding___ + 1037 4 corefoundation 0x002dd28e _cf_forwarding_prep_0 + 1...

python - Writing tests for file parser functions in a modular way -

i writing piece of python code parses formatted file python object. file can vary, i'm working based off subset of file , hoping tests can me extend of these files. the file consists of header containing metadata, followed several data blocks. [general header, describes length of header 1 & header 2] [header describing data block 1] [header describing data block 2] [data block 1] [data block 2] currently code outlined in following way with datafile open(filename, 'r'): gen_header_obj = parse_gen_header(datafile) header1_obj = parse_header1(datafile, gen_header_obj.header1_len) header2_obj = parse_header2(datafile, gen_header_obj.header2_len) data1_obj = parse_data1(datafile, header1_obj.datalen) data2_obj = parse_data2(datafile, header2_obj.datalen) where each parse*(file) function calls file.readline() several times, depending on size of specified data length. ideally have @ least 5 separate tests, provide fake portion of file , sees...

javascript - Questions about Angular form validation -

trying use ngmessages login page validation. (1) how can make sure error messages(username , password missing) displayed when user click submit button? (2) how block submit button prevent user resubmitting form. thanks to display error message after submitting form, should <div ng-show="theform.login.$error.required && theform.$submitted"></div> and submitting once can counter. here created working plunker . oops, sorry didn`t pay attention using ngmessages, hope still help

r - Adding table to ggplot with facets -

Image
reproducible code: x = sample(1:12,100,replace=true) y = rnorm(100) z = sample(c('sample a','sample b'),100,replace=true) d = data.frame(x,y,z) ggplot(data=d, aes(factor(x),y)) + geom_boxplot() + stat_summary(fun.y=mean, geom="line", aes(group=1), color ='red') + stat_summary(fun.y=mean, geom="point", color='red') + xlab('months') + ylab('metric') + facet_wrap(~z) i want add table @ end of chart displays summary statistics- mean, median, quartiles , number of records each month on x-axis. not sure how possible facet layout. simplified version of chart , there multiple facets working with. thinking along lines of getting statistics stat_summary , can display @ end? maybe need use grid library. here's example: library(ggplot2) x = sample(1:12,100,replace=true) y = rnorm(100) z = sample(c('sample a','sample b'), 100, replace=true) d = data.frame(x,y,z) g1 <- ggplot(data=d, a...

html - Equally distributing height with CSS -

Image
i have html problem pretty tricky , i'm not sure there css-based solution it. have 3 column grid. first , third columns can contain variable number of rows in them. second column has 1 row. each row has minimum height. so column rows have rows height set minimum height. rows in other columns should expand equally in height take remaining space. say column 1 has 3 rows, each 50px tall. column 2 must have 1 row 150px tall. if column 3 has 2 rows must each 75px tall. below pictures further illustrate i'm after. is possible css? if don't mind working in small handful of browsers, can absolutely pure css. go ahead, add , remove many grandchild divs want: http://codepen.io/cimmanon/pen/ldmtj /* line 5, ../sass/test.scss */ .wrapper { display: -webkit-flexbox; display: -ms-flexbox; display: -webkit-flex; } @supports (display: flex) , (flex-wrap: wrap) { /* line 5, ../sass/test.scss */ .wrapper { display: flex; } } /* line 9, ../sass/test....

swift - Xcode "Expected Delcaration","Expression not allowed at the top level" error -

Image
i trying implement nsdatecomponent in viewcontroller.swift file when got "expected declaration" error , "instance member"something" cannot used on type "viewcontroller" so, decided make new .swift file , implement nsdatecomponents there. got "expressions not allowed @ top level" error. from found googling, know should implement in function, not have idea kind of function should wrap into. know why errors in viewcontroller.swift file future reference. thank in advance, , sorry if question duplicate. and here original code let weekbmondaycomponents:nsdatecomponents = nsdatecomponents() weekbmondaycomponents.year = 2016 weekbmondaycomponents.month = 01 weekbmondaycomponents.day = 11 weekbmondaycomponents.hour = 08 weekbmondaycomponents.minute = 39 weekbmondaycomponents.timezone = nstimezone.systemtimezone() let weekbmonday = usercalendar.datefromcomponents(weekbmondaycomponents)! you'll want declare weekbmondaycomponent...

Nested dataTaskWithRequest in Swift tvOS -

i'm c# developer convert swift tvos , starting learn. i've made progress, not sure how handle nested calls json. sources different providers can't combine query. how wait inner request complete tvseries has poster_path? there better way add show collection , process poster path loading in thread doesn't delay ui experience? func downloadtvdata() { let url_btv = nsurl(string: btv_url_base)! let request_btv = nsurlrequest(url: url_btv) let session_btv = nsurlsession.sharedsession() //get series data let task_btr = session_btv.datataskwithrequest(request_btv) { (data_btv, response_btv, error_btv) -> void in if error_btv != nil { print (error_btv?.description) } else { { let dict_btv = try nsjsonserialization.jsonobjectwithdata(data_btv!, options: .allowfragments) as? dictionary<string, anyobject> if let results_btv = dict_btv!["results"] as? [dicti...

javascript - clone div is not displaying same code straight away -

on code have area can preview code typing. problem having when select text , click on button either bold, italic, pre. preview area not display same code straight away. question how can make sure preview area when select text , click on button display correct code below straight away. @ moment displays plain text. live example codepen code view codepen full view script <script type="text/javascript"> $('#code_view').on('click', function(e) { var code = $('#editable').clone(); $('#preview').html(code); }); $('#editable').keyup(function(){ $('#code_view').trigger('click'); }); $('#editable').each(function(){ this.contenteditable = true; }); </script> html <div class="container"> <div class="row"> <div class="col-lg-12 col-md-12 col-sm-12 col-sm-12"> <div class="form-group"> <input type="text...

Android - Signed apk not run in mobile device -

i facing strange problem. when directly copy apk bin folder of project , paste in mobile phone sd card. , install it, working fine. while same export signed apk android tool in project , placed apk in sd card. install not run. not know why happen. progaurad in app. cause of crashing app?? here logcat output > fatal exception: main process: com.globalassignmenthelp, pid: 7708 java.lang.abstractmethoderror: abstract method "android.view.view q.a(android.view.view, java.lang.string, android.content.context, android.util.attributeset)" @ r.oncreateview(unknown source) @ android.support.v4.app.fragmentactivity.oncreateview(unknown source) @ com.globalassignmenthelp.perspective.oncreateview(unknown source) @ android.view.layoutinflater.createviewfromtag(layoutinflater.java:733) @ android.view.layoutinflater.inflate(layoutinflater.java:482) @ android.view.layoutinflater.inflate(layoutinflater.java:414) @ android.view.layoutinflater.inflate(layoutinflater.java:365) @ com.a...

atmega - Using Arduino timers -

i using arduino code generate 5v, 200 khz pulse 50% pulse-width. void setup() { // put setup code here, run once: pinmode(pwmpin, output); pinmode(fbo, input); pinmode(fbi, input); nointerrupts(); // disable interrupts tccr0a = 0; tccr0b = 0; tcnt0 = 0; ocr0a = 40; // compare match register duty cycle * 16mhz/200khz ocr0b = 40; // compare match register 1 - duty cycle * 16mhz/200khz timsk0 |= (1 << ocie0a); // enable timer compare interrupt digitalwrite(pwmpin,high); tccr0b |= (1 << cs00); interrupts(); // enable interrupts } isr(timer0_compa_vect) { digitalwrite(pwmpin, digitalread(pwmpin) ^ 1); //timsk0 |= (1 << ocie0b); // enable timer compare interrupt //timsk0 &= ~(1 << ocie0a); // disable timer compare interrupt } instead of 5v 200 khz pulse, showing me approximately 2v 30 khz signal. can tell me problem is? the problem operating timer/counter0 in normal mode instead of ctc mode. try adding ...

oauth - Google+ unable to insert moment -

trying example g+ documentation authorize requests using oauth 2.0: on . got unauthorized result. here's output: request post https://www.googleapis.com/plus/v1/people/me/moments/vault?debug=true&key={your_api_key} content-type: application/json authorization: bearer *my_token* x-javascript-user-agent: google apis explorer { "target": { "url": "https://developers.google.com/+/web/snippet/examples/thing" }, "type": "http://schemas.google.com/addactivity" } response 401 unauthorized cache-control: private, max-age=0 content-encoding: gzip content-length: 93 content-type: application/json; charset=utf-8 date: fri, 01 mar 2013 18:56:34 gmt expires: fri, 01 mar 2013 18:56:34 gmt server: gse www-authenticate: authsub realm="https://www.google.com/accounts/authsubrequest" allowed-scopes="https://www.googleapis.com/auth/plus.login,https://www.google.com/accounts/oauthlogin" { "er...

javascript - Using KnockoutJS, how to bind data to 2 different <select> tags from the same view model -

i have 2 select tags on view.html so <select id="first" data-bind="options: firstdropdownoptions, optionstext: 'title', value: value"></select> <select id="second" data-bind="options: seconddropdownoptions, optionstext: 'title', value: value"></select> and in viewmodel.js var firstdropdownoptions = ko.observablearray([ { value: -1, title: 'select type' }, { value: 111, title: 'option 1' }, { value: 222, title: 'option 2' }, { value: 333, title: 'option 3' } ]); var seconddropdownoptions = ko.observablearray([ { value: -1, title: 'select type' }, { value: 1, title: 'option new 1' }, { value: 2, title: 'option new 2' }, { value: 3, title: 'option new 3' } ]); i unable bind data both <select> tags. first <select> tag works properly. also, if move #se...

net snmp - Receiving snmptraps in a C program -

i want write c program receives snmptraps sent machine , parses them. able command line, have no idea on how implement in c. i searched online , found code in ruby or atleast c++ had traplistener class. is there way receive snmptraps within c program ? one of best library use net-snmp . supports both c , c++ linkages.

Laravel 5.2 multi tables authentication -

i trying make separated authentication in laravel 5.2 users , admins. for have 2 tables - users , admins. users, working fine. admins table, not working. getting "these credentials not match our records." error. have configured necessary information below. any appreciated. config/auth.php ..... 'guards' => [ 'web' => [ 'driver' => 'session', 'provider' => 'users', ], 'api' => [ 'driver' => 'token', 'provider' => 'users', ], 'admin' => [ 'driver' => 'session', 'provider' => 'admins' ] ], 'providers' => [ 'users' => [ 'driver' => 'eloquent', 'model' => app\models\frontend\user::class, ], 'admins' => [ 'driver' => ...

android - How to make links in textview clickable -

how make links clickable in text view. problem (1). view.setmovementmethod(linkmovementmethod.getinstance()); works when textview contains link(anchor tag/href) this: <a href="http link">go google</a> it does'nt work when textview contains link this: http link (2). while android:autolink="web" works when textview contains link this: http link does'nt work when textview contains link this: <a href="httplink">go google</a> what when textview contains both types of link. please help. try this textview.setonclicklistener(new view.onclicklistener()); in xml: android:clickable="true" or can use string htmltext=html.fromhtml(htmltext) then set htmltext textview textview.settext(htmltext)

java - i want to search strings from domain file in log file...for reading two files i used nested loops...incorrect output -

while((sline= bbr.readline()) != null) { while ((line = br.readline()) != null){ if (line.contains(sline)){ tracker.append(line); tracker.append("\n ");tracker.append("\n "); string track = new string(tracker.tostring()); writetofile(c,track,"trackinginfo.txt"); } }// end of while1 }// end of while2 br.close(); bbr.close(); i use nested loops first reading domain file , second logfile. first string domain file searches whole log file not other strings in domain file.

regex - Capturing a particular character from a string in Perl -

i have file contents this: hfh_f_opl_j0 ;comment1 hij_i_aaa_v2_dsd ;comment2 ale_h_fb_v1 ;comment3 zxzpoif_p ;comment4 rst0drek_s ;comment5 i need match single character, present after first underscore, , 1 of [h, i, f, p, l, s] only . what regex used this? /(\w{3,})_([s|i|p|f|l|h]{1})(.*)\;/ does not give right results. use anchors , change first \w [a-z] because \w should match _ . now, character want group index 1. /^[a-z]{3,}_([sipflh]).*;/ or /^[^_]{3,}_\k[sipflh](?=.*;)/ demo

go - Golang Revel: Paginating a struct array -

i have struct array need paginate on view end. this code looks on view: <div class="tab-content"> <div class="tab-pane active" id="tab1" > <hr/> {{range .c}} <p>number: {{.number}}</p> <p>name: {{.name}}</p> <p>parties: {{.a}} , {{.b}}</p> <p>location: {{.location}}</p> <a href="/search">read more</a> <hr/> {{end}} <div class="paging"> <ul class="pagination"> <li><a href="#"><i class="fa fa-angle-left"></i></a></li> <li class="active"><a href="#">1</a></li> <li><a href="#">2</a></li> <li>...

android - How does the pairing work on Lightsaber Escape work -

how pairing work on this? https://lightsaber.withgoogle.com/ here's example: http://sheav.se/en i want able link mobile app desktop web browser using 4-digit unique pairing code, have no idea google!

c++ - How do inherited classes access data stored in a base class container? -

i'm trying access data base class container multiple inherited classes. i've looked other stackoverflow questions on either static vectors , shared_ptr or unique_ptr i'm not sure these best way forward (and i'm unfamiliar how implement shared_ptr or unique_ptr). please see code below. class event { public: event(){} virtual ~event(){} std::vector<int>& testdata() {return test;} // return reference. private: std::vector<int>test; }; class inheritedevent1 : public event { public: void firstmethod(void); }; class inheritedevent2 : public event { public: void secondmethod (void); }; void inheritedevent1::firstmethod(void){ testdata().push_back(1); // insert data event vector. std::cout << "firstmethod: size " << testdata().size() << std::endl; } void inheritedevent2::secondmethod(void){ std::cout << "secondmethod: size " << testdata().size() << std::endl; } int main() { inherited...

I want to format SQL result in to given format in SQL Server -

sql result: id student_name class ---------------------- 1 abc 1a 2 xyz 1a 3 dsk 1a 4 uij 1a ................. ................. ................. ................. ................. 1000 results i want format data in specific format id1 student_name1 class1 id2 student_name2 class2 id3 student_name3 class3 ----------------------------------------------------------------------------------- 1 abc 1a 2 abc 1a 3 abc 1a 4 abc 1a 5 abc 1a 6 abc 1a 7 abc 1a as comment says, question isn't clear, wrote query think need ... try out , let me know if wanted if object_id('tempdb..#temp') not null drop table #temp create table #temp (id int, student_name nvarchar(100), class nvarchar(10)) insert #temp (id, student_name, class) values (1, 'abc', '1a'), (2, 'xyz', '1a'), (3, 'dsk', ...

how to get diffrent data from single column in mysql and php -

i want store multiple data comma separated in single column , data of php in different different line in column view looks this-- toothbrush-1234,glass-1234, in there 1234 product id want data in php separated values each line details. <?php $sql="select product_name form products product_id=1234" ?> so possible data , separat - , , single column. you want display comma separated data separate rows. can try this. <? //here complete example of code using mysqli object oriented: $servername = "localhost"; $username = "username"; $password = "password"; $dbname = "mydb"; // create connection $conn = new mysqli($servername, $username, $password, $dbname); // check connection if ($conn->connect_error) { die("connection failed: " . $conn->connect_error); } $sql = "select product_id,product_name form products product_id=1234"; $result = $conn->query($sql); if ($result->num...

scope - Node.js variables scoping in debugger -

var foo = 0, bar = 0 process.nexttick(function() { debugger }) entering node repl using node debug , , trying print variables, found foo , bar can not accessed either: referenceerror: foo not defined var foo = 0, bar = 0 process.nexttick(function() { console.log(foo) }) process.nexttick(function() { debugger }) but somehow 'access' foo async callback function, became visible, print bar still raises referenceerror . is v8 jit or node implementing details? there seems nothing wrong code, not sure how used debugger try node-inspector better debugging experience. you can use console.log current scope value. same example in browser environment. var foo = 0, bar = 0 window.settimeout(function() { console.log(foo, bar); }, 0);

Swift - Convolution with Accelerate Framework -

i'm trying 1d convolution accelerate framework. i can make work seems goes wrong after few experiments. here code: import accelerate var n = 10000 var m = 10 var convn = n + m - 1 var xf = [float](count:n, repeatedvalue:0.0) var yf = [float](count:m, repeatedvalue:0.0) in 0..<n { xf[i] = float(i+1) } in 0..<m { yf[i] = float(i+1) } var outputf = [float](count:convn, repeatedvalue:0.0) // padding 0 xf = [float](count:convn-n, repeatedvalue:0.0) + xf var ptr_xf = unsafepointer<float>(xf) var ptr_yf = unsafepointer<float>(yf).advancedby(yf.count-1) vdsp_conv(ptr_xf, 1, ptr_yf, -1, &outputf, 1, vdsp_length(convn), vdsp_length(m)) print("[float]: \(outputf)") i compile , run different n , m . then check result result python package numpy . sometime looks great sometime give me weird result like: ( n =6, m =3) correct: [1.0, 4.0, 10.0, 16.0, 22.0, 28.0, 27.0, 18.0] result get: [1.0, 4.0, 10.0, 16.0, 22.0, 28.0, 2.23692...