Posts

Showing posts from July, 2012

Making cmake library accessible by other cmake packages automatically -

i have 1 project produces library: project (mycoollibrary) add_library(my_cool_library shared ${mysources_src}) and project should using library: find_package (mycoollibrary required) include_directories("${mycoollibrary_include_dirs}" ) add_executable(mycoolexe ${my_sources_src} ) target_link_libraries(mycoolexe ${mycoollibrary_libraries} ) is there way can change first file second file works automatically? running cmake on first file , running make on output, running cmake on second file, cmake able find package? an answer give address of first project built second package acceptable. turning comment answer taking code found in blog post @daniperez - use cmake-enabled libraries in cmake project (iii) - i've come following minimal solution: mycoollibrary/cmakelists.txt cmake_minimum_required(version 3.3) project(mycoollibrary) function(my_export_target _target _include_dir) file( write "${cmake_current_binary_dir}/${_targ

Mergesort implementation in C -

can please check mergesort code. when tried sorting input values, sorted array contained random values weren't input. , not sorted. way i'm declaring array within while loop correct? #include <stdio.h> void merge (int a[], int aux[], int lo, int mid, int hi){ for(int y=lo; y<=hi; y++){ aux[y]=a[y]; } int i=lo; int j=mid+1; for(int k=lo;k<=mid;k++){ if (j>hi) a[k]=aux[i++]; else if (i>mid) a[k]=aux[j++]; else if (a[j]<a[i]) a[k]= aux[j++]; else a[k]=aux[i++]; } return; } void sort (int b[],int aux[], int lo, int hi) { if(hi<=lo) return; int mid= lo+(hi-lo)/2; sort(b, aux, mid+1, hi); sort(b, aux, lo, mid); merge(b,aux,lo,mid,hi); return; } int main(void) { int t,n; long long int sum; scanf("%d",&t); while(t--){ sum=0; scanf("%d",&n); int w[n]; int m[n]; int g[n]; int h[n]; (int i=0; i

javascript - Using moment.js, JS, or Jquery, turn on a feature within a time frame -

i'm trying write code reliably show div between times. i'm using moment.js , claim in docs can can't find proper way query times need. my code give idea of want doesn't work because when try turn on or off feature, if time goes before midnight, end negative numbers instead of time. (i using utc times , subtracting 10 hours. can use negative numbers in arrays clarity, i'd stick actual times as possible.) also, way code now, can turn off feature @ time turning off after time better, having on between times best. would guys know how query moment( ).isafter or .isbetween time rather dates? so far i've tried many permutations of: moment().isbetween('7:00:00', '8:00:00', 'hour', 'minute'); , .isafter. the docs don't seem have examples , no 1 on web has posed question in past. thanks! var opensun = [6,7,17,22]; // on hours // sundays ---------------------------------------------- // // setup sunday - on if (mome

shell - tab autocomplete on python script execution in console -

i'm having "issue" (for lack of better word), whenever run python script arguments, can't use tab completion function of unix consoles. example when want put file in script execution. hope examples illustrate better issue. case 1 >python3 script.py [tab] folder/ folder1/ data.dat case 2 >python3 script.py -f d [tab] folder/ folder1/ (file data.dat not showing) ideal case >python3 script.py -f data.dat - n 2 .... hope made myself clear, , can explain me, i'm guessing python won't allow this, or needs configured in someway. i'm using argparse in script usual code.. ap.add_argument('-f', '--file', type=str, action='store', help='input file.',metavar='file') i've tried type=argparse.filetype('r') same. i want achieve because of files i'm working have long names, , requested not write files names every time. anyway, reading. ok, work around this. usin

javascript - Get every element with a specific (data-) attribute in CasperJS -

i'm trying test page using casperjs. there possibilities every element (paragraphs) contains attribute data-...? after that, need compare attribute inner html, don't know how it. first need retrieve representations of of elements you're interested in. can done casper.getelementsinfo(selector) : var elements = casper.getelementsinfo("p[data-whatever]"); this give <p> elements on page have data-whatever attribute set. if want filter values of data-whatever attributes, need use attribute selectors according needs. the getelementsinfo() function contains useful information, doesn't contain actual elements want use. contains representation array. you can iterate on element representations , run operations on them. said want "compare attribute inner html" . can done in way: elements.foreach(function(element){ if (element.attributes["data-whatever"] === element.html) { casper.echo("data attribute

html - CSS unable to un-skew text issue -

i attempting create skewed links straightened text. unable un-skew text despite ton of tinkering. here html code using: <div class="menu"> <div class="row"> <div class="col-md-6"> <h1>photography</h1> </div> <div class="col-md-6"> <ul> <li class="skew"><a class="skew-fix">work</a></li> <li class="skew"><a class="skew-fix">shop</a></li> <li class="skew"><a class="skew-fix">contact</a></li> </ul> </div> </div> </div> and here css: .menu { height: 90px; border-bottom: 1px solid black; padding: 0 50px; } .menu h1 { line-height: 90px; margin: 0; } .skew { margin: 5px 0; display: inline-block;

amazon web services - 'aws configure' in docker container will not use environment variables or config files -

so have docker container running jenkins , ec2 registry on aws. have jenkins push containers ec2 registry. to this, able automate aws configure , get login steps on container startup. figured able export aws_access_key_id=* export aws_secret_access_key=* export aws_default_region=us-east-1 export aws_default_output=json which expected cause aws configure complete automatically, did not work. tried creating configs per aws docs , repeating process, did not work. tried using aws configure set no luck. i'm going bonkers here, doing wrong? no real need issue aws configure instead long populate env vars export aws_access_key_id=aaaa export aws_secret_access_key=bbbb ... export zone , region then issue $(aws ecr get-login --region ${aws_region} ) you achieve same desired aws login status ... far troubleshooting suggest remote login running container instance using docker exec -ti container bash then manually issue above aws related commands interac

jquery - javascript to print a specific div -

i got code site print div: function printdata() { var divtoprint=document.getelementbyid("printtable"); newwin= window.open(""); newwin.document.write(divtoprint.outerhtml); newwin.print(); newwin.close(); } $('button').on('click',function(){ printdata(); }) how add css code javascript apply table id='table' ? table, td, th { border: 1px solid black; text-align:justify; } th { background-color: #7a7878; text-align:center } please have at: http://jsfiddle.net/rhjv1u11/ function printdata() { var divtoprint=document.getelementbyid("printtable"); newwin= window.open(""); newwin.document.write(divtoprint.outerhtml); var css =`table, td, th { border: 1px solid black; text-align:justify; } th { background-color: #7a7878; text-align:center }`; var div = $("<div />", { html: '&shy;<

mongodb - Getting Node.js up and running - DB connection errors -

i'm super new node.js, basic question, happening when console telling me error: unable connect database @ mongodb://localhost/realjoet-me-development i'm running environment using swig, sass, node, express, gulp, nodemon , yeoman. i have db set on heroku mongolab add-on. what causing error causes app crash can't view on localhost?? what more need know better understand situation?? here's entire console log ➜ realjoet.me git:(master) ✗ gulp [06:50:13] using gulpfile ~/sites/realjoet.me/gulpfile.js [06:50:13] starting 'sass'... [06:50:13] starting 'develop'... [06:50:13] finished 'develop' after 6.51 ms [06:50:13] starting 'watch'... [06:50:13] finished 'watch' after 9.09 ms [06:50:13] [nodemon] 1.8.0 [06:50:13] [nodemon] restart @ time, enter `rs` [06:50:13] [nodemon] watching: *.* [06:50:13] [nodemon] starting `node app.js` [06:50:13] /users/realjoet/sites/realjoet.me/public/css/style.css reloaded. [06:50:13] fi

Calculate effects using delta method in R -

i have written code calculate effects using delta method in r i have dataframe dpcp variables x1 , x2 , x3 , x4 , matrix of 1000 draws multivariate normal, m4[1000,4] . this code calculates effects, takes long run. how can run faster: n = nrow(dpcp) (i in 1: n) { (j in 1: 1000) { marg_effects[i, j] = (m4[j, 1] * dpcp[i, ] $x1) + (m4[j, 2] * dpcp[i, ] $x2)+ (m4[j, 3] * dpcp[i, ] $x3) + (m4[j, 4] * dpcp[i, ] $x4) } } the code takes upwards of 5 hours 2000 observations. you may want check this out first. however, speed computation, use matrix multiplication instead of looping marg_effects <- as.matrix(dpcp) %*% t(m4) the %*% operator matrix multiplication , t() function transpose m4 hope helps.

Android implementation of tutorial screen -

Image
i'm planning implement tutorial screen android app. plan tutorial screen looks like: there several screens , can swipe between than. every view has custom design. there dots represents every screen, , show page watching now. need good-looking transition adequate animations. screen full screen activity. i have found several image galery, don't want slide between images, need slide between views. i not need code this. need instruction in way can done, , elements need use in order achieve targeted design. thanks in advance. you'll want use viewpager in conjunction fragments, instructions on android developer's website .

javascript - How do I add a button to activate Annyang JS? -

sorry noob question js skills extremely limited. implementing annyang webpage. loads page, prefer add button activate it. here's have far: <script> if (annyang) { // let's define command. var commands = { 'hello': function() { alert('hello, can speak navigate around website. try saying "contact"'); }, 'goodbye': function() { alert('goodbye!'); }, 'contact': function() { window.location.href='../contact-us/'; }, }; // add our commands annyang annyang.addcommands(commands); // start listening. annyang.start(); } </script> <button class="btn btn-secondary-alt view-more" onclick="annyang.start();">speak now</button> thanks in advance help just remove annyang.start() in script. line calls when annyang ready.

winforms - Visual Studio c# Key press enter not working -

hey guys i've been struggling code ! did research , don't understand why code isn't working... please ! private void checkenter(object sender, system.windows.forms.keypresseventargs e) { if (e.keychar == (char)13) { debug.writeline("it's working!"); enterkey = true; } else { enterkey = false; } } private void textbox_textchanged(object sender, textchangedeventargs e) { debug.writeline("the text changing"); if (enterkey == true) { encryptkey = encryptintextbox.text; debug.writeline("the key " + encryptkey); } } apparently can't change 'textchangedevenargs' because of how text box created, whenever change it, comes error. so, decided way, ! why don't check enter key directly textbox keypress or keyup event?

ios - SWIFT 2 - Impossibile to pass value from UICollectionViewController to UICollectionViewCell. Found NIL -

i trying pass value uicollectionviewcontroller uicollectionviewcell . have created custom uicollectionviewcell connected cellview in storyboard. have created uilabel iboutlet. when try send value uicollectionviewcell class error: fatal error: unexpectedly found nil while unwrapping optional value which coming line: videocell.nameusrvideo.text = "test" also cannot see object had in cell any idea why? uicollectionviewcontroller: override func viewdidload() { super.viewdidload() collectionview!.registerclass(videocellclass.self, forcellwithreuseidentifier: "videocell") } override func collectionview(collectionview: uicollectionview, cellforitematindexpath indexpath: nsindexpath) -> uicollectionviewcell { let videocell = collectionview.dequeuereusablecellwithreuseidentifier("videocell", forindexpath: indexpath) as! videocellclass videocell.nameusrvideo.text = "test" return vi

c# - Sync conflict handling in Azure Mobile Services: ad hoc vs sync handler -

when not using "sync handler", 1 needs catch sync errors push , pull. push: samples catch mobileserviceinvalidoperationexception , mobileservicepushfailedexception , exception : try { await client.synccontext.pushasync(); } catch (mobileserviceinvalidoperationexception ex) { // ...push failed // ...do manual conflict resolution } catch (mobileservicepushfailedexception ex) { // ...push failed // ...do manual conflict resolution } catch (exception ex) { // ...some other failure } pull: samples catch mobileserviceinvalidoperationexception , exception : try { await synctable.pullasync("allitems", synctable.createquery()); } catch (mobileserviceinvalidoperationexception ex) { // ...pull failed } catch (exception ex) { // ...some other failure } sync handler: errors processed in .executetableoperationasync() . samples catch mobileserviceconflictexception , mobileservicepreconditionfailedexception , exception . finally questi

php - PHPUnit fatal error call to undefined method on mock -

i want test method on object called. want making mock of object , rather specific class. following code throws fatal error: class mytest extends phpunit_framework_testcase { public function testsomemethodiscalled() { $mock = $this->getmock('object'); $mock->expects($this->once()) ->method('somemethod'); $mock->somemethod(); } } the above dies error: fatal error: call undefined method mock_object_204ac105::somemethod() i'm sure there way this, without having write class has somemethod() method? you must set array of methods should available in mock when create via $this->getmock() , code should work: $mock = $this->getmock('object', ['somemethod']);

c# - How to center the image jpg in the preview window? -

when printing jpg images have problem. when displayed in preview window image not centered. how center image jpg in preview window? private void printjpg_click(object sender, eventargs e) { photo = image.fromfile(@"c:\...\Рисунок.jpg"); printdocument printdoc = new printdocument(); printdoc.printpage += new printpageeventhandler(printdocument1_printpage); printpreviewdialog dlg = new printpreviewdialog(); dlg.height = 1000; dlg.width = 1000; dlg.document = printdoc; dlg.showdialog(); } private void printdocument1_printpage(object sender, system.drawing.printing.printpageeventargs e) { graphics g = e.graphics; g.pageunit = graphicsunit.inch; graphics gg = graphics.fromimage(photo); rectanglef marginbounds = e.marginbounds; if (!printdocument1.printcontroller.ispreview) marginbounds.offset(-e.pagesettings.hardmarginx, -e.pagesettings.hardmarginy); float x = marginbounds.x / 100f + (marginbounds.

java - error acessing WSDL from browser -

i have web service code (first time) troubleshooting. not able test web service on browser using url. see operations on browser when click on them throwing 404 error. the link next them not right. know coming server-config.wsdd file. don't know how wsdd got geerated in first palce.not sure need changed resolve 404 error. on clicking on web service url, see below message http//localhost:8080/testws/empdeptwebservice and services adminservice(wsdl) version(wsdl) empdeptwebservice(wsdl-http//localhost:8080/testws/services/empdeptwebservice?wsdl) none of wsdl links work. there no services folder? not sure how generating url.

javascript - I keep getting Error: $injector:modulerr Module Error with AngularJS. -

i trying teach myself angular , keep getting error. wrote simple bit of code test out angular while following tutorial , keep getting error , angular not doing it's supposed do. angular.min.js:6uncaught error: [$injector:modulerr] http://errors.angularjs.org/1.5.7/$injector/modulerr? 0%20%20at%20c%20(http%3a%2f%2f127.0.0.1%3a8080%2fangular.min.js%3a20%3a359)(anonymous function) @ angular.min.js:6(anonymous function) @ angular.min.js:40r @ angular.min.js:7g @ angular.min.js:39db @ angular.min.js:43c @ angular.min.js:20bc @ angular.min.js:21ge @ angular.min.js:19(anonymous function) @ angular.min.js:315b @ angular.min.js:189sf @ angular.min.js:37d @ angular.min.js:36 this code <!doctype html> <html ng-app='store'> <head> <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" /> </head> <body> <script type

xamarin.android - xamarin android Google maps exception when closing page with map -

i have exception in xamarin forms – in android – when closing custom map. i rendering in android , once every 5~ times exception when closing page google maps the exception follows: unhandled exception: system.notsupportedexception: unable activate instance of type xamarin.forms.maps.android.maprenderer native handle b250001d ---> system.missingmethodexception: no constructor found xamarin.forms.maps.android.maprenderer::.ctor(system.intptr, android.runtime.jnihandleownership) ---> java.interop.javalocationexception: exception of type 'java.interop.javalocationexception' thrown i saw post in stack overflow: error when navigating away page map on android, while on-screen keyboard visible and tried create constructor this: public custommaprenderer(intptr javareference, jnihandleownership jnihandleownership) : base(javareference, jnihandleownership) { } but compilation error: 'maprenderer' not contain constructor takes 2 arguments what er

ios - Buttons & Switches -

this question has answer here: uiswitch doesn't send valuechanged event when changed programmatically 1 answer i have switch thats prints "its on" when on , "its off" when off. since want have more switches in future, decided wanted have button acts general, therefore when press button, switch sets on, problem is, doesn't print "its on". essentially if directly click switch, supposed to; if change switch's status through button, doesn't, switches on, , doesn't print anything. button code: @ibaction func button(sender: uibutton) { self.sswitch.seton(true, animated: false) } switch code: @ibaction func switch(sender: uiswitch) { if self.sswitch.on { print("its on") } else { print("its off") } this expected situation. if user trigg

ruby on rails - I can't save two datetimes at the same time -

i'm trying submit form , have of data save database, 1 column not saved. have form set start_at datetime , and end_at datetime. when click create button appears both pieces of data being sent, 1 being saved database. @ first neither save, , don't know i've done 1 save. i'm using rails 4.2.5.1, ruby 2.3, postgres 9.3, simple_form , bootstrap3-datetimepicker. below code related issue, if able figure out i'm doing wrong i'd appreciate help. _form.html.erb <div class="form-group"> <%= simple_form_for shallow_args(current_user, @image) |f| %> <%= render 'shared/error_messages', object: f.object %> <%= f.label :file %><br> <%= f.attachment_field :file, direct: true %> <div class="row"> <%= f.collection_check_boxes :category_ids, category.all, :id, :name |cb| %> <% cb.label(class: "checkbox-inline input_checkbox") {cb.chec

imagemagick - Manipulating .gif animation with wand -

i'm working wand frame-by-frame translation of gif. want transpose image each frame of gif, save output animated gif. def placeimage(gif_name, image_name, save_location): image(filename = gif_name) gif: image(filename = image_name) image: new_frames = [] frame_orig in gif_new.sequence: frame = frame_orig.clone() drawing() draw: draw.composite(operator='src_over', left=20, top=20, width=image.width, height=image.height, image=image) draw(frame) new_frames.append(frame) so i've got of these frames (though they're not singleimage objects, image objects) i'd put , generate new gif. advice? i'd able like: with gif.clone() output: output.sequence=new_frames output.save(filename=save_location) i answered similar here: resizing gifs wand + imagemagick with image() dst_image: image(filename=src_path) src_image: frame in src_image.sequence:

javascript - Can't get webpack hot middleware working with react/redux -

im pulling out hairs trying hot reloading working. project loads when run node server.js files not being hot reloaded. server.js // webpack stuff var webpack = require("webpack"); var webpackdevmiddleware = require("webpack-dev-middleware"); var webpackhotmiddleware = require("webpack-hot-middleware"); var config = require("./webpack.config"); var compiler = webpack(config); // email template var emailtemplate = require("./emailtemplate"); // express var express = require("express"); var app = express(); var crypto = require("crypto"); var bodyparser = require("body-parser"); var cookieparser = require("cookie-parser"); var port = 8000; app.use(webpackdevmiddleware(compiler, { noinfo: true, publicpath: config.output.publicpath })); app.use(webpackhotmiddleware(compiler)); app.use(express.static(__dirname + "/src")); app.use(bodyparser.urlencoded({ extended: false })); app.us

python - Query in pandas for closest object (in time) which meets a set of conditions -

i using pandas manage set of files have several properties: import pandas pd data = {'objtype' : ['bias', 'bias', 'flat', 'flat', 'stdstar', 'flat', 'arc', 'target1', 'arc', 'flat', 'flat', 'flat', 'bias', 'bias'], 'ut' : pd.date_range("11:00", "12:05", freq="5min").values, 'position' : ['p0', 'p0', 'p0', 'p0', 'p1', 'p1','p1', 'p2','p2','p2', 'p0', 'p0', 'p0', 'p0']} df = pd.dataframe(data=data) which gives me dataframe one: objtype position ut 0 bias p0 2016-07-15 11:00:00 1 bias p0 2016-07-15 11:05:00 2 flat p0 2016-07-15 11:10:00 3 flat p0 2016-07-15 11:15:00 4 stdstar p1 2016-07-15 11:20:00 5

ios - How to only allow certain URLs in app -

is there way allow app load urls? thinking there exception domains in app transport security settings, except not allowing arbitrary loads url, rather allow urls , block others, whether or not https/http. thanks you can use in appdelegate: optional func application(_ app: uiapplication, openurl url: nsurl, options options: [string : anyobject]) -> bool { //return true or false depending on if want //this application open url. } in comments mention using in single uiwebview. in case can following: func webview(webview: uiwebview, shouldstartloadwithrequest request: nsurlrequest, navigationtype: uiwebviewnavigationtype) -> bool { let url = request.url return handlerequest(url) } @available(ios 8.0, *) func webview(webview: wkwebview, decidepolicyfornavigationaction navigationaction: wknavigationaction, decisionhandler: (wknavigationactionpolicy) -> void) { let request = navigationaction.request; let url

statsmodels - How exactly BIC in Augmented Dickey–Fuller test work in Python? -

this question on augmented dickey–fuller test implementation in statsmodels.tsa.stattools python library - adfuller(). in principle, aic , bic supposed compute information criterion set of available models , pick best (the 1 lowest information loss). but how operate in context of augmented dickey–fuller? the thing don't get: i've set maxlag=30, bic chose lags=5 informational criterion. i've set maxlag=40 - bic still chooses lags=5 information criterion have changed! why in world information criterion same number of lags differ maxlag changed? sometimes leads change of choice of model, when bic switches lags=5 lags=4 when maxlag changed 20 30, makes no sense lag=4 available. when request automatic lag selection in adfulller, function needs compare models given maxlag lags. comparison need use same observations models. because lagged observations enter regressor matrix loose observations initial conditions corresponding largest lag included. as consequ

c - "Alarm clock" message on linux -

i'm working on project written in c , i'm using alarms. in beginning of code use sigaction() initialize alarm: struct sigaction sa; sa.sa_handler = alarm_handler; sigaction(sigalrm, &sa, null); then call alarm alarm() function in loop: while(){ alarm(myseconds); } the program sends first alarm , runs handler function, when sends second 1 message appears on output stream: "alarm clock" i don't know why keeps happening. thank you. you leave variables of struct sigaction uninitialized, need struct sigaction sa; memset(&sa, 0, sizeof sa); sa.sa_handler = alarm_handler; note alarm documentation says if calling alarm() again before current alarm has expired: " in event set alarm() canceled.". calling millions of times second in loop not idea, you're resetting alarm.

ruby - Rails 4 Strong parameters for associated model -

i have users model in rails4 application , have defined def user_params params.require(:user).permit(:email) end but storing users address in separate address table , filling email , address both single form how add address parameters in users strong parameters permit method. like so: def user_params params.require(:user).permit(:email, address: [:address_attribute]) end take @ this post, think pretty @ explaining strong parameters.

c# - Customizing buttons in windows forms -

Image
where can customized buttons free download can used winforms? using c# (visual studio) desktop applications , aim create looking ui. i looking looking next, buttons etc. edit 1: for e.g ms access have following button previous .what equivalent windows form. use bindingnavigator you can put bindingnavigator component on form. can customize colors using custom color tables render in office style. can find famous color tables here in toolstrip customizer . use button png image visual studio image library you can download visual studio image library , use standard visual studio png images on buttons. in above picture, top component bindingnavigator , other components buttons standard icons visual studio image library . you can inherit button , override onpaint , draw button background using pathgradientbrush or lineargradientbrush have vista style glass buttons. can find example here .

c++ - Using binary search to find k-th largest number in n*m multiplication table -

so, trying solve problem: http://codeforces.com/contest/448/problem/d bizon champion isn't charming, smart. while of learning multiplication table, bizon champion had fun in own manner. bizon champion painted n × m multiplication table, element on intersection of i-th row , j-th column equals i·j (the rows , columns of table numbered starting 1). asked: number in table k-th largest number? bizon champion answered correctly , immediately. can repeat success? consider given multiplication table. if write out n·m numbers table in non-decreasing order, k-th number write out called k-th largest number. input single line contains integers n, m , k (1 ≤ n, m ≤ 5·105; 1 ≤ k ≤ n·m). output print k-th largest number in n × m multiplication table. what did was, applied binary search 1 n*m looking number has k elements less it. this, made following code: using namespace std; #define ll long long #define pb push_back #define mp make_pair ll n,m; int f (int val); int min (int

c# - Hide header Checkbox in DatagridView -

i have requirement in need have checkbox columns in first column of datagaridview. when add checkbox , adds same in header of teh same column well. header checkbox not required me. want hide out. not able achieve this. haev tried cell painitng technique not working out me :(.. pls help ckbox = new checkbox(); ckbox.size = new size(14, 14); //get column header cell bounds rectangle rect = dgv_courselist.getcelldisplayrectangle(0,-1, true); point opoint = new point(); opoint.x = rect.location.x + 3; opoint.y = rect.location.y + 2; //check cells of first column , header if (this.dgv_courselist.columns[0].index == e.columnindex && e.rowindex < 0) { // can change e.cellstyle.backcolor color.gray example using (brush backcolorbrush = new solidbrush(e.cellstyle.

ember.js - Ember 2: How to add custom jQuery -

where following go? $('a').click(function() { $('html, body').animate({ scrolltop: $($.attr(this, 'href')).offset().top }, 500); return false; }); i'm working in rails environment ember frontend inside rails app. tried in ember vendor's folder , called import in ember-cli-build.js, , when go test it, nothing works. missing step? when add app.import on ember-cli-build.js make code part of vendor.js file. vendor.js file downloaded , executed (to knowledge) before application available. meaning templates not rendered time code executed, , $('a') return empty list (hence why it's not working). if want believe may need event delegation, this: $( "body" ).on( "click", "a", function() { $('html, body').animate({ scrolltop: $($.attr(this, 'href')).offset().top }, 500); return false; }); so delegate click events a links when available in app. the embe

html - bootstrap row pseudo elements usage -

im wondering , dont know answer bootstrap grid row using display:table , content:"" pseudo elements(after , before) . why using display table there . .row:after,.row:before{ display:table; } can explain why using ? .row:before, .row:after { display: table; } this supported browsers except ie(6/7). generates pseudo-element before , after content of element contains floats. setting display: table creates anonymous table-cell , new block formatting context. acts prevent top-margin collapse , improve consistency between modern browsers , ie(6/7).

java - Improving context-based search -

i looking @ possibility of implementing context-based search single word using wordnet. idea this: the user searches virus, should return contexts / applications of searched word, in our case health , computing. user selects context, retrieves meaning based on context selected. have been checking @ possibility of using wordnet seems wordnet not have capability. looked @ word sense disambiguation sentence not word. how achieve this? there dictionary capable of achieving this? idea on other work around ? disambiguation big computational problem. if you're willing relatively simple point babelnet , babelfy . the first 1 huge encyclopedic dictionary, second disambiguation system developed babelnet team. with babelnet have several metadata word categories , have java api. maybe can work out of it. also, recommend try several text analytics software meaningcloud

websocket - (Go) Comparing everchanging variable in ws loop -

working on loop receives messages , processes them accordingly, websocket echo-er keep-alives , authentication, , i've been stuck in keep-alive part little while now. the concept simple, when server starts create goroutine ticker, , initialize uint64 pointer, each time ticker ticks (every 2 seconds), increment pointer atomic.adduint64(clockticks, 1), each websocket connection goroutine, check variable every tick compare , atomic.loaduint64(clockticks), , send ping/pong message. edit: seems blocking loop until message received, result: i := atomic.loaduint64(clockticks) if != cur { cur = if act != true { fmt.println("quit nao u filthy bot.") return } else { fmt.println("keep going.") act = false } } in snippet, := atomic.loaduint64(clockticks) & if block runs when message sent (prints "keep going." on msg), not want, want snippet run every iteration,

javascript - Best (most performant) way to declare (class) properties with unknown values in v8 -

so learned bit hidden class concept in v8. said should declare properties in constructor (if using prototype based "pseudo classes") , should not delete them or add new ones outside of constructor. far, good. 1) properties know type (that shouldn't change) not (initial) value ? for example, sufficient this: var foo = function () { this.mystring; this.mynumber; } ... , assign concrete values later on, or better assign "bogus" value upfront, this: var foo = function () { this.mystring = ""; this.mynumber = 0; } 2) thing objects. know object wont have fixed structure, want use hash map. there (non verbose) way tell compiler want use way, isn't optimized (and deopted later on)? update thanks input! after reading comments (and more on internet) consider these points "best practices": do define all properties of class in constructor (also applies defining simple objects) you have assign something the

Fullcalendar + Private google calendar -

i m using full calendar web app project , sync google calendar of client, moment public calendar. is there way sync private calendar ? note : use 0auth identify , sync google account. thanks i think work private calendar using correct authorization. authorizing requests oauth 2.0 all requests google calendar api must authorized authenticated user. here sample create alexandre : <script type="text/javascript"> var clientid = '<your-client-id>'; var apikey = '<your-api-key>'; var scopes = 'https://www.googleapis.com/auth/calendar'; function handleclientload() { gapi.client.setapikey(apikey); window.settimeout(checkauth,1); } function checkauth() { gapi.auth.authorize({client_id: clientid, scope: scopes, immediate: true}, handleauthresult); } function handleaut

interprocess - C++ Using files / semaphors to lock step processes / overhead-should I do this at all -

i have process a. has various scripts s1, s2, s3, s4, s5. previously process merely calls script functions. s1->tick(currenttime). however, standardize sandboxing of these scripts , move them external processes. my question is: what best portable c++ (linux/osx/win32) method signal subprocesses new tick dataset available. what best portable c++ way make data available. for instance, perhaps write data shared memory area (writable primary process) , have sub processes read memory area? would faster having sort inter process communication?

angularjs - DataSnapshot.val() doesn't return processed value immediately -

this method within factory: kbuser.getcurrentuserdetails = function(){ return $rootscope.ref.child("user/" + firebase.auth().currentuser.uid).once('value', function(snap){ return snap.val(); }); } i call method in controller this: return kbuser.getcurrentuserdetails().then(function(details){ // here need .val() once again (var attrname in details.val()) { kbuser.userobject.details[attrname] = details.val()[attrname]; } kbuser.copyfirebasedatatouser(firebaseuser).then(function(){ return true; }); }); this returned: details = w {a: p, w: u, g: ve} , doesn't correspond database. when read details variable here, have details.val() again expected json object database. don't why result of snap.val() isn't returned in method, 'raw' firebase datasnapshot snap . know why occurs? assume factory setup correctly. basically need use chain promise when snap.val() gets return can data in it.

oracle11g - How to put 2 rows returned from a query into into 2 columns of a single row in Oracle sql -

i run query returns 2 rows select table-a condition=something; row1 value1 row2 value2 now, want put in new table in 2 columns of single row select column1, column2 table-b condition=something; row1 column1 column2 value1 value2 can please me this? it unclear how want pick row goes column - here couple of options: select min( ) minimum_value, max( ) maximum_value table_a 1=1; or select max( ) keep ( dense_rank first order rownum ) first_value, max( ) keep ( dense_rank last order rownum ) last_value table_a 1=1; or select * ( select a, rownum rn table_a 1=1 ) pivot ( max(a) rn in ( 1 first_value, 2 second_value ) );

javascript - How to debug SystemJS ENOENT no such error error in Webpack 2.x? -

Image
after upgrading webpack 2.x i'm getting error during compilation , re-compilation (in hmr mode): (systemjs) error: enoent: no such file or directory, open ... have found way fix that? here source code: https://github.com/kriasoft/react-static-boilerplate/tree/webpack2 (see pr #102 )

c# 4.0 - In C#, Excel cell's custom date format not working with EPPlus -

Image
i'm having trouble excel's custom format using epplus. here's code: var destfile = new fileinfo(@"c:\temp\test1.xlsx"); var filename = "test1"; using (excelpackage pck = new excelpackage(destfile)) { pck.workbook.worksheets.add(filename); // create worksheet in package pck.workbook.worksheets[filename].cells["a2"].value = datetime.now.tostring("mm/dd/yyyy hh:mm:ss"); pck.workbook.worksheets[filename].cells["a2"].style.numberformat.format = "d-mmm-yy"; pck.save(); } i'm getting following: the custom format showed right, value in cell doesn't display format needed. here's i'm trying get: note: need full date value datetime.now.tostring("mm/dd/yyyy hh:mm:ss") other files, custom format need file. what need change work? thanks @paullabbott, here's correct answer: pck.workbook.worksheets[filename].cells["a2"].value = datetime.now;

java - Elasticsearch return nested objects without their parents -

i have index looks this: { "mappings":{ "authors":{ "properties":{ "books":{ "type":"nested", "properties":{ "title":{"type":"string"}, "firstsentence":{"type":"string"}, "isbn":{"type":"string"}, "publishdate":{"type":"date"}, } }, "firstname":{"type":"string"}, "lastname":{"type":"string"}, "birthday":{"type":"date"}, } } } i querying index through java client. query, don't care authors; want books. instance, find

java - Major Concurrency Issue -

i have looked around cannot find decent answer issue having. have list being modified , read keep getting concurrency issues. note: there 2 threads pull data list. issues pop on doentitytick() , getentity() . note: doentitytick issues caused me adding entity list. world: package unnamedrpg.world; import java.awt.rectangle; import java.util.arraylist; import java.util.collection; import java.util.collections; import java.util.iterator; import unnamedrpg.player.game.gamemanager; import unnamedrpg.world.entity.entity; import unnamedrpg.world.entity.entitycharacter; import unnamedrpg.world.entity.entityliving; import unnamedrpg.world.entity.entityprojectile; public class world { private string name; private arraylist<boundary> boundlist = new arraylist<boundary>(); private collection<entity> entitylist = collections.synchronizedlist(new arraylist<entity>()); public world(string name){ setname(name); } public string ge

oop - PHP Have Object Return Different Object -

in few different places call: $model=new makecall($form); i have updated makecall class several changes want take affect after given date. renamed original class makecallold how can leave calls to: $model=new makecall($form); intact , within makecall this: class makecall { ... public function __construct($form) { //use legacy makecallold stuff before 2016-10-01 if ($form['date']<'2016-10-01') { $object=new makecallold($form); return $object; } $this->perform several functions , set variables... this returns empty object of class makecallold not appear run constructor in makecallold properties empty. entire object of makecallold dropped $model . what need static factory constructor. way should doing add initialization logic or switch constructors depending on argument. class makecall { public function __construct($form) { $this->form = $form;

How to define/process NiFi FlowFile content without a schema? -

i have been experimenting nifi (via hortonworks hdf) , can't grasp seems basic. start file..i want filter records based on value (e.g., field number 2 contains "xyz")...then write matching records hdfs. i have non-filtered flow working can't find docs or examples showing how apply schema (or in way understand "content") of file. what missing? (i have seen references flowfiles being "schema-less" - not sure how useful). for example, file this: [app1][field1][field2] [app2][field1][field2] [app2][field1][field2][field3] [app3][field1] i want filter select records containing "[app2]" , create hdfs file looks this: field1,field2 field1,field2,field3

process - Sending characters using pipes in C -

i trying send string parent process child process using pipes in c programming language, works correctly, receive incomplete string without first character. wrong in code? thank you. #include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <sys/wait.h> #include <string.h> int main(int argc, char** args) { int pid, p[2]; int status = -100; char input[100]; char inputbuffer[100]; if(pipe(p) == -1) { return -1; } if((pid = fork())<0) { printf("error\n"); } else { if(pid==0) { close(p[1]); while(1) { if(!read(p[0],&inputbuffer,1)) { close(p[0]); break; } else { read(p[0],&inputbuffer,100); } } printf("received: %s\n&qu

javascript - Google Maps API Directions Service Displaying Text Directions Repeating -

Image
i'm using google maps javascript api display routes , text directions: js: var geocoder; var map; var search_lat; var search_lng; function initmap() { var mylatlng = { lat: 38.5803844, lng: -121.50024189999999 }; map = new google.maps.map(document.getelementbyid('map'), { zoom: 16, center: mylatlng, }); geocoder = new google.maps.geocoder(); document.getelementbyid('search_button').addeventlistener('click', function() { getdirectionsbyaddress(geocoder, map); }); var locations = <?php echo json_encode($locations_array); ?>; var infowindow = new google.maps.infowindow(); var marker, i; (i = 0; < locations.length; i++) { marker = new google.maps.marker({ position: new google.maps.latlng(locations[i][5], locations[i][6]), animation: google.maps.animation.drop, icon: icon_image, map: map });