Posts

Showing posts from June, 2013

android - Text Editor keyboard overlaps with the recyclerview list -

Image
the layout has recyclerview , text editor @ bottom of view. when click editor, keyboard popup , overlaps recycerview. want recyclerview resized when keyboard brought up. in manifest file have : <activity android:name=".commentactivity" android:label="yourtime" android:windowsoftinputmode="adjustresize"> </activity> my layout looks : <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> <android.support.v7.widget.recyclerview android:id="@+id/rv" android:layout_width="match_parent" android:layout_height="wrap_content" /> <linearlayout android:orientation="horizonta

android - Can I not use SharedPreference inside a constructor? -

i'm using simple class perform actions (calculations) , want write value in sharedpreferences may later used. however, not working. extended class activity can use getsharedpreferences() method. incorrect , not allowed? i'm getting null pointer exception trying initialize sharedpreference editor code below: public class jsonparser extends activity { // store our preferences json route info public static final string my_prefs_json = "jsonprefs"; // construct object json values public jsonparser(string jsonstring){ try { jsonobject jsonobject = new jsonobject(jsonstring); jsonarray routesarray = jsonobject.getjsonarray("routes"); // fails nullpointer sharedpreferences.editor editor = getsharedpreferences(my_prefs_json, mode_private).edit(); // store in sharedpreferences our json value editor.putstring("json", routesarray.tost

java - Usage of @Transactional with Spring Data custom methods -

i using spring data (via spring boot 1.3.3). repositories have custom method primary key. example: @transactional(readonly=true) @repository public interface userrepository extends crudrepository<user, userid>, userrepositorycustom { user findbyusername(string username); } public interface userrepositorycustom { userid nextid(); } public class userrepositoryimpl implements userrepositorycustom { public userid nextid() { return new userid( uuid.randomuuid() ); } } is use of @transactional correct here? or need add @transactional userrepositoryimpl (possibly readonly set or not)? the reason asking because unexplainable objectoptimisticlockingfailureexception org.springframework.orm.objectoptimisticlockingfailureexception: object of class [com.company.project.domain.game] identifier [gameid{id=7968c30b-838f-424c-bfef-838de7028def}]: optimistic locking failed; nested exception org.hibernate.staleobjectstateexception: row updated or deleted transaction

excel vba - VBA Dependent Combobox -

i have 3 combo boxes dependent each other. list on cmb2 depends on value on cmb1. cmb3 list depends on cmb2 value. my problem is, when remove/delete values on combo boxes, when click cmb2, still shows list of last value chosen on cmb1 & same goes cmb3. what's code show empty if combo box it's dependent doesn't have value? edit: think based on added information in comment should encapsulate logic in sub procedures , functions. best so, there should logic between named ranges , values in combobox. in below example, created function handle conversions value in independent combobox , named ranges. can supply own connector, assumed space changed underscore (so, 'account information' replaced 'account_information'). next subprocedure checks confirm named range exists in workbook matches converted value in independent combobox. if so, dependent box takes on named range list property. if not, dependent combobox cleared. the benefit using

integer - Java toString method difference -

this question has answer here: java int string - integer.tostring(i) vs new integer(i).tostring() 11 answers i enjoy codefights @ moment , @ end of last fight found interesting. code in 2 cases (mine , opponent) said correct. there difference between source code: return integer.tostring(character.getnumericvalue(ch1) + character.getnumericvalue(ch2)); and one: return new integer(character.getnumericvalue(ch1)+ character.getnumericvalue(ch2)).tostring(); what key missing? from javadoc https://docs.oracle.com/javase/7/docs/api/java/lang/integer.html string tostring() returns string object representing integer's value. static string tostring(int i) returns string object representing specified integer.

winforms - C# Calculate Employee Salary in a Class or via button click? -

i'm developing payroll software major project. tax information (jamaican income tax) should calculated, added , subtracted base pay secretary enter via textbox. the tax percentage , calculations each type of tax contained in checkboxes. result of calculations of taxes incorrect. if base pay less threshold tax (22800) income tax becomes negative value. if 1 checkbox checked before other result checkbox becomes incorrect. i know if easier perform calculations employee salary in class or within button click event. thanks in advance help. first of all, mixing few thing sup here. checkboxes should never used data storage - ui elements , job display results, or take inputs. ideally, should have class represents object - in case payroll guess. payroll class should know it's own tax calculations, amount of salary , related payroll. if have checkboxes correspond tax amounts deducted, use sort of resolver class return tax amount based on state of checkboxes sele

Apache Nifi GetTwitter -

Image
i have simple question, new nifi. i have gettwitter processor set , configured (assuming correctly). have twitter endpoint set sample endpoint. run processor , runs, nothing happens. no input/output how troubleshoot doing (or in case not doing)? a couple things might at: what activity processor show? can @ metrics see if has been attempted (tasks/time) if succeeded (out) stop downstream processor temporarily make output flowfiles visible in connection queue. are there errors? typically these appear in top-left corner yellow icon are there related messages in logs/nifi-app.log file? it might if describe gettwitter property settings bit more. can share screenshot (minus keys)?

javascript - Angular ui multiselect binding only desired property -

i'm using angularjs ui select , want select more 1 items.my code this $scope.user.selectedcategories $scope.categories= [ { value: 'reading', name: 'reading books',id : 4 }, { value: 'sports', name: 'physical activity',id : 9 }, { value: 'movies', name: 'entertainment',id : 7 }, { value: 'video games', name: 'passion',id : 11 } ]; <div class="input-group"> <ui-select multiple ng-model="user.selectedcategories" theme="bootstrap" sortable="true" close-on-select="false" style="width: 350px;"> <ui-select-match placeholder="select categories...">{{$item.value}}</ui-select-match> <ui-select-choices repeat="category in categories"> {{category.value}} </ui-select-choices> </div> right selectedcategories contain

javascript - Scraping dynamic content through Selenium? -

i'm trying scrap dynamic content blog through selenium returns un rendered javascript. to test behavior tried wait till iframe loads , printed it's content prints fine again when move parent frame displays un rendered javascript. i'm looking in i'm able print rendered html content from selenium import webdriver selenium.webdriver.support.ui import webdriverwait selenium.webdriver.common.by import selenium.webdriver.support import expected_conditions driver = webdriver.chrome("path chrome driver") driver.get('http://justgivemechocolateandnobodygetshurt.blogspot.com/') webdriverwait(driver, 40).until(expected_conditions.frame_to_be_available_and_switch_to_it((by.id, "navbar-iframe"))) # rendered iframe html printed. content = driver.page_source print content.encode("utf-8") # when switch parent frame again prints non rendered javascript. driver.switch_to.parent_frame() content = driver.page_source print content.encod

.htaccess - Upgrading from OwnCloud 8.2.3 to OwnCloud 9.0.1 results in css and js being served as text/html -

i have been using owncloud quite while on ubuntu 14.04 lts headless server. a couple days ago tried upgrade owncloud 9.0.1 , upon logging in first time after upgrade presented non styled layout. if in browser console see many errors incorrect mime types: refused execute script 'https://www.domain.at/cloud/core/vendor/jquery/jquery.min.js?v=a283428d5f34c45e26387d89361a95ba' because mime type ('text/html') not executable, , strict mime type checking enabled. www.domain.at/:1 refused execute script 'https://www.domain.at/cloud/core/vendor/jquery-migrate/jquery-migrate.min.js?v=a283428d5f34c45e26387d89361a95ba' because mime type ('text/html') not executable, , strict mime type checking enabled. www.domain.at/:1 refused execute script 'https://www.domain.at/cloud/core/vendor/jquery-ui/ui/jquery-ui.custom.js?v=a283428d5f34c45e26387d89361a95ba' because mime type ('text/html') not executable, , strict mime type checking enabled. www.d

r - Load spark-csv from Rstudio under Windows environment -

can 1 tell me if can import spark-csv package sparkr using r studio under windows 7 environment? local machine has r 3.2.2, spark-1.6.1-bin-hadoop2.6 , java installed, not maven, scala etc. don't know if miss in order call spark-csv? shall install package (.jar file) , put in folder? here script: library(rjava) sys.setenv(spark_home = 'c:/users/***/spark-1.6.1-bin-hadoop2.6') .libpaths(c(file.path(sys.getenv('spark_home'), 'r', 'lib'), .libpaths())) library(sparkr) sys.setenv('sparkr_submit_args'='"--packages" "com.databricks:spark-csv_2.11:1.4.0" "sparkr-shell"') sc <- sparkr.init(master = "local[*]", sparkenvir = list(spark.driver.memory="2g")) sqlcontext <- sparkrsql.init(sc) i able call sparkr library , initiate sc, here message: launching java spark-submit command c:/users/***/spark-1.6.1-bin-hadoop2.6/bin/spark-submit.cmd --driver-memory "2g" &qu

Ways to register a user in an asp.net mvc website from another mvc website -

i'm looking suggestions on how go creating user in 1 of asp.net mvc websites one, integrate 2 sites bit. site (asp.net mvc 4, vs 2012) needs take information customer upon post action , within action (server side) send post site b (mvc 5, vs 2013, asp.net identity 2) create user in (it doesn't have wait post complete, can fire , forget...but open suggestions here too). both sites owned , operated myself, exist different purposes until now. i'm thinking need expose controller action on site b allow site post information needed create user. would make sense add action existing controller in site b creates user accounts, or make more sense create web api controller handles separately? there performance differences between 2 controller types? also, how secure new endpoint/action - i'm considering generating api key of sorts (generating , storing guid private key submit request) verify in fact site making request (all on https of course), , no 1 else. want o

swift - Modifying a class to display specific output -

i new swift , having bit of trouble bit in particular. attached code need run part of project. details @ end. class screen:datasource { var items:[string]=[] func run(){ let lv = tableview() items = ["john","paul","george","ringo"] let ds = self lv.datasource=ds lv.drawlist() } } class tableview { // class displays list given datasource var datasource:datasource? init (){ self.datasource=nil } func drawlist(){ for(var i=0;i<datasource!.getsize();i++) { print("\(datasource!.getitem(at:i))") print("--------------------------") } } } protocol datasource { func getsize()->int func getitem(at pos:int)->string } let screen = screen() screen.run() without changing "run" function/method, need have print this: john -------------------------- paul -----------------------

.net - Increasing the max length of file in the upload in asp.net application -

i have asp.net mvc application uploading projects files. things works fine , have problem, can't upload file length > 200mo. think problem in iis configuration , see many tutorials without finding soltion increase max length of file supported iis . i think handicap if have big file upload it( > 200mo) , application limit max length, other language java or php problem didn't exist. i have 2 web.config file: <?xml version="1.0" encoding="utf-8"?> <configuration> <configsections> <sectiongroup name="system.web.webpages.razor" type="system.web.webpages.razor.configuration.razorwebsectiongroup, system.web.webpages.razor, version=2.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35"> <section name="host" type="system.web.webpages.razor.configuration.hostsection, system.web.webpages.razor, version=2.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" requirepe

nlp - Does NLTK have a tool for tagging for animate versus inanimate? -

i trying tag list of words animacy . i've tried using spacy , stanford core nlp, these seem tag named entities. i know stanford has animacy dictionary, don't know how use , can't find instructions. can point me in right direction? there no such thing in nltk. this paper stanford nlp group might further, though.

.htaccess - Redirect to HTTP non-www to HTTPS www htaccess -

i want redirect direction our site https protocol, redirects it's not working. want this: http://www.site.co https://www.site.co http://site.co https://www.site.co this htaccess: rewriteengine on rewritecond %{https} off rewriterule ^(.*)$ https://www.domain.com/$1 [l,r=301] rewritecond %{http_host} !^www\. rewriterule ^(.*)$ https://www.domain.com/$1 [l,r=301] the second rule it's not working. going direction inside our site, , isn't redirect https site. try this: rewriteengine on rewritecond %{http_host} !^www\. [nc] rewriterule ^(.*)$ http://www.domain.com/$1 [l,r=301] rewritecond %{https} off rewriterule ^(.*)$ https://www.domain.com/$1 [l,r=301] the real difference here first redirect non-www www check https , redirect it. if work try one: rewriteengine on rewritecond %{http_host} !^www\. [nc] rewriterule ^(.*)$ http://www.domain.com/$1 [l,r=301] rewritecond %{server_port} !^443$ rewriterule ^(.*)$ https://www.domain.com/$1 [l,r

elasticsearch - Stop processing nested elements and treat as string or raw -

good afternoon, looking way elasticsearch stop processing further fields , instead treat string or raw. keep in mind newbie elk stack. have similar following: { "_index" : "logstash-2016.04.21", "level1" : { "level2" : { "1" : "somevalue", "2" : "somevalue2" } } } what have happen contents of level2 treated string , not create nested fields of 1 , 2. hope makes sense. thank you, mike changing field in template enable : false did trick. thank @vipw

iphone - Embedded Google maps opening app on iOS -

i have google map embedded in bootstrap site. busy testing on different mobile devices , when on ios , open page embedded map on it, maps app on device opened. i don't think doing fancy, stop. not occur on android devices. my html follows: <section> <div class="well well-sm"> <iframe width="100%" height="350" src="http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=central%2bpark&ie=utf8&z=12&t=m&iwloc=near&output=embed"></iframe> </div> </section> this default behavior of iphone/ipad regard maps. change behavior follow these steps stated in google support : 1.visit search settings page iphone or ipad. 2.scroll down "google maps" section. 3.select never use native app. 4.touch save @ bottom of page.

javascript - Safari's window.history.go(index) is off by 1 -

i'm trying make button takes user 2 pages, i've noticed odd safari. here working function: jquery(function(){ jquery('.go-back').click(function(e) { if(jquery.browser.safari) { window.history.go(-3); } else { window.history.go(-2); } }); }); does have explanation why indexing off 1 in safari?

ruby on rails - Default object attribute not defaulting for HTML -

if @challenge.name == 'foo' @challenge.category = 'habit' @challenge.days_challenged = 21 @challenge.why = 'bar' else :days_challenged & :why being set in _form foo not :category . <div class="challenge-category"> <input class="date-format-switcher" type="radio" value="goal" name="challenge[category]" id="challenge_category_goal"> <label for="challenge_category_goal">goal</label> <input class="date-format-switcher" type="radio" value="habit" name="challenge[category]" id="challenge_category_habit"> <label for="challenge_category_habit">habit</label> </div> <%= f.number_field :days_challenged, class: 'day-challenge' %> <%= f.text_area :why %> i assume purposefully custom-coding radio buttons. selected radio button

go - Run goimports on save in Sublime Text? -

in sublime text 3, plugins gosublime , goimports installed. i'm having trouble having goimports run on file automatically everytime save. here's tried : my gosublime settings set : { "env": {"gopath": "/home/nicolas/.go", "path": "$gopath/bin:$path" }, //"fmt_cmd": ["goimports"] } when save these settings, code gets formatted imports not added. nothing surprising far. if hit ctrl+shift+p goimports, imports added expected. now problem is, when uncomment previous line have these settings : { "env": {"gopath": "/home/nicolas/.go", "path": "$gopath/bin:$path" }, "fmt_cmd": ["goimports"] } not not add imports, no other formatting gets done anymore. any idea went wrong ? i'm using linux (ubuntu). make sure $gopath/bin in $path (windows: %gopath%\bin goes in %path%). run go -u golang.org/

import urllib.request, ImportError: No module named request -

i trying import urllib.request python 2.7.10 on pycharm 4.5.4 on window 10 getting error "importerror: no module named request". the urllib.request modules have been deprecated .. use import urllib and function if earlier writing say urllib.request.urlretrieve now write urllib.urlretrieve

Prolog Get the differences in days between two dates -

i've been trying compare 2 dates in prolog. the dates format date(yyyy, mm, dd) ex: (2016,04,21). i want compare 2 dates , know if difference (in days) between dates bigger 15 days (2 weeks). %datedifference( number_of_day, date_no1, date_no2 ). datedifference( 35, date(2003,8,16), date(2003,9,20) ). computing difference in days between 2 dates can simple or tricky depending on calendar , on covered periods. assuming gregorian calendar, common solution convert dates julian days. @mat mentioned in comment, swi-prolog, consider library(julian) ; https://github.com/mndrix/julian for portable solution can used prolog systems (including swi-prolog), logtalk includes third-party iso 8601 library can used these computations: http://logtalk.org/library/iso8601_0.html

multithreading - How to ensure two users can atomically confirm transaction has taken place in mongodb -

i have model called transaction has following schema var transactionschema = new mongoose.schema({ amount: number, status: string, _recipient: { type: mongoose.schema.types.objectid, ref: 'user' }, _sender: { type: mongoose.schema.types.objectid, ref: 'user' }, }); i want both sender , recipient of transaction able 'confirm' transaction took place. status starts out "initial". when sender has confirmed transaction (but recipient yet not), want update status "senderconfirmed" or something, , when recipient has confirmed (but sender has not), want update status "recipientconfirmed". when have both confirmed it, want update status "complete". the problem is, how can know when update "complete" in way avoids race conditions? if both sender , recipient go confirm transaction @ same time, both threads think status "initial" , update "senderconfirmed" or "recipientco

apache - perl/Cgi script with apache2 -

i have installed apache2 on unbuntu . working. want configure run perl/cgi scripts. made directory /var/cgi-bin scripts. made simple perl file echo.pl having following codes. #!/usr/bin/perl use strict; use warnings; print qq(content-type: text/plain\n\n); print "hi\n"; made executable. chmod +x /var/cgi-bin/echo.pl executed it /var/cgi-bin/echo.pl but showed following error. /var/cgi-bin/echo.pl: line 2: use: command not found /var/cgi-bin/echo.pl: line 3: use: command not found /var/cgi-bin/echo.pl: line 5: syntax error near unexpected token `(' /var/cgi-bin/echo.pl: line 5: ` print qq(content-type: text/plain\n\n);' i cant find error. please help.

swift - NSPopover OS X Application -

i developing menu bar application os x. using nspopover create popup window. however when other application full screen popup not visible. settings should set, popup window on top. i struggled well. when had problem, created invisible window flow above other windows, including full screen ones. window activate popover. however, found cleaner solution here .

css3 - CSS triangular cutout with border and transparent gap -

Image
i need draw following pattern css separator between sections of page: using skewx() technique this answer , able mimic triangular cutout accurately (two pseudo-elements appended top of lower section, 1 skewed left , 1 skewed right, background of upper section shows through): but can't figure out how add border, shown in first image. the problem gap between border , lower section has transparent, because background of upper section can gradient, image, etc. therefore, can't use image triangular cutout, because can't know content behind it. is there possible way css? it possible css approach find complex 1 using fair amount of gradients mimic borders. couldn't done normal borders because resulted in either borders extending beyond meeting point or inner area never meeting. couldn't done box shadow's because gap between border , filled area need transparent. ( not saying cannot done couldn't work, maybe there way too ). the below how

heap - Why is Windows Safe Mode Magic? -

everyone. i out i.t. medical practice. turns out there’s bug in emr software shows once in while. (all computers run on windows 10 currently) the program dies , popup “ a problem has caused program stop working… ” i hook debugger. looks heap issue in code according stack trace. turn on gflags , hits every time. tell emr software folks don’t claim bugs , want prove it’s not them. they boot computer safe mode networking , low , behold there’s no heap problem they’re off hook. it’s not them. i’ve reproduced problem on machines (32 , 64 bit) , in clean mode , logged in under activated administrator account safe mode works every time. i've reproduced problem running in command window: gflags /p /enable emrprogram.exe /full cdb -g -x emrname.exe questions: how can safe mode make heap bug disappear? any suggestions reproducing bug in safe mode, i.e. what’s happening in safe mode can make more normal mode? p.s. here's stack trace: verifier stop 00000010:

android - ListView not displaying anything in new activity using array adapter -

i've got class should, theoretically, display rss headlines, single rss feed site, in listview called searchlistview . if listview empty textview appears informing user listview empty, happens every time navigate activity. button , edittext filtering headlines. i've got exact same class in project (this class main activity in said project) works fine. rssitem class parses rss feed information headline title , url headline. note: searchactivity not main activity. edit: i'm using callback , loadermanager in main activity display items in list view well. i'm not knowledgeable these , don't know if might causing issue due main activity. not pass information main activity, though. fixed: wasn't getting errors or but, reason, nothing displayed. went android manifest , realised app doesn't have permissions connect internet. silly mistake, easy miss. <uses-permission android:name="android.permission.internet"/> searchactivity.jav

javascript - Put a text in side of jquery animation -

i found post animate button when click on it , want know how can put text side of animation. i tried: <div class="heart">text</div> && <div class="heart"><p>text</p></div> but text come on animation... want text in right side of animation. how make ? here updated snippet base on fiddle trying do. $(".heart").on('click touchstart', function(){ $(this).toggleclass('animating'); }); $(".heart").on('animationend', function(){ $(this).toggleclass('animating'); }); .heart { float:left; margin-top: -1em; cursor: pointer; height: 50px; width: 50px; background-image:url( 'https://abs.twimg.com/a/1446542199/img/t1/web_heart_animation.png'); background-position: left; background-repeat:no-repeat; background-size:2900%; } .heart:hover { background-position:right; } .animating { animation

c++ - std::advance - offset out of range failure on Debug only -

i'm trying iterate through vector more 1 using std::advance . there's discrepancy between debug , release builds debug giving vector iterator + offset out of range failure while release works in real application in more expanded case. why happen , how can write runs on debug? vector<glm::vec2> testv; testv.push_back(glm::vec2(0.f)); int step = 2; (auto = testv.begin(); != testv.end(); ) { if (it + step <= testv.end()) advance(it, step); else ++it; } this runs on release (unless print in loop causes hang) for (auto = testv.begin(); != testv.end(); ) advance(it, step); the addition operator iterator validating returned iterator. when add 2 , go past end, generate error in debug. release build doesn't have these checks doesn't report problem. having iterator point past end of container is, think undefined behavior. dereferencing is. you'll have check going past end other way.

jquery-dirtyforms not working with ajax actionlink - UpdateTargetID -

i have jquery.dirtyforms configured on forms in site. works fine when form dirty , try example close page. doesn't work @ unobtrusive ajax call. (ajax.actionlink), call proceeds normal. any ideas? code: <html> <head> <meta name="viewport" content="width=device-width" /> <title>create</title> <script src="~/scripts/jquery-2.2.1.js"></script> <script src="~/scripts/jquery.unobtrusive-ajax.js"></script> <script src="~/scripts/jquery.dirtyforms.js"></script> <script type="text/javascript"> $(document).ready(function(){ $('form').dirtyforms(); }) </script> </head> <body> @using (html.beginform()) { @html.antiforgerytoken() <div id="update"> <div class="form-horizontal">

ruby on rails - Devise is screwy -

when put require 'devise' in application.rb, error cannot load such file -- devise when take out, error uninitialized constant devise (nameerror) can't win. it turns out gem file messed up. needed restart project.

java - JSoup not printing all elements in HTML table row -

i trying elements in html table row using jsoup. however, seems consistently omit columns , print half of columns in table. instance, if have html table so: <table id="resulttable" width="100%" border="1" cellpadding="1" cellspacing="0" bordercolor="#ffffff"> <tbody> <tr class="table"> <td align="right">1</td> <td align="right">4</td> <td><div>name</div></td> <td><div>country</div></td> <td><div>club</div></td> <td><div>sr</div></td> <td align="right"><div>56.00 (5)</div></td> <td align="right"><div>51.62 (3)</div></td> <td align="right"><div>1:47.62

apache - add www on http and remove www on https -

i trying following: add www non secure http://domain[.]com http://www.domain[.]com & remomve www on secure https://www[.]domain.com https://domain[.]com i trying doesn't seem work rewritecond %{https} off rewritecond %{http_host} ^example.org$ rewriterule ^(.*)$ http://www.example.org/$1 [r=301,l] rewritecond %{https} on rewritecond %{http_host} ^example.org$ rewriterule ^(.*)$ https://example.org/$1 [r=301,l] try this: rewritecond %{https} off rewritecond %{http_host} ^example\.org$ [nc] rewriterule ^(.*)$ http://www.example.org/$1 [r=301,l] rewritecond %{https} on rewritecond %{http_host} ^www\.example\.org$ [nc] rewriterule ^(.*)$ https://example.org/$1 [r=301,l] your second http_host condition still checks www. missing, should other way around.

arrays - Swift fatal error: Index out of range -

leetcode easy 88 merge sorted array question: given 2 sorted integer arrays nums1 , nums2, merge nums2 nums1 1 sorted array. note: you may assume nums1 has enough space (size greater or equal m + n) hold additionalelements nums2. number of elements initialized in nums1 , nums2 m , n respectively. i got error have commented in code. have printed index2 , index3, both zero.they should legal. why got error? any help, appreciate it. thank time! class solution { func merge(inout nums1:[int], _ m: int, _ nums2:[int], _ n: int) { var index1 = m - 1 var index2 = n - 1 var index3 = m + n - 1 while index2 >= 0 && index1 >= 0 { if nums1[index1] > nums2[index2] { nums1[index3] = nums1[index1] index3 -= 1 index1 -= 1 } else { nums1[index3] = nums2[index2] index3 -= 1

javascript - Can't get token.remove() working in Facebook Emitter -

any idea why facebook emitter not working token.remove() call below: console: $ node main.js 5 10 /users/carlf/documents/dev/test/emitter/emit-node.js:21 token.remove(); ^ typeerror: undefined not function my code: var {eventemitter} = require('./node_modules/emitter'); var emitter = new eventemitter(); var token = emitter.addlistener('event', function(x, y) { console.log(x, y); }); emitter.emit('event', 5, 10); // listener prints "5 10". token.remove(); emitter.emit('event', 9, 11); // nothing logged that error telling remove not function. remove listener need call removelistener method of instance of eventemitter passing name of event , callback provided. try this: var {eventemitter} = require('./node_modules/emitter'); var emitter = new eventemitter(); function handler(x, y) { console.log(x,y); } emitter.addlistener('event', handler); emitter.emit('event', 5, 10); // listener

AngularJS Directive ng-repeat first time element shown -

i want apply custom directive in ng-repeat on html element first time appears. further elements after first appearance not have directive or directive not enabled. the element may not appear on first iteration of ng-repeat can't use $first. i'm creating tutorial tooltip , want show on first visible element. underlying scope of ng-repeat has no knowledge of tutorial can't use it. i think can write directive - var app = angular.module('app', []) app.controller('homectrl', ['$scope', function($scope) { $scope.done = false; $scope.items = [{ name: 'one' }, { name: 'two' }, { name: 'three', special: true }, { name: 'four', special: true }, { name: 'five', special: true }]; } ]); app.directive('special', function() { return { scope: false, restrict: 'a', li

android - How to know if phone app is closed -

please explain me how android call lock screen after closing emergency dialer. i've tried check every second if emergency call top activity if it's not lock device didn't it's job in android 5.0 , higher. so, need solution. my code: private static final long interval = timeunit.seconds.tomillis(1/100); private thread t = null; private context ctx = null; private boolean running = false; public myservice2() { } @override public ibinder onbind(intent intent) { return null; } @override public void oncreate() { super.oncreate(); } @override public int onstartcommand(intent intent, int flags, int startid) { final activitymanager activitymanager = (activitymanager) getsystemservice(context.activity_service); running = true; ctx = this; log.i("point","prerun"); t = new thread(new runnable() { @override public void run() {

javascript - Autocomplete on demand in angularJS -

i trying implement search function in angularjs pretty similar facebook way of searching. found out many tutorials, autocomplete directive works on data loaded , filtering that. if data count huge calling service on page load takes in data make website slow. there possibility of making autocomplete loads data on demand? i.e onkeyup function if type "dru", every key event service called , fetch data on demand. thanks yes can calling api on every key stroke change. <input type="text" ng-model="search" ng-change="fetchsearchresults(search)"> the fetchsearchresults method make api call server, fetching results given characters input. hope made sense.