Posts

Showing posts from April, 2015

sql - Esqueleto count inside select -

i have following entities : group name text groupuser user userid group groupid and query this: select g.* /* g */ , count(gu.id) groupuserscount group g left outer join groupuser gu on gu.groupid = g.id group g.id can done esqueleto ? the esqueleto docs groupby contain examples of how use it. moreover, reading through getting started section, you'll see several example of queries including equivalent of table.* : do people <- select $ $ \person -> return person putting 2 means should work: select $ \(g `leftouterjoin` gh) -> on (gu ^. groupid ==. g ^. id) groupby (g ^. id) return (g, countrows)

javascript - 401 unauthorized except through browser -

i've been trying html request, using url works in browser somehow results in 401 unauthorized error when run code. problem did provide authentication; url of form http://username:password@url?param=value it succeeds in firefox , chrome (i went through incognito mode avoid cookies), google's postman app, despite trying several other http request methods return unauthorized error. i've run through rest api , xmlhttprequest, command line. any ideas on causing this? or, better, if someone's had similar problem , has solution? (note: i'm pretty new whole thing, not sure if clear/detailed enough. i'll best elaborate if needs.) edit: here's idea of original code running: var func = function() { var options = { baseurl: server, uri: '/device.cgi', qs: { param1: value1, param2: value2 } }; request(options, function(err, response, body) { if (err) console.log(err); else console.log(body); }); };

javascript - How to make SmoothScroll for website pages? -

i developing website , have question. customer wants make more smooth scrolling on site. example, browser chrome, has special extension smoothscroll . prompt me if there similar website, can script or library? as far question can offer check repo here: smooth scrolling you can declare step, speed, ease, targets...it pretty library :) , have browser , os detection functionality

asp.net mvc - Adding value to a list of item in a class c# -

below 3 methods, public class abcorder { public items items { get; set; } } public class item { public string orderrefno { get; set; } public string sku { get; set; } public string qty { get; set; } } public class items { public list<item> item { get; set; } } now want assign below, abcorder.items.item.add(new item { orderrefno = "12345", sku = "sk8765", qty = 3 }); but getting items null in abcorder.items .please help. first, don't understand why have items class. why not make abcorder class have list property? but problem never initialized objects. can't use object if never created it. easiest way in class constructor, this. public class abcorder { public abcorder() { items = new items(); } public items items { get; set; } } public class items { public items() { item = new list<item>();

javascript - Setting mock location from Cordova Android -

is there way set mock location coordinates cordova? perhaps there plugin this? i developed app needed mock location, , lot of testing using localhost in iis before testing on device or emulator. global variable _testlocalhost = true i have function called isrunninglocalhost() , check anytime if need mock data. have use similar technique when testing on published apps.

javascript - d3 pie chart not displaying all labels -

Image
i trying simple pie chart labels inside slices. can display labels not all. e.g. in sample code have rick 5%, paul 4% , steve 3% not displayed because of small size of slices. how can overcome problem? <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title>testing pie chart</title> <!--<script type="text/javascript" src="d3/d3.v2.js"></script>--> <script src="../js/d3.min.js" type="text/javascript"></script> <style type="text/css"> #piechart { position:absolute; top:10px; left:10px; width:400px; height: 400px; } #linechart { position:absolute; top:10px; left:410px; height: 150px; } #barchart { position:absolute;

javascript - how to determine if gulp watch is running -

i run gulp on server in background running gulp & but fail down. mi question is: there command gulp ask if running. gulp status thanks there nothing special in gulp limit running multiple processes or alert running gulp process. use regular unix techniques check if process running. use supervisor supervisord or runit automatically restart processes. #the program pidof set variable $? either #1 or 0 in bash depending on if finds process #with name. print out matching #process ids command line pidof gulp echo $? #1 if there no process called gulp #0 if there process called gulp if pidof gulp; echo 'gulp alive'; else echo 'we need support on here!' ./node_modules/.bin/gulp watch & sleep 3 fi

c - Using `const` breaks program -

Image
i wrote small test program using sdl 2.0 , opengl 1.1, , ran strange problem: making variables const breaks program! can explain why happens? code static float vertexes[] = { // static uint8_t colors[] = { static float vertexes[] = { // no problem static const uint8_t colors[] = { static const float vertexes[] = { // bad static const uint8_t colors[] = { static const float vertexes[] = { // bad static uint8_t colors[] = { respective screenshots full (working) program this program gives desired behaviour. comment out const s view broken versions. // gcc -o main main.c -std=c11 -pedantic -wall -i. -lm -lmingw32 -lsdl2main -lsdl2 -lopengl32 -lglu32 -mwindows #include <sdl.h> #include <gl/gl.h> #include <gl/glu.h> #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #define arraysize(arr) (sizeof(arr) / sizeof(*arr)) typedef struct { float x; float y; float z; } vec3; bool running; int width, height; sdl_wi

c# - How to record listened key strokes as string? -

i'm listening key events global hook setwindowshookex . lets assume user types a , b , c , backspace , , d . sequence results string abd . there easy way convert sequence of key strokes resulting string in text area? i'm thinking redirecting these strokes hidden text area pinvoke function setforegroundwindow seems tricky , slows down system considerably. what simple way of doing this?

php - str_replace is not working properly -

hi im gonna trying add x,y location static google maps image location string is $googlemapstatic="http://maps.googleapis.com/maps/api/staticmap?center=(location)&zoom=7&size=1000x1000&markers=color%3ablue|label%3as|11211&sensor=false&markers=size:mid|color:0x000000|label:1|(location)"; and have x , y latitude , longitude $koorx='32.323213123'; $koory='39.3213'; and im using str replace changing static maps location , marker inside it. $newlocation=$koorx.','.$koory; $googlemapstatic=str_replace('location',$newlocation,$googlemapstatic); but shows me different location input. <img style='width:15.61cm; height:12.0cm' src=".$googlemapstatic.'> if write x,y manually browser, show correct location. assume there mistake in str_replace function couldn't find it. use ini_set('display_errors','on'); error_reporting(e_all); if deprecated kind of error try us

c# - Page_Load is called when leaving page -

i have master page , 2 web pages, webform1 , webform2. on master page there 2 linkbuttons in order go webform1 or webform2. when click on linkbutton go webform1 page_load event handler webform1 called , page.ispostback == false. far good. then when click go webform2 happens: a) page_load event handler webform1 called again , page.ispostback == true. b) page_load event handler webform2 called , page_load == false. vice versa when going webform1. why page_load webform1 called when i'm going webform2? loading webform2 , not webform1. for pages: autoeventwireup="true". <form id="form1" runat="server"> <div> <p>this mysite.master.</p> <p> <asp:linkbutton id="goto1" runat="server" onclick="goto1_click">go webform1</asp:linkbutton> </p> <p> <asp:linkbutton id="goto2" runat="server" onclick="goto2_clic

c# - ASP.NET MVC6 localizable DisplayAttribute -

i wonder if there possibility use ihtmllocalizer asp.net mvc6 directly poco classes? have few viewmodels uses displayattribute in order display translated string in views , validator, requires create additional static class each static property defined (unfortunately static indexers not possible in c#). there better way done? my current code: [display(name = "trackingdevice", resourcetype = typeof(testresource))] public string trackingdevice { get; set; } public class testresource { public static string trackingdevice { { //here call ihtmllocalizer via iservicelocator return "field name"; } } } i have struggled bit , succeeded in compiling working solution question. @szymon sasin answer, although not working against latest version , configuration partial, helped me build solution. first, configure localization @ startup.cs: public class startup { public void configureservices(ise

string - Split rows according to text in two columns (Python, Pandas) -

this dataframe (with many more letters , length of ~35.5k) , stuff – other relevant strings). variables strings , ['c1','c2'] multiindex. tmp c1 c2 c3 c4 c5 start end c8 1 - - - 12 14 - 2 - - - 1,4,7 3,6,10 - 3 - - - 16,19 17,21 - 4 - - - 22 24 - i need become (split every row contains commas maintaining else): c1 c2 c3 c4 c5 start end c8 appearance 1 - - - 12 14 - 1 2 - - - 1 3 - 1 2 - - - 4 6 - 2 2 - - - 7 10 - 3 3 - - - 16 17 - 1 3 - - - 19 21 - 2 4 - - - 22 24 - 1 i tried script pandas: how split text in column multiple rows? as s = tmp['start'].str.split(',')

java - mapping two fields from one table on to other -

i have these 2 tables users( id pk, name varchar(30) ); the other table is orders( id pk, orderby fk users.id, orderto fk users.id ); now, want create orders entity class maps orderby , orderto user. thing confuse cascading should use. class orders{ /// @manytoone(fetch = fetchtype.lazy @joincolumn(name="orderby") users orderby; /// @manytoone(fetch = fetchtype.lazy @joincolumn(name="orderto") users orderto; } i thinking create 2 fields in users table such that class account{ /// @onetomany(fetch = fetchtype.lazy) @joincolumn(name="orderto") list<orders> ordersreceived; /// @onetomany(fetch = fetchtype.lazy) @joincolumn(name="orderbo") list<orders> ordersplaced; } but again, not sure cascading shall use. users table populated other processes orders has nothing with. don't want when placing order, particular transaction should add/dele

javascript - Event binding on dynamically created elements? -

i have bit of code looping through select boxes on page , binding .hover event them bit of twiddling width on mouse on/off . this happens on page ready , works fine. the problem have select boxes add via ajax or dom after initial loop won't have event bound. i have found plugin ( jquery live query plugin ), before add 5k pages plugin, want see if knows way this, either jquery directly or option. as of jquery 1.7 should use jquery.fn.on : $(staticancestors).on(eventname, dynamicchild, function() {}); prior this , recommended approach use live() : $(selector).live( eventname, function(){} ); however, live() deprecated in 1.7 in favour of on() , , removed in 1.9. live() signature: $(selector).live( eventname, function(){} ); ... can replaced following on() signature: $(document).on( eventname, selector, function(){} ); for example, if page dynamically creating elements class name dosomething bind event parent exists, document . $(document

java - android setVisibility sometimes works sometimes not -

im having trouble setvisibility when app goes background , bring foreground after setvisibility(view.visible) not work correctly have socket private emitter.listener onnewrequest = new emitter.listener() { @override public void call(final object... args) { mainmapactivity.this.runonuithread(new runnable() { @override public void run() { jsonobject objectrequet = (jsonobject) args[0]; setcomponentvisible(); } }); } }; and function is public void setcomponentvisible() { runonuithread(new runnable() { @override public void run() { llacceptreject.setvisibility(view.visible); llacceptreject.requestlayout(); lluserdetailview.setvisibility(view.visible); lluserdetailview.requestlayout(); } }); playbeep(); phelper.putjsonstring(requeststr); phelper.putpending(true); starttimerrem

msbuild - Why does visual studio 2013 produces build errors with no error list after adding an RDLC file? -

i have wpf project uses mahapps metro ui in visual studio 2013. added rdlc file used report when tried build project, visual studio says has build errors , error list shows nothing. when delete rdlc file, project builds successfully. tried set build output's verbosity detailed , shows following: 1>target "preparerdlfiles" in file "c:\program files (x86)\msbuild\microsoft\visualstudio\v12.0\reportingservices\microsoft.reportingservices.targets" project "c:\users\eloj\documents\visual studio 2013\projects\simapplication\mahapps.metro.application1\simapplication.csproj" (target "compilerdlfiles" depends on it): 1>task "createitem" skipped, due false condition; ('%(extension)'=='.rdlc') evaluated ('.resources'=='.rdlc'). 1>task "createitem" 1>done executing task "createitem". 1>task "createitem" skipped, due false condition; ('%(exte

clojure - doseq should be giving me side effects so why does it work with dorun only? -

i wrote simple program takes number n , list input. , prints each element in list n times. i tried this (defn list-repl [num lst] (doseq [elem lst] (map println (repeat num elem)))) this didn't work. no output. while looking @ docs found dorun . tried , did work. (defn list-repl [num lst] (doseq [elem lst] (dorun (map println (repeat num elem))))) reading documentation understand doseq looping construct forces side-effects in body-expression. dorun directly sequences. is understanding correct? if correct body in first example should have given me side effect of printing number. did not happen. missing in understanding? basically, doseq can't force every side effect in body. in order guarantee have recursively check every expression in body lazy subcomputations force, be... challenging. deals top-level expressions. forcing lazy subcomputations job of expressions' writer. if need several layers of looping "unpack" members of

javascript - Error handling and status codes with knex in koa -

i'm experimenting koa , knex build restful web service, , while got basics working i'm stuck @ handling errors. i'm using koa-knex-middleware wraps knex in generator. i have following code defines happens , post requests particular resource: var koa = require('koa'); var koabody = require('koa-body')(); var router = require('koa-router')(); var app = koa(); var knex = require('./koa-knex'); app.use(knex({ client: 'sqlite3', connection: { filename: "./src/server/devdb.sqlite" } })); router .get('/equipment', function *(next){ this.body = yield this.knex('equipment'); }) .post('/equipment', koabody, function *(next){ this.body = yield this.knex('equipment').insert(this.request.body) }); app.use(router.routes()).use(router.allowedmethods()); app.listen(4000); this works in general, can't manage change http status codes. examp

asp.net - Control [...] of type [...] must be placed inside a form tag with runat=server - but already is -

asp.net says asp:button needs inside <form runat="server" . inside form. why still wrong? default.aspx: <%@ page language="c#" autoeventwireup="true" codefile="default.aspx.cs" inherits="_default" %> <!doctype html> <html> <head> <title>test case</title> </head> <body> <asp:placeholder runat="server" id="ph"/> <form runat="server"> <asp:button runat="server" text="foobar"/> </form> </body> </html> default.aspx.cs: using system; using system.web.ui.webcontrols; public partial class _default : system.web.ui.page { protected void page_load(object sender, eventargs e) { ph.controls.add(new button()); } } error message: control 'ctl02' of type 'button' must placed inside form tag

haskell - Parsing several Yaml documents in one file using Data.Yaml -

starting code in answer , have working parses list of todo task items in yaml file. but if ever add second document: data.yaml.decode no longer decodes anything, , returns nothing . like this: --- - name: > test task state: finished - name: > second test task state: todo --- - name: noname state: nostate so wondering if possible @ use documents feature of yaml, when parsing data.yaml ? or doing wrong ? this code: {-# language overloadedstrings #-} import data.yaml import control.applicative -- <$>, <*> import data.maybe (fromjust) import qualified data.bytestring.char8 bs data task = task { name :: string, state :: string } deriving (show) instance fromjson task parsejson (object v) = task <$> v .: "name" <*> v .: "state" -- non-object value of wrong type, fail. parsejs

apache spark - How to specify multiple python files in a PySpark application? -

i have pyspark app (one python file) something. submitting app spark using spark-submit , passing dependencies , jars manually (i not building uber jar). but python file big , difficult manage, split multiple .py files under 1 package (working in pycharm). how specify these files @ spark-submit let know these files make application? thanks in advance!

Minimizing over the minimum of a function in linear programming -

how can minimize function, contains inner minimum. below example. understand can start defining new variable x4=min(c1*x1, c2*x2, c3*x3) , add new constraints x4<=c1*x1, x4<=c2*x2, x4<=c3*c3 . not correct because x4 smaller terms above not minimum of them(actually x4 smaller minimum satisfy constraints above). how should reformulate make correct? thank you. minimize (c1 * x1) + (c2 * x2) + (c3 * x3) + (c4 * min(c1*x1, c2*x2, c3*x3)) subject #some arbitrary linear constraints: x1 >= ... x1 + 2*x2 <= ... x3 >= ... x1 + x3 == ...

Association information not being displayed in Rails 4? -

the current_user has 1 quiz has questions 1 through 5, entered here: <%= form_for @quiz |f| %> <div class="field"> <!-- question 1 name --> <%= f.label :q1, "what first question?", :class => "edit_labels", :maxlength => 10 %> <%= f.text_field :q1, :placeholder => "question 1", :style => "text-align: center" %> </div> ,,,, created in controller takes place def landing @quiz = quiz.new end in quizzes controller: def edit @quiz = quiz.find(params:[id]) end def create @quiz = current_user.build_quiz(quiz_params) if @quiz.save flash[:success] = "updated" redirect_to '/' else render 'new' end end def quiz_params params.require(:quiz).permit(:q1, :q2, :q3, :q4, :q5) end def show @quizzes = quiz.all end now, when try display users: /users/index.html.erb <%= render @users %>

ruby on rails - SendGrid not Preserving ActionMailer Template -

i have rails 4 app on heroku uses sendgrid. created mailer shows digest of user's recent social media posts using twitter's oembed api. problem is, when send message , view in inbox, it's plain text , social media posts missing. not that, none of styling persisted. what know how preserve template generated mailer user gets nicely formatted html email. here current sendgrid seetings: actionmailer::base.smtp_settings = { :address => 'smtp.sendgrid.net', :port => '587', :authentication => :plain, :user_name => env['sendgrid_username'], :password => env['sendgrid_password'], :domain => 'heroku.com', :enable_starttls_auto => true } i'll post mailer code well, don't know if it's relevant issue. other mailers plain text messages. <!doctype html> <html> <head> <meta content='text/html; charset=utf-8' http-equiv=

file - Update image path in CKEditor after being received from FileManager -

Image
i using ckeditor fileman file manager handeling file uploads. works fine on local host , there small problem on production environment haven't been able solve playing around configuration. i'm able upload, edit, delete , select files in fileman seen in next picture. however, after select file (a picture) example, file path returned in format of: /www/path/to/image.jpg. . the problem "www" part of path not visible online , right path returned editor should /path/to/image.jpg . example of path returned fileman: does know how force ckeditor or fileman use publicly visible directory structure? thank you! there multiple solutions problem: set following properties according documentation: files_root , return_url_prefix not recommended: create soft link www folder (on linux example ln -s /www /www/www) the second solution lead serious security problems , needs server able follow symlinks apache2 example edit : missed problem first..

c++ - Combining two YV12 image buffers into a single side-by-side image -

Image
i have 2 image buffers in yv12 format need combine single side-by-side image. (1920x1080) + (1920x1080) = (3840*1080) yv12 split 3 seperate planes. yyyyyyyy vv uu the pixel format 12 bits-per-pixel. i have created method memcpy s 1 buffer (1920x1080) larger buffer (3840x1080), isn't working. here c++. byte* source = buffer; byte* destination = convertbuffer3d; // copy on y (int x = 0; x < height; x++) { memcpy(destination, source, width); destination += width * 2; source += width; } // copy on v (int x = 0; x < (height / 2); x++) { memcpy(destination, source, width / 2); destination += width; source += width / 2; } // copy on u (int x = 0; x < (height / 2); x++) { memcpy(destination, source, width / 2); destination += width; source += width / 2; } i expected this: instead, result: what missing? what wanted this: y1 y1 y1 y1 y2 y2 y2 y2 y1 y1 y1 y1 y2 y2 y2 y2 y1 y1 y1 y1 y2 y2 y2 y2 y1 y1 y1 y1 y

Passing images from Node.js to Jade to be displayed in a table-row -

i try passing array of objects form node.js jade displayed table. works far. how have code it, when in 1 column image should displayed? in dataarray have database documents array of objects. have bild images correspond dataarray the image rendered when code follows (see below) when try render part of table fails. node.js res.render('index', { title: 'image analysis - content of database', src: bild[0].tostring('base64'), dbdoc: dataarray }); index.jade img(with=50 height=50 alt='wikipedia', src='data:img/png;base64,#{src}') table(border='1') thead tr th # th image id th processed th raspi location th celebrity th age th gender th additional fields tbody each val in dbdoc tr td= 1 td= val.imageid td= val.entryproc

android - how to find incompatible apis with older versions -

i have built app api 23/22/21 sdk mintargetversion = 16. i use android studio sometimes during development process, saw android giving hints newer api used when mintarget 16. i have fixed of may not all. now have written lot of code , looking way find out usages of newer api not compatible older versions. i looking same in layout files well. is there easy way can find out? harder way @ every single line of code again or source files. in android studio can click on analyze in toolbar @ top > inspect code > whole project after finished have list of lint errors can go through

ruby on rails - acts_as_votalble always shows link to dislike -

i'm trying use acts_as_votable in rails application. have link allow users or unlike post. right shows link dislike ( current_user has liked status). case when seed database. app/controllers/status_controller.rb class statuscontroller < applicationcontroller before_action :set_status def current_user.liked_by @status respond_to |format| format.js {render inline: "location.reload();" } end end def dislike current_user.unliked_by @status respond_to |format| format.js {render inline: "location.reload();" } end end private def set_status @status = status.find(params[:id]) end app/models/user.rb class user < activerecord::base # include default devise modules. others available are: # :timeoutable , :omniauthable devise :database_authenticatable, :registerable, :confirmable, :lockable, :recoverable, :rememberable, :trackable, :validatable has_many :statuses, dependent: :dest

java - Writing a constructor, takes an enum argument from a different class -

i trying program ai game , wanna able set different modes players. here enum in type.java: public enum type { human,random,minimax } and here constructor in player.java set type of player: public player(string name, type e ) { this.name = name; this.type = e; } now eclipse says "type cannot resolved or not field." should do? both files in same package. now eclipse says "type cannot resolved or not field." that's telling problem has type in line: this.type = e; // ^---- 1 declare field in player if haven't already: private type type; ...and make sure you're using field's name in constructor: this.type = e; note i've used lower case field name. overwhelming convention in java, , matches did field name .

php - How do I control the page margins when streaming html as Microsoft Word -

i need output ms word document through web application, , utilizing trick of streaming html content type set application/vnd.msword. working unable figure out how set page margins in resulting word document. coming out 1 inch , them smaller. i'm using technique documented here: http://cosninix.com/wp/2010/04/generating-microsoft-office-documents-word-excel-on-your-webserver-using-php/

Writing a System Call that Accesses a Kernel Variable -

i have own kernel module has external integer variable: extern int = 0; i want write system call (in separate file) following i: i = + 1; however, because declared in kernel module file , not in system call, won't compile properly. know problem doesn't lie elsewhere because system call "works" fine when contains printk statement or self-contained. how can link variable in kernel module file system call file?

c# - Reformat string to be comma separated and formatted -

i have list of strings... var strings = new list<string>() { "a", "b", "c" }; i want output them in different format, this: 'a','b','c' i've tried : string.join("','",strings ); and string.join(",", string.format("'{0}'",strings ) your first attempt should work, need prefix , suffix overall result "'" . or, do: var strings = new list<string>() { "a", "b", "c" } .select(x => string.format("'{0}'", x)); var result = string.join(",", strings); another option use stringbuilder instead, var strings = new list<string>() { "a", "b", "c" }; var builder = new stringbuilder(); foreach (var s in strings) { builder.appendformat(",'{0}'", s); } var result = builder.tostring().trim(","

javascript - Why does No 'Access-Control-Allow-Origin' browser error have a status code? -

xmlhttprequest cannot load <website>. no 'access-control-allow-origin' header present on requested resource. origin '<otherwebsite>' therefore not allowed access. response had http status code 401. what i'm curious last line @ end. there's point in php code can change status code , changes number in output. if browser blocking request, how possible server side application code change happening being executed?

java - Attempt to invoke interface method android -

this question has answer here: what nullpointerexception, , how fix it? 12 answers i have code in class a private rtclistener mlistener; @override public void update(string string) { //here work want pass data interface mlistener.onupdate(sometext); } public interface rtclistener{ void onupdate(string string); } now in class , b i implements interface public class b extends service implements a.rtclistener{ // here override interface method @override public void onupdate(string string) { log.d("dwdwadwadwd"," data is"+string); } } its give me error attempt invoke interface method 'void ..... on null object reference i solve in class b construct class a in class b a myclass = new a(this,another prameter if u have,another prameter if u have); and in class a on construct fun

javascript - Protractor Cucumber BDD Tests Show Pass before Execution -

i have sample bdd test using protractor cucumber. on executing code, console shows result passed , code begins executing after that. i wish execution status display in sync actual execution.(e.g console displays - ' given launch protractor demo page ' , code underneath executed, console displays next step , on) know has got async coding , callbacks, not able figure out exact problem though. feature file: feature: test scenario: test scenario given launch protractor demo page when enter 2 in first field , enter 3 in second field , click go button result should displayed 5 step file: var chai = require('chai'); var chaiaspromised = require('chai-as-promised'); chai.use(chaiaspromised); var expect = chai.expect; module.exports = function () { this.given(/^i launch protractor demo page$/, function (callback) { browser.driver.manage().window().maximize(); browser.get('http://ju

vim - Clear search highlight on autocmd BufWrite -

i tried of suggestions in 3 questions: get rid of vim's highlight after searching text how rid of search highlight in vim vim clear last search highlighting it's :noh , , works when type manually. want happen on bufwrite, tried multiple ways, none of worked: function! removehighlight() :noh endfunction autocmd bufwrite * :call removehighlight() autocmd bufwrite * :noh autocmd bufwrite * :execute "normal! :noh\<cr>" debuging echom s , adebug\<esc> in function , in third autocmd show execute successfully, :noh has no effect. (also tried :let @/ = "" worked clears search pattern, not i'm looking for. want rid of highlight til pressing n or similar) using bufwritepost doesn't have effect, either. it workaround can set nohlsearch autocmd. can add mapping set n , n . au bufwrite * set nohlsearch nnoremap <silent> n n:set hlsearch<cr> nnoremap <silent> n n:set hlsearch<cr> or may

nested loop Assembly code -

for (int = 0; < vec1.length; i++) { (int j = 0; j < vec2.length; j++) { if(vec1[i]==vec2[j]){ add=true; cont++; (int k = 0; k < cont; k++) { if(vec2[j]==vec3[k]){ add=false; } } if(add==true){ vec3[cont+1]=vec2[j]; } } } } i'd translate pseudocode java correct assembly 32-bit system. can me? i´m doing this, ignore comments in foreign language don´t know how third loop in addvec3, , condition after global ptrvec1, ptrvec2, ptrvec3 .section .text .global comuns #int comuns(void) comuns: movl $0, %eax # iniciar eax 0 movl $0, %ebx # primeiro ciclo movl $0, %ecx # segundo ciclo movl $0, %edx # ciclo vetor3 movl $ptrvec1, %ebp #endereco vetor1 movl $ptrvec2, %edi #endereco vetor2 movl $ptrvec3, %esi # resultado ciclo: cmpl $14, %eb

android - How to communicate with a background activity from intent service -

so have activity holding data mydata. have background intentservice runs periodically , updates data in database reload when background activity comes foreground. want reload when background service ran. used broadcast receivers work if activity in foreground. doesn't receive events if activity in background. another way thinking write flag "reload" in preferences when intentservice runs , when backgrounded activity resumes checks flag , reloads if necessary , set false again. can suggest better solution? thanks. the simple way? use static method, myintentservice.didanythingchange() (making sure clear flag when activity reloads). or maybe sequence number, you'd have if (this.updateno != myintentservice.getlatestupdateno()) in activity. the complicated way? use dynamically registered broadcastreceiver in activity, , send matching broadcast intentservice. let broadcastreceiver set flag in activity.

python - Dumb error in my if/and statement - not seeing it -

i have data set float values: dog-auto dog-bird dog-cat dog-dog result 41.9579761457 41.7538647304 36.4196077068 33.4773590373 0 46.0021331807 41.33958925 38.8353268874 32.8458495684 0 42.9462290692 38.6157590853 36.9763410854 35.0397073189 0 41.6866060048 37.0892269954 34.575072914 33.9010327697 0 39.2269664935 38.272288694 34.778824791 37.4849250909 0 40.5845117698 39.1462089236 35.1171578292 34.945165344 0 45.1067352961 40.523040106 40.6095830913 39.0957278345 0 41.3221140974 38.1947918393 39.9036867306 37.7696131032 0 41.8244654995 40.1567131661 38.0674700168 35.1089144603 0 45.4976929401 45.5597962603 42.7258732951 43.2422832585 0 this sframe. have attempted write function uses if/an statement determine if value dog-dog less values dog-ct , dog-auto , dog-bird. i've gone through better part of 4 hours. admittedly i'm newby python - i'm making i

c++ - Finding the closest number of array to another given number -

i have program write have array of 11 numbers entered me. need find avarage sum of numbers, , im asked find closest number of array avarage sum, , distant element of array avarage sum again. far manage write program create array , find avarage sum. asssume there abs function of cmath libary , far fail make it. #include <iostream> using namespace std; int main() { unsigned const int size = 11; float number[size]; (unsigned = 0; i<size; i++) { cout << "please enter value number " << + 1 << ":"; cin >> number[i]; } (unsigned = 0; i<size; i++) { cout << "number " << + 1 << " : " << number[i] << endl; } unsigned int sum = 0; (unsigned = 0; i<size; i++) { sum += number[i]; } what problem? not asking question, making statement... seem have not posted whole code.. in c++ use "abs" should use fabs "math.h" librar

c++ - How to find biggest white surface using OpenCV -

Image
i've got binary image lots of white blobs. find biggest white blob of them , copy new mat object. using simpleblobdetector way go here? i've found examples using findcontours. how rid of small blobs?

javascript - Socket.io updating multiple times -

i included socket.io in small react application , set of listeners in "componentwillmount," shown below. componentwillmount() { const socket = io(); socket.on('update', function(newdatapoint) { console.log("client updating!"); this.setstate({ count: newdatapoint.count, temperature: newdatapoint.temperature, humidity: newdatapoint.humidity, pressure: newdatapoint.pressure }); }.bind(this)); } on server side, have this: io.on('connection', function(socket) { const pulse = setinterval(function() { console.log("from server."); io.emit('update', { temperature: math.floor(math.random() * 10 + 70), count: math.floor(math.random() * 300) + 5000, humidity: math.floor(math.random() * 5) + 30, pressure: math.floor(math.random() * 3) + 29 }); }, 1000); sock

c - Generating a Linked List by reading numbers from text file -

i want read in numbers text file , create linked list dynamically, although able it, last node value of 0 added list. how can correct this? should able add value 0 if want not in way. #include <stdio.h> #include <stdlib.h> typedef struct node { int data; struct node *next; }node; int main(int argc, char const *argv[]) { file *fp = fopen("data.txt", "r"); node *prev = null; while(!feof(fp)){ node *curr = malloc(sizeof(node)); fscanf(fp, "%d", &(curr->data)); fprintf(stdout, "%d-->", curr->data); if(prev != null){ prev->next = curr; } prev = curr; } printf("null\n"); fclose(fp); return 0; } the input file single column of integers 1 5 2 3 6 4 the output comes this, 0 not part of input 1-->5-->2-->3-->6-->4-->0-->null fo

javascript - Creating object reference in prototype constructor -

i'm trying wrap head around using javascript prototype objects , have run block perhaps due understanding of traditional classes. my code looks following: $(document).ready(function () { var instance = new cards(); $dom = instance.builditem(5); } var cards = function () { //constructor this.chromaobj = chroma.scale(["lightblue", "navy"]).domain([2, 6]); } cards.prototype.builditem = function (val) { var scale = this.chromaobj; var $item = $("<span>" + val + "</span>").addclass("label-default").addclass("label").css({ "background-color": scale(val) }); return $item; } every time scale called in builditem function, receive error in console scale not function, however, if create scale instance inside of builditem function, works expected. can please point me in right direction why unable access function reference when defined in constructor? th