Posts

Showing posts from January, 2013

node.js - Execute script after package installation -

now, there postinstall run script after npm install however, looking way run script after installing single package npm install jquery --save is possible? if so, work on windows , there way name of installed package ( jquery in given example)? i'm don't see on package.json features . it therefore possible in prestart instance jquery won't in devdependencies way: { ... "devdependencies": { "bower": "1.3.x", "uglifyjs": "2.4.10", ... other dependencies }, "scripts": { "prestart": "npm install jquery@#.#.# ; <yourcommand> ; npm install", ... } }

memory reallocation issue in Java ArrayList, HashSet and HashMap -

looked unofficial references, , want confirm here understanding correct. suppose adding new (unique) elements time time, arraylist<t> reallocate memory since memory needs continuous, when memory grow newly inserted elements exceeds threshold, reallocation of larger continuous memory space happen, , existing elements moved such newly allocated larger continuous memory space; hashset<t> , hashmap<t> has no such issue since memory of them not require continuous? btw, if articles on these areas, appreciate refer well. regards, lin if checkout sourcecode of add(e e) method in arraylist<> in java 8 (jre 1.8.0_71), calls in method called ensurecapacityinternal(int mincapacity) . i.e method called every time add in object arraylist. inturn calls in series of methods , if size of arraylist smaller hold newly added element, calls in method called grow(int mincapacity) . method shown below: /** * increases capacity ensure can hold @ least

Add markers on the fly to geoJSON array with mapbox-gl-js -

i've seen several examples of mapbox maps multiple markers marker locations pre-programmed geojson array such 1 here . i'd able add marker map via method , keep existing markers. markers created built-in geocoder search. seems possible old mapbox.js along lines of this: l.geojson(geojsonfeature, { ... }).addto(map); however, cannot seem find documentation such method/functionality mapbox-gl-js. i'd able keep track of these markers , edit/delete them in fiddle . missing something? here current code works 1 marker. if add new marker, replaces old. i'd keep adding them geocoder hook: mapboxgl.accesstoken = 'xxx'; var map = new mapboxgl.map({ container: 'map', style: 'mapbox://styles/mapbox/streets-v9', center: [-79.4512, 43.6568], zoom: 13 }); var geocoder = new mapboxgl.geocoder({ container: 'geocoder-container' }); map.addcontrol(geocoder); map.on('load', function() { map.addsource('s

ios - UISlider ValueChanged action not working -

i want calculate number in real-time uislider, method: @ibaction func hpslidervaluechanged(_ sender: customuislider) { calculator.hppercentage = double(hpslider.value) hpvalue.text = string(int(hpslider.value * 100)) + " %" resultlabel.text = string(calculator.calculate()) } both hpvalue label , resultlabel expected change value when user swipes on slider, however, hpvalue label changes, resultlabel doesn't work. calculator not nil, here's code: class turretdivecalculator { var hero: heroes = .taka var build = [defenseitems](repeatelement(defenseitems(name: "empty item", index: 0, price: 0, image: #imageliteral(resourcename: "emptyitem")), count: 6)) var hppercentage: double = 0 func calculate() -> int { let basehp = hero.hplow + (hero.hphigh - hero.hplow) / 12 * double(hero.level) let basedefense = hero.armorlow + (hero.armorhigh - hero.armorlow) / 12 * double(hero.level) + hero.shieldlow + (hero.shieldhi

ios - UIScrollView not Scrolling at all -

Image
i've tried several s.o threads none of them have solved me. have "containerscrollview" won't let me scroll it. i've tried making both longer , shorter contents of view either doesn't work (longer) or turns whole view white (shorter). on iphone 5 can still see down third label whereas need able scroll down past "about" section. suggestions? thanks ] 1 try this override func viewdidlayoutsubviews() { super.viewdidlayoutsubviews() scrollview.contentsize = cgsize(width:self.view.bounds.width, height: 1430) }

appstore approval - OTA Download Limit for iOS Apps on Cellular Network -

did apple remove ota limit downloading ios apps on cellular network?i don't see guideline, 'apps larger 100mb in size not download on cellular networks (this automatically prohibited app store)' requirement in latest app store review guidelines did apple remove chance? info me lot! cheers.

c# - This command is not available because no document is open while getting Active document -

Image
try { microsoft.office.interop.word.application wordobj = system.runtime.interopservices.marshal.getactiveobject("word.application") microsoft.office.interop.word.application; office.customxmlparts currclassification = wordobj.activedocument.customxmlparts; } catch(exception ex) { //i getting, command not available because no document open. error here. } when using above code, getting error: this command not available because no document open. regards actually trying access active document when there no document open in word application getting error. word application open no document opened in i.e. @ home screen of word application shown in image. try use following code check whether there open documents in application , access activedocument if(wordobj.documents.count >= 1)

rxjs - Angular 2 How to detect string change using observable -

i have 2 services. in 1 want subscribe detect if string changes in other service load database each time changes. first service:( session value used reference 2nd service) subscribestringchange() { this.session.uid.subscribe(x => { console.log(this.session.uid); return this.af.database.list('items', { query: { orderbychild: 'uid', equalto: this.session.uid } }); }); } here second service , have tried: uid: observable<string> = observable.of(''); constructor(private auth: firebaseauth, private af: angularfire) { this.auth.subscribe(user => { if (user) { this.uid = observable.of(user.uid); console.info('logged in'); } else { this.uid = observable.of(''); console.info('logged out'); } }); } you use behaviorsubject , acts both producer , consum

c# - How to know a StreamGeometry is a Line -

i have collection of streamgeometrys. each streamgeometry shape. want pick streamgeometrys lines. how can know streamgeometry line. background: collection of streamgeometrys interface. interface given other team , doesn't return information geometry is. (i may discuss them make update, involve architecture change.) have function group geometrys , outline of group. originally, add them geometrygroup, use geometry.getoutlinedpathgeometry outline of geometrygroup. behavior good. problem :but when geometrys number increases more 200, getoutlinedpathgeometry becomes extremely slow. current solution :then have make compromise outline not accurate. instead of getoutlinedpathgeometry, use geometry.combine combine geometrys. geometry.combine used closed geometry. when geometry not closed, find nearest points make closed. behavior somehow reduce complexity of overall outline getoutlinedpathgeometry can result quicker. how question :but 1 problem geometry.combine omit line shape

sql - Count percentage of certain column values and add it to a new column -

i have following table [table_orangeisnewblack] id | name | color | redpercent ------------------------------------------ 1 | donald | orange | 2 | hillary | white | 3 | barack | black | 4 | bernie | grey | 1 | donald | red | 2 | hillary | red | 3 | barack | black | 4 | bernie | grey | 1 | donald | red | 2 | hillary | blue | 3 | barack | red | 4 | bernie | purple | i need add percentage value presenting how person 'red' donald's record 1 donald orange 1 donald red 1 donald red redpercent : (2 / 3 ) * 100 = 66,66 hillary 2 hillary white 2 hillary red 2 hillary blue 'blue' , 'purple' not count, : redpercent : (1 / 2) * 100 = 50,00 barack 3 barack

html - drawing shapes with css -

am trying shape drawn in css on header of webpage. supposed this. the shape trying draw header but when try exact shape, looks below (run snippet) am not @ css struggling here. codes below. header { padding: 0px !important; height: auto !important; } .header { top: 0px; width: 100%; height: auto !important; padding: 0px !important; background-color: #00ff00; } .spanheader { font-size: 20px; } .logo { z-index: 1; position: relative; } .topheader { text-align: center; width: 100%; background-color: lightgray; left: 0px !important; top: 0px !important; } #draw { height: 30px; width: 100%; background-color: #fff; } #green { height: 60px; width: 100%; border-width: 0px; border-left: 280px solid white; border-top: 20px solid white; -moz-transform: skew(-45deg); -webkit-transform: skew(-45deg); transform: skew(-45deg); } <section id="header" class="header"> &

java - How to get following XML structure using JaxB -

i have requirement need generate xml having following structure. data populating database going format target xml. have created few classes , tried marshalling bean not able generate following structure. please help. <component id ="668020">--root element <xyz>xyz</xyz> <pqr>pqr</pqr> <profile> <abc>abc</abc> <bcd>bcd</bcd> </profile> <twentyseven> <item> <one>1</one> <two>2</two> </item> <item> <one>1</one> <two>2</two> </item> <item> <one>1</one> <two>2</two> </item> </twentyseven> <hundred> <hundred_one> <item> <one>1</one> <two>2</two>

indexing - OrientDB: can I create an index on a property of type EMBEDDED? -

i have schema property of type embedded. when try create index in web interface property, nullpointerexception: {"errors":[{"code":500,"reason":500,"content":"com.orientechnologies.orient.core.index.oindexexception: cannot create index 'order.attr_f9e8e581_7076_4b14_a625_37e0e7dbc2a9_2'\r\n\tdb name=\"temp\"\r\n--> java.lang.nullpointerexception"}]} is possible create index on type of property? embedded document has 2 properties , i'm not interested in indexing on embedded property, document whole. reading old response: https://groups.google.com/forum/#!topic/orient-database/oh7hcbsi6e4 seems forbidden. hope helps. regards

php - Selective export from MySQL database -

i've got database called members, people register online entering fullname, email address, phone number, etc. made hidden form set random 4 digit unique number , register data, send via email. people use these unique ids enter event, 80% came. collected ids, have list of ids belongs people came event, want export rows of people came using ids. example: every row include number: 4293, 1932, 9382 = export. there's way in mysql? following query should trick select fullname members id in (4293, 1932, 9382)

MySQL and Python Select Statement -

i'm trying select specific text cell within table, can't mysql obey command. i'm sure i'm doing wrong, me feels right... i've checked documentation , google wasn't able come answer myself, hence why i'm turning you. this outlay of mysql: mysql> describe configuration; +---------+--------------+------+-----+---------+-------+ | field | type | null | key | default | | +---------+--------------+------+-----+---------+-------+ | option | varchar(255) | no | pri | null | | | setting | varchar(255) | no | | null | | +---------+--------------+------+-----+---------+-------+ in phpmyadmin looks this: +---------+---------+ | option | setting | +---------+---------+ | version | 0.7.48 | +---------+---------+ i'm trying this: #!/usr/bin/env python import mysqldb db = mysqldb.connect(host="xxx", user="xxx", passwd="xxx", db="xx") cur = db.cursor() cur.execute("sel

ios - NSString Date to NSDate -

this question has answer here: converting nsstring nsdate (and again) 16 answers nsstring date nsdate in ios not displaying proper details. have nsstring date : nsstring *strfinal = @"2016-10-20 12:00:00"; i following below method convert nsstring nsdate nsstring *strfinal = @"2016-10-20 12:00:00"; nsdateformatter *dateformatter = [[nsdateformatter alloc] init]; // [dateformatter setdateformat:@"yyyy-mm-dd hh:mm:ss"]; [dateformatter setdateformat:@"yyyy-mm-dd hh:mm:ss"]; nsdate *datefromstring = [[nsdate alloc] init]; datefromstring = [dateformatter datefromstring:strfinal]; and out put : string date : 2016-10-20 12:00:00 nsdate is: 2016-10-19 18:30:00 +0000 it generates different date , different format nsstring want same nsdate . any appreciated. thanks you have

java - How to use JUnit assertThat correctly? -

this question has answer here: hamcrest tests fail 14 answers i have class called calculator 4 basic operations of adding, subtracting, dividing , multiplying public class calculator{ public int add(int a, int b) { return + b; } public int subtract(int a, int b) { return - b; } public double multiply(double a, double b) { return * b; } public double divide(double a, double b) { if (b == 0) { throw new arithmeticexception("division zero."); } return / b; } } i'm using maven project , pom.xml file: <project xmlns="http://maven.apache.org/pom/4.0.0" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://maven.apache.org/pom/4.0.0 http:

lsa - Document Similarity in R -

i new text mining , semantic analysis. trying find similarity of documents. first approach, using jaccard_similarity find documents similar. have read, jaccard_similarity find similar words, perhaps not best approach finding similar documents, thought give try anyway. the problem facing following. have 200 type documents, , 1000000 b type documents. need see (if any) of documents similar b documents, not need see if type documents similar between them, or if b documents similar between them. i found "textreuse" package in r perform this. following: minhash <- minhash_generator(100, seed = 235) corpus <- textreusecorpus(text=as.character(data$text), tokenizer=tokenize_ngrams, n=5, minhash_func=minhash) buckets <- lsh(corpus, bands = 50, progress = false) candidates <- lsh_candidates(buckets) scores <- lsh_compare(candidates, corpus, jaccard_similarity, progress = true) whe

javascript - OneSignal subscribe user through web page using web-push-sdk -

is there way in 1 signal web-push-sdk add user manually , unsubscribe? i tried in subscribeonesignal() function nothing happening. onesignal.push(function() { onesignal.registerforpushnotifications(); }); i have simple html page have 2 buttons 1 "subscribe" , other "unsubscribe", when user click on subscribe button should add @ 1 signal , when clicked on "unsubscribe" button shouldn't receive notifications. <!doctype html> <html> <head> <link rel="manifest" href="/manifest.json"> <script src="https://cdn.onesignal.com/sdks/onesignalsdk.js" async></script> <script> var onesignal = window.onesignal || []; onesignal.push(["init", { appid: "345345-asdf-345", autoregister: false, notifybutton: { enable: true } }]); function subscribeonesignal

java - How to fix error `StringIndexOutOfBoundsException`? -

i learning rc4 encryption , try execute script java when run debug on eclipse kepler have error this: exception in thread "awt-eventqueue-0" java.lang.stringindexoutofboundsexception: string index out of range: 4944 @ java.lang.string.charat(unknown source) @ rc4.rc4.enkripsi(rc4.java:309) @ rc4.rc4.jbutton3actionperformed(rc4.java:364) @ rc4.rc4.access$4(rc4.java:362) @ rc4.rc4$5.actionperformed(rc4.java:152) @ javax.swing.abstractbutton.fireactionperformed(unknown source) @ javax.swing.abstractbutton$handler.actionperformed(unknown source) @ javax.swing.defaultbuttonmodel.fireactionperformed(unknown source) @ javax.swing.defaultbuttonmodel.setpressed(unknown source) @ javax.swing.plaf.basic.basicbuttonlistener.mousereleased(unknown source) @ java.awt.component.processmouseevent(unknown source) @ javax.swing.jcomponent.processmouseevent(unknown source) @ java.awt.component.processevent(unknown source) @ java.awt.c

ubuntu - @font-face: Why does this single font letter look different on Windows? -

Image
i've created webfont set using fontsquirrel.com font called interface dalton maag . lowercase letter s looks different , larger other letters. happens on windows , on multiple browsers (tested on chrome 53, safari 5.1, internet explorer 11, firefox 49) . (notice lowercase s letters on jessica , clements) the issue goes away if zoom browser make fonts larger: but doesn't happen on ubuntu (chrome , firefox) is issue windows font rendering? or "font hinting" issue? how can fix this? this "x-height snapping" on truetype (tt) hinting options. had download ttfautohint , manually adjust configurations , hint font file myself before generating derivatives through fontsquirrel.com leaving tt hinting options "keep existing", instead of letting fontsquirrel handle hinting (either using fontsquirrel hinting or ttfautohint hinting) i had set "x-height snapping exceptions" -20 doesn't use "snapping" on sizes le

php - How to display the text of particular item in the modal window by passing the id value in the modal window? -

i have code of html different number of packages given below : <article class="col-lg-4 col-md-4 col-sm-6 col-xs-12 baner-box"> <div class="thumb-pad1"> <div class="thumbnail"> <figure> <img src="images/packages/<?php echo $arr["package_image"]; ?>" alt=""> <h3>hi</h3> <h4>welcome</h4> <p>fggf</p> <div class="package-btn"> <a data-toggle="modal" href="#mymodal"

html - apache2 adding new website -

i'm pretty new apache. want create website hosting apache, here did: created new folder in /var/www/html named 'test' put index.html, js , css files in new folder then tried access website localhost/test, html page displayed, cannot access js , css files. in console says "networkerror: 404 not found - http://localhost/main.js " why '/test' missing url? my index.html has <script type="text/javascript" src="main.js"> can figure out what's wrong? update checked dir.conf , added 'directoryslash on', looks like: <ifmodule mod_dir.c> directoryindex index.html index.cgi index.pl index.php index.xhtml index.htm directoryslash on </ifmodule> noticed when try access http://localhost/test adds '/' end, i'm still getting same error. when use url relative path, computed relative last / in url relative to. since visiting: http://localhost/test test trimmed, , main.js a

Ambiguity in the number of partition in server.properties and in topic creation --partition parameter in apache kafka -

in kafka have created topic ./kafka-topics.sh command. command like ./kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 8 --topic test with 8 partitions topic test, there server.properties configuration in kafka broker, has num.partitions parameter default 1. now specific question not create ambiguity in partition topic test. consider partition mentioned @ time of topic creation or num.partition in server.properties kafka can configured create topics on demand. means if try send message topic not exists, topic created automatically number of partitions specified num.partitions property in server.properties . if going create topic using ./kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 8 --topic test the topic created number of partitions specified --partitions , in case 8, , property num.partitions ignored.

JDBC Fetch from oracle with Beam -

the below program connect oracle 11g , fetch records. how ever giving me nullpointerexception coder @ pipeline.apply(). i have added ojdbc14.jar project dependencies. public static void main(string[] args) { pipeline p = pipeline.create(pipelineoptionsfactory.create()); p.apply(jdbcio.<kv<integer, string>>read() .withdatasourceconfiguration(jdbcio.datasourceconfiguration.create( "oracle.jdbc.driver.oracledriver", "jdbc:oracle:thin:@hostdnsname:port/servicename") .withusername("uname") .withpassword("pwd")) .withquery("select empid,name employee1") .withrowmapper(new jdbcio.rowmapper<kv<integer, string>>() { public kv<integer, string> maprow(resultset resultset) throws exception { return kv.of(resultset.getint(1),

python - OpenCV cv2.rectangle output binary image -

Image
i have been trying draw rectangle on black image, us cv2.rectangle .here code : (it sample, in actual code there loop i.e values x2,y2,w2,h2 changes in loop) heir = np.zeros((np.shape(image1)[0],np.shape(image1)[1]),np.uint8); cv2.rectangle(heir,(x2,y2),(x2+w2,y2+h2),(255,255,0),5) cv2.imshow("img",heir); cv2.waitkey() it giving following output: why image that? why boundaries not line width 5. have tried, not able figure out. can't post in comment, it's negative answer: same operations work me on windows/python 2.7.8/opencv3.1 import numpy np import cv2 heir = np.zeros((100,200),np.uint8); x2=10 y2=20 w2=30 h2=40 cv2.rectangle(heir,(x2,y2),(x2+w2,y2+h2),(255,255,0),5) cv2.imshow("img",heir); cv2.waitkey()

c# - WPF custom composite user controls -

first of all, wpf beginner! approach potentially not right way want not hesitate tell me if case. want composite user control in wpf, using mvvm. some classes better presentation i, here view models: interface iparameter : inotifypropertychanged { string name { get; set;} string value { get; set;} } class textparameter : viewmodelbase, iparameter { private string _value; public string name { get; private set; } public string value { { return _value; } set { _value = value; raisepropertychanged(); } } public textparameter (string name) { this.name = name; } } class parameterlist : viewmodelbase, iparameter { private string _value; public string name { get; private set; } public string value { { return _value; } set { _value = value; raisepropertychanged(); } } observablecollection<ip

How can I manage focus states on an Angular 2 custom input component? -

i cannot find way manage through angular 2 how custom input gets focus label (and for attribute) , how manage states. i'm trying give same focus-and-blur behaviour regular has. ideas on that? thanks! html have tabindex attribute, makes element focusable. http://w3c.github.io/html/editing.html#the-tabindex-attribute then in component can listen focus event: @hostbinding('tabindex') tabindex = -1; @hostlistener('focus') focushandler() { alert('focused!'); }

java - Spring security OAuth 2 -

i have example working spring oauth 2 ( https://github.com/elohalili/oauth ) customized little bit, can not understand 1 thing: in example use resources services should have token oauth server, redirects user log-in page, credentials stored in database not client id , client secret oauth (acme : acmesecret); , in client client id , client secret passed (acme : acmesecret), clients log-in oauth server logged same client id , secret, wrong! my question how can manage client id , secret in dynamic way user logs-in logged own credentials? , how client can know user's client id , secret pass them oauth server? clientid , clientsecret credentials application, want authorize token, not user , password. don't know oauth2 ( https://oauth.net/2/ ) know in oidc ( http://openid.net/connect/ ) there possibility dynamically register new clients. clients applications, not users e.g. person (uses username:password) -> android app/ ios app (client clientid:clientsecret)

Instagram API / Submission Review / Issue with Video Screencast shared on public network -

we use instagram api harvest comments brand page crm solution. from crm solution, agents consult , possibly reply instagram posts. i think appropriate use case plan one: "my product helps brands , advertisers understand, manage audience , media rights" here question: during submission review, need join video screencast of our project. this part annoying as: we don't want share on public platform (like youtube) details of our project , crm solution is there workaround ? you don't need "join" video screencast, need submit video of product functionality (use quicktime screen record), upload video on google drive , share link, instagram seeing it, people u send link able video, not public when sharing google drive, there varrious settings while sharing. need show login flow , api functionality of app. worked me. usecase looks correct app.

How do i show the marker at given position on google map in android? -

i developing app using google map.in want show marker @ location longitude latitude values fetch form server.how show marker @ fetched longitude , latitude value? following code fetch longitude , latitude values server successfully, want show marker on google map fetch langitude , latitude.how do? //java code public class location_track1 extends activity { private static final string tag = "location_track1"; private static final long interval = 1000 * 60 * 1; //1 minute private static final long fastest_interval = 1000 * 60 * 1; // 1 minute private static final float smallest_displacement = 0.25f; //quarter of meter button btnfusedlocation; textview tvlocation; locationrequest mlocationrequest; googleapiclient mgoogleapiclient; location mcurrentlocation; string mlastupdatetime; googlemap googlemap; private imageview mcurrentpointer; private double longitude; private double latitude; // private arraylist<la

unit testing - How to inject mock in parent class with Mockito? -

i'm using mockito mock services.. how can inject mocks in parent class? sample: public abstract class parent(){ @mock message message; } public class mytest() extends parent{ @injectmocks myservice myservice //myservice has instance of message //when put @mock message here works } when run tests message in parent stay null two ways solve this: 1) need use mockitoannotations.initmocks(this) in @before method in parent class. the following works me: public abstract class parent { @mock message message; @before public void initmocks() { mockitoannotations.initmocks(this); } } public class mytest extends parent { @injectmocks myservice myservice = new myservice(); //myservice has instance of message ... } 2) if want use @runwith(mockitojunitrunner.class) above class definition, must done in parent class: @runwith(mockitojunitrunner.class) public class parent { ... note declaring @mock

javascript - Progress of PHP script after file upload -

i know how progress of file being uploaded server using xmlhttprequest progress event tells me when file arrives server. server processes file (moves cloud storage) , progress of in client. i read eventsource , found this example can't send file using that, simple get. is possible upload file , progress of server processing file on single request? (i'm using silex server , angularjs client)

ruby - Error: disable image loading on watir with firefox -

i've got error changing profile watir-webdriver. use following code disable loading images in firefox: profile = selenium::webdriver::firefox::profile.from_name "default" profile['permissions.default.image'] = 2 browser = watir::browser.new :firefox, :profile => profile this error message occur: /var/lib/gems/2.3.0/gems/selenium-webdriver-3.0.0/lib/selenium/webdriver/remote/w3c_bridge.rb:80:in `initialize': unknown option: {:profile=>#<selenium::webdriver::firefox::profile:0x00000000e90700 @model="/home/amvisor/.mozilla/firefox/9ud9suhs.default", @native_events=false, @secure_ssl=false, @untrusted_issuer=true, @load_no_focus_lib=false, @additional_prefs={"permissions.default.image"=>2}, @extensions={}>} (argumenterror) /var/lib/gems/2.3.0/gems/selenium-webdriver-3.0.0/lib/selenium/webdriver/firefox/w3c_bridge.rb:34:in `initialize' /var/lib/gems/2.3.0/gems/selenium-webdriver-3.0.0/lib/selenium/web