Posts

Showing posts from February, 2010

Accessing DOM elements and composition lifecycle for non-viewModels in Aurelia -

i have application closely tied dom. need keep track of size , position of elements represent objects behind them. myviewmodel.js export class myviewmodel { // root view model has important properties // other functions , objects need use constructor() { this.importantproperty = 'veryimportant'; this.things = []; } // create things in view model // represented in dom creatething() { this.things.push({ isathing: true }); } // things things in view model // depend on root view model dosomethingwiththing(thing, property) { thing[property] = `${this.importantproperty}${property}`; } // need know dom representation // of things in view model doanotherthingwiththing(thing) { console.log(`the height of thing ${thing.height}`); } lookandseewhatsizethisthingis(element, thing) { thing.height = element.clientheight; thing.width = el

Cascading: Merge tuple if Join is unavailable -

here's issue: i have 2 tables id field match on. of them match, if don't, need merge record other table , make empty fields null. is kind of thing possible in cascading? thanks! you can use cogroup along left/right/outer join matches requirement.

javascript - Protractor + Safari non-secure form warning -

Image
os: os x el capitan node: v5.4.1 protractor: 3.3 safari: 9.0.3 i'm getting security warning popup in in test , wondering if there way around in fashion. popup security warning doesn't seem come on chrome , browser.switchto().alert(); doesn't seem work? this alert/security warning looks like apparently block mixed content , doesn't seem there option anymore change why mixed content blocked in safari i have tried press tab enter b/c works manually seems give error when use code browser.actions().sendkeys(protractor.key.tab).sendkeys(protractor.key.enter).perform(); failed: unknown command: {"id":"z4v9sab7uay","name":"sendkeystoactiveelement","parameters":{"value":[""]}} (warning: server did not provide stacktrace information)

ruby - FFmpeg extracts different number of frames when using -filter_complex together with the split filter -

i fiddling ffmpeg, extracting jpg pictures videos. splitting input stream 2 output stream -filter_complex, because process videos direct http link (scarce free space on vps), , don't want read through whole video twice (traffic quota scarce). furthermore need 2 series of pitcures, 1 applying filters (fps changing, scale, unsharp, crop, scale) , selecting them naked eye, , other series being untouched (expect fps changing, , cropping black borders), using them furter processing after selecting first series. call ffmpeg command ruby script, contains string interpolation / substitution in form #{}. working command line looked like: ffmpeg -y -fflags +genpts -loglevel verbose -i #{url} -filter_complex "[0:v]fps=fps=#{new_fps.round(5).to_s},split=2[in1][in2];[in1]crop=iw-#{crop[0]+crop[2]}:ih-#{crop[1]+crop[3]}:#{crop[0]}:#{crop[1]},scale=#{thumb_width}:-1:flags=lanczos,unsharp,lutyuv=y=gammaval(#{gammaval})[out1];[in2]crop=iw-#{crop[0]+crop[2]}:ih-#{crop[1]+crop[3]}:#{crop[0

buildbot scheduler not working -

i have same problem discussed here buildbot scheduler not work , answer there may not apply -- possibly because i've got newer version of buildbot >buildbot --version buildbot version: 0.8.12 twisted version: 16.2.0 running on windows 7 64-bit. i'd svn commit trigger buildbot builders, instead, periodic scheduler (when enabled) triggers builders. log shows 2016-06-10 11:40:18-0700 [-] svnpoller: polling 2016-06-10 11:40:18-0700 [-] svnpoller: svnurl=file:///g:/buildbot/buildbot_repo/trunk/triggers_for_testing, root=file:///g:/buildbot/buildbot_repo, prefix=trunk/triggers_for_testing 2016-06-10 11:40:18-0700 [-] svnpoller: starting @ change 31 2016-06-10 11:40:18-0700 [-] svnpoller: _process_changes none .. 31 2016-06-10 11:40:18-0700 [-] svnpoller: finished polling none 2016-06-10 11:40:38-0700 [-] svnpoller: polling 2016-06-10 11:40:38-0700 [-] svnpoller: _process_changes 31 .. 32 2016-06-10 11:40:38-0700 [-] adding change revision 32 2016-06-10 11:40:38-0700 [-

jsf 2 - primefaces datatable with checkboxes are processing selects when are marked -

i have 1 datatable multiple selection (checkboxes). every time checkboxes marked, executed select of datatable again. xhtml: <p:datatable id="dtusuarios" widgetvar="usuarios" value="#{configgruposusuariosmb.usuarios}" var="usuario" paginator="true" rows="10" paginatorposition="bottom" scrollable="true" scrollheight="82%" rowsperpagetemplate="5,10,15,30,50,100" paginatortemplate="{currentpagereport} {firstpagelink} {previouspagelink} {pagelinks} {nextpagelink} {lastpagelink} {rowsperpagedropdown}" emptymessage="#{i18n.datatablevazia}" lazy="true" currentpagereporttemplate="{currentpage}/{totalpages} #{i18n.paginas} - {startrecord} #{i18n.a} {endrecor

Can't get if statement to compare two strings in javascript -

Image
in code when i equals 5 mydate should equal it. alert shows me same. can never function return 1; function checkforholiday(date) { var mydate = new date(date); mydate = mydate.getmonth() + "/" + mydate.getdate() + "/" + mydate.getfullyear(); alert(mydate + "\n" + holidays[5]); (i = 0; <= 9; i++) { if (mydate == holidays[i]) { return 1; alert("got it"); } } return 0; } this string in array looks like: year = 2013 holidays[5] = "7/2/" + year my alert shows me this: i have run code locally, , have working. i'm going guess issue stems fact date.getmonth() returns month numbers january === 0. throws lot of people off. to recreate code, used chrome's console. changed alert console.log save myself hassle of using alert . here's code: function checkforholiday(date) { var mydate = new date(date); mydate = mydate.getmonth() +

Making API call using swift -

i total noob when comes ios coding. im trying learn how make api call " http://de-coding-test.s3.amazonaws.com/books.json " however, since i'm total noob, tutorials find make no sense how it. want learn how can json data web , input uitableviewcell i have looked through 3 dozen tutorials, , nothing makes sense. any appreciated. let's going step: 1) framework you're going use make api call nsurlsession (or library alomofire, etc). an example make api call: func getbooksdata(){ let url = "http://de-coding-test.s3.amazonaws.com/books.json" (nsurlsession.sharedsession().datataskwithurl(nsurl(string: url)!) { (data:nsdata?, response:nsurlresponse?, error:nserror?) -> void in //here we're converting json nsarray if let jsondata = (try? nsjsonserialization.jsonobjectwithdata(data!, options: nsjsonreadingoptions.mutableleaves)) as? nsarray{ //create local variable save data receive v

Elasticsearch dynamic synonym update -

we need develop possibility of dynamic synonyms update without node restart or index close/open. decided implement our own synonym functionality, basic idea have our own storage synonyms , each time process request, check query string synonyms stored in our synonym storage. question is, how implement query returns document match query string or of synonyms word(or phrase) query string? important point, how synonyms particular original word(or phrase) score once?

java - dealing with multiple player thread and repainting -

i working on java bomber-man game, game works fine have concurrent modification exception thrown repeatedly. in game have 2 players , each have own thread run (thread.run()) @ constant 60fps using timer. tried having repainting run after bother thread run @ end of each player run method. method 1: public void loop(){ if(!gameover){ player1_thread.run(); //run player 1 thread player2_thread.run(); //run player 2 thread gui.repaint() //repaint panel } method 2: public class player extends character{ //character implements runnable ... @override public void run(){ play(); ... game.render(); } both of these method throws concurrent modification expected how can avoid error other doing: player1.run(); //call run method of each player class player2.run(); which gives player1 advantage. edit: method 4: import java.util.timer public class player extends character { //character implements runnable private timer gametimer @ovveride public void run(){

python - Can we use a Pandas function in a Spark DataFrame column ? If so, how? -

Image
i have pandas dataframe called "pd_df". i want modify it's column , this: import pandas pd pd_df['notification_dt'] = pd.to_datetime(pd_df['notification_dt'], format="%y-%m-%d") it works. on same database, created spark dataframe called "spark_df" i want same function (pd.to_datatime) on it's column perform same operation. did this. pyspark.sql.functions import userdefinedfunction pyspark.sql.types import timestamptype udf = userdefinedfunction(lambda x: pd.to_datetime(x, format="%y-%m-%d"), timestamptype()) spark_df2 = spark_df.withcolumn("notification_dt1", (udf(spark_df["notification_dt"]))) it should work, according me. on spark_df.show() i encounter following error after minute or so: so, got fixed. udf = userdefinedfunction(lambda x: pd.to_datetime(x, format="%y-%m-%d"), timestamptype()) should be udf = userdefinedfunc

java - ListView Not Showing Up -

i trying listview display, not. have read through other posts , unable find problem. here snippet set adapter. have checked debugger , not set null afterwards. tournaments = (arraylist) datasnapshot.getvalue(); adapter = new arrayadapter(admincontrol.this, android.r.layout.simple_list_item_1, tournaments); list.setadapter(adapter); here xml content file: <?xml version="1.0" encoding="utf-8"?> <relativelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingbottom="@dimen/activity_vertical_margin" android:paddingleft="@dimen/activity_horizontal_margin" android:paddingright="@dimen/activity_horizontal_margin" an

python 2.7 - Exception: Invalid object array with comtypes -

i try implement simple copy operation between 2 autocad documents via com in python. from pyautocad import autocad, apoint comtypes.client import getbestinterface # acad application acad = autocad(create_if_not_exists=true) # create new document doc1 = getbestinterface(acad.application.documents.add()) # add circle in document , make visible circle = getbestinterface(doc1.modelspace.addcircle(apoint(0.0, 0.0), 1.0)) doc1.application.zoomextents() # create document doc2 = getbestinterface(acad.application.documents.add()) # , copy circle new document doc1.copyobjects([circle], doc2.modelspace) this throws: traceback (most recent call last): file "copy_bug.py", line 13, in <module> doc1.copyobjects([circle], doc2.modelspace) file "anaconda2\lib\site-packages\comtypes\__init__.py", line 655, in call_with_inout rescode = func(self_, *args, **kw) _ctypes.comerror: (-2145320837, none, (u'invalid object array', u'autocad.application&

ruby - Editing new products in my seeds.rb file creates a copy instead of editing the file I changed -

i'm new ruby , rails appreciate feedback. in web application, have 6 products added products page through seeds.rb file encountered problem every time try edit 1 of them. once i'm done edit, run rake db:seed , reload webpage (local host) instead of showing edit on item changed, new version of updated item shows instead of running edit. example, if change color of 1 of bikes , save changes in seeds.rb file, run rake db:seed , reload page, copy of item edited shows instead of changing color field on existing item. code in seeds.rb web app i wondering if there i'm missing. solution has been delete product through "destroy" button on page , run rake db:seed again. if i'm doing wrong, i'd appreciate if guys point me in right direction. thanks! try doing rake db:reset after edit seeds.rb. although it's worth noting rake:seeds reserved initial creation of app. should editing through app (using localhost:3000/products/:id/edit )

Where can you find http timings in the glimpse popup window? -

Image
the glimpse javascript panel shows nice summary of http timing information. time spent on wire, time on server, etc.... however when view information using pop out, information no longer accessible. can't find http timings anywhere. there anyway view information without viewing directly through javascript injected panel? unfortunately, @ point, answer no. there has been some community work bring full data set available the navigation timing api glimpse. that effort bit stale now, if you'd pick you'd able not http timings, of following: navigationstart unloadeventstart unloadeventend redirectstart redirectend fetchstart domainlookupstart domainlookupend connectstart connectend secureconnectionstart requeststart responsestart responseend domloading dominteractive domcontentloadedeventstart domcontentloadedeventend domcomplete loadeventstart loadeventend and it work in browsers (excluding oldie).

python - Variable greater than -

is possible make variable in python equal number greater number? example: x = >26 pretty wondering trying trying make if number in list of integers on 26 take number , change number under 26 depending on number is. sorry 1 small thing in bigger project hard explain all yes, you can customize class's behaviour in comparison operations behaviour. class equaltoanygreaterthan(object): def __init__(self, n): self.n = n def __eq__(self, other): return other > self.n def __ne__(self, other): return other <= self.n egt26 = equaltoanygreaterthan(26) print egt26 == 1 # false print egt26 == 26 # false print egt26 == 27 # true print egt26 == 99 # true print 21 == egt26 # false print 89 == egt26 # true print 21 != egt26 # true print 89 != egt26 # false

Wicket Checkbox onUpdate not being called on JQuery changing check state -

i have data table i've added panel holds checkbox in cell. have panel has checkbox use select checkboxes in data table. select done jquery , jquery in code below. how can onclick or onchange event called when jquery select checkbox checked? i've tried using ajaxcheckbox below event not being called. private static list<checkbox> checkboxes = new arraylist<checkbox>(); private static class actionspanel extends panel { public actionspanel(string id, imodel<workordercustomer> model, final string uuid ) { super( id ); ajaxcheckbox checkbox = new ajaxcheckbox("checkbox", model.of(boolean.false)) { private static final long serialversionuid = 1l; @override protected void oncomponenttag(componenttag tag) { super.oncomponenttag(tag); tag.append("class", uuid, " "); } @override protected void onupdat

c++ - Search for value in multi map -

suppose have following: class foo { public: foo(int x) { _x = x; } int _x; } int main() { multimap<string, foo> mm; foo first_foo(5); foo second_foo(10); mm.insert(pair<string, foo>("a", first_foo)); mm.insert(pair<string, foo>("a", second_foo)); foo third_foo(10); } what's nice way of checking if third_foo key "a" in multimap ? use multimap::equal_range fetch range of iterators entries have key "a" . use any_of check if of values compare equal foo want. auto const& r = mm.equal_range("a"); bool found = std::any_of(r.first, r.second, [&third_foo](decltype(mm)::value_type const& p) { return p.second._x == third_foo._x; });

android - stand alone broadcast receiver for Download Manager -

i have broadcastreceiver listens download complete action opens file when download completes. my issue user may download file , minimize screen unregisters broadcastreceiver , file isn't opened automatically when download completes. how can set stand alone broadcastreceiver image opened when app stopped/destroyed. can't figure out how make listen download complete action. private broadcastreceiver downloadreceiver = new broadcastreceiver() { @override public void onreceive(context context, intent intent) { long referenceid = intent.getlongextra(downloadmanager.extra_download_id, -1); if (downloadreference == referenceid) { downloadmanager.query query = new downloadmanager.query(); query.setfilterbyid(referenceid); cursor cursor = downloadmanager.query(query); if (cursor.movetofirst()) { int status = cursor.getint(cursor.getcolumnindex(downloadmanager.column_status));

Place to put parameter object in rails -

i'm new rails guy , have problem structure of rails. my application structure this - app - controllers -- orders_controller.rb - services -- get_customer.rb orderscontroller receive create order request , return new order. because order belongs customer. create service name getcustomer in order find or create new customer if not exists. however, action method in getcustomer service receive long parameters. need extract parameter object. don't know place should put in ? any advice graceful me ! thanks hi questions not specific though here answer based on asked. in service can set instance variable specific param want. example below: def initialize(params) @phone= params[:phone] @something = params[:somthing] @email = params[:email] end you have list specific code if more specific answer.

c# - Float array of samples to WAV file format -

i working on application applies filters on sound files, filters applied in frequency domain samples .wav file using naudio library code : audio = new audiofilereader(wav_file); samples = new float[wave.length]; audio.read(samples, 0, samples.length); after applying previous code, have samples array of float, apply short-time fourier transform on samples getting frequency domain data, , filters applied on frequency domain data. , inverse short-time fourier transform applied on frequency domain data convert time domain should similar initial samples filters applied. steps again: get samples (time domain data) array wav file. apply short-time fourier transform on samples frequency domain data. apply filters on frequency domain data. apply inverse short-time fourier transform on frequency domain data samples (time domain data). convert samples wav form again save , play it. now problem in last step, have float array of samples (time domain data), how convert .wav file

html - How do you force a column div to be the same height of its row? -

this question has answer here: how can make bootstrap columns same height? 28 answers i'm in process of learning bootstrap , struggling hard. know default row height in bootstrap whatever height able contain child element (i.e. column). however, default height of column take minimum amount of space. so question: how force height of column take height of row? let's have 2 columns in row. height of 1 column greater other due contents of column being more. how force sibling column same height? i feel i've tried , having no luck. i've tried using flex properties, table properties, nothing working. also, practice me modifying css of bootstrap classes? couldn't possibly break entire framework? tldr: best method declaring div heights in bootstrap? as example, how both of 'hello there' divs occupy same height in same row? <!doct

php - Check duplicate data in CodeIgniter try to make a callback function -

i have registration form. here i'm able check duplicate email custom unique call function (don't try use is_unique). doesn't returns anything. here code. controller - public function add_member () { $this->load->library('form_validation'); $post_email = $this->input->post('email_id'); $this->form_validation->set_rules('email_id', 'email id/ username', 'required|trim|xss_clean|valid_email|callback_check_duplicate_email[' . $post_email . ']'); $this->form_validation->set_rules('password', 'your password', 'required|min_length[5]|max_length[12]|matches[confirm_password'); $this->form_validation->set_rules('confirm_password', 'password confirmation', 'required'); $this->form_validation->set_message('check_duplicate_email', 'this email exist. please write new email.'); if ($this->form_valida

botframework - Starting a conversation with Microsoft bot builder and microsoft bot framework -

i tried have bot start conversation user don't know in code should send message from. documentation starting convo here, it's not super helpful: http://docs.botframework.com/connector/new-conversations/#navtitle . tried replying in handlesystemmessages (which works emulator if change message type) still won't send first message. i'm using microsoft bot connector , c#. // idk how syntax highlighting in stackoverflow // code messagecontroller class public async task<message> post([frombody]message message) { if (message.type == "message") { return message.createreplymessage($"you said:{message.text}"); } else { return handlesystemmessage(message); } } i spent lot of time researching issue. result, managed initiate sending message on behalf of bot. example sends message group conversation. code below - rough draft works: class program { static

Bing Geocode api not working with Singapore addresses -

i tried several valid address bing map api not returning result: http://dev.virtualearth.net/rest/v1/locations?admindistrict=singapore&countryregion=sgp&postalcode=449269&addressline=80%20marine%20parade%20rd&key=mykey any ideas? there 3 ways resolve issue; instead of passing in singapore admindistrict (i.e. state/province), pass in using locality property (city). alternatively pass in both of properties. remove postal code query. instead of using structured address, pass in address query. recommended in best practices , increases odds of correct result being found: https://msdn.microsoft.com/en-us/library/dn894107.aspx

ios - Xcode Push Notifications Issue -

i'm trying enable push notification on project i'm getting error i went app id , saw enabled well. when looking @ certificated, saw i'm getting "this certificate has invalid issuer" on certificated created. main source of problem? i appreciate insight , in advance! :) download certificate , add inside keychain first close xcode because accessing certificates thats why , delete expire or invalid certificate keychain , restart mac download certificate , add keychain. https://developer.apple.com/certificationauthority/applewwdrca.cer i hope you.

C++ column chart is reversed -

i'm stumped on why columns reversed. actual column graph (asterisks only) needs flipped horizontally. (the population in 1900 2000 , population in 2040 24000.) here looks like: population column chart 24000 ** 23000 ** 22000 ** ** 21000 ** ** 20000 ** ** 19000 ** ** 18000 ** ** ** 17000 ** ** ** 16000 ** ** ** 15000 ** ** ** 14000 ** ** ** ** 13000 ** ** ** ** 12000 ** ** ** ** 11000 ** ** ** ** 10000 ** ** ** ** 9000 ** ** ** ** ** 8000 ** ** ** ** ** 7000 ** ** ** ** ** 6000 ** ** ** ** ** 5000 ** ** ** ** ** ** 4000 ** ** ** ** ** ** ** 3000 ** ** ** ** ** ** ** 2000 ** ** ** ** ** ** ** ** 1000 ** ** ** ** ** ** ** ** 1900 1920 1940 1960 1980 2000 2020 2040 and here's code: #include <fstream>

c++ - When does it make sense to have separate implementations for operator== and operator!=? -

i heard c++ enables overriding both operator== , operator!= because in cases a != b can implemented more efficient !(a == b) . i've thought , can't imagine case true. what examples makes sense, performance-wise or other, have separate implementations operator== , operator!= ? the first example comes mind implementations analogous null value sql. in that, comparing 2 objects—either of null—does not mean equal. if both not null makes sense return equality.

Hiding Border On HTML Button -

i'm having little trouble button i'm making part of sharepoint site. appears http://imgur.com/n9m6ffx i edit code grey border not appear around blue image i've had no luck getting work. current code pretty simple , can found below: <button onclick="hideshow()" type="button"> <img src="training%20libraries.png" style="width: 117px; height: 33px;"/> </button> use border: none; for button

java - Component disappears randomly in the SOUTH position when using BorderLayout and pack() -

i have rather mysterious problem when using borderlayout. when place jbutton in center position , component (say jlabel) in south, latter 1 disappears randomly. here example. see problem you'll have resize window larger size , move mouse cursor on screen bit (on off button, label, window title bar, windows taskbar, edges of screen). don't need press button. after few seconds of such movements label disappears. reappears if resize or minimize/restore window again. the strange thing is, pack() seems important, don't observe problem in use e.g. setsize(600,300) on jframe instead. seems center component must jbutton, while south component can (i tried jlabel, jcheckbox), , positions (south , center) important. not happen if button placed north, example. it easy avoid situation in practice, of course, still know why happens, , whether did wrong or unsafe. using jdk 8 release 77 on windows 10. import java.awt.*; import java.awt.event.*; import javax.swing.*; public c

git - Android Stuidio 2.1.2 enable version control integration -

Image
most sources go to, including this question , many of top google search results , there should option under vcs menu says "enable version control integration", don't have one. this menu looks like: (submenus can provided if needed) i'm running android studio version 2.1.2 on ubuntu 12.04 lts i remember accidentally enabling version control before, i've been unable since then. i know isn't enabled because option git add grayed out whenever try add file , filenames not colored based on whether or not added. try deleting vcs.xml file .idea folder of project

python - pytest -> How to use fixture return value in test method under a class -

i have fixture returns value this: import pytest @pytest.yield_fixture(scope="module") def onetimesetup(browser): print("running 1 time setup") if browser == 'firefox': driver = webdriver.firefox() print("running tests on ff") else: driver = webdriver.chrome() print("running tests on chrome") yield driver print("running 1 time teardown") this fixture gets browser value fixture reading command line option. then have test class have more 1 test methods , want consume same returned value driver proceed tests. import pytest @pytest.mark.usefixtures("onetimesetup") class testclassdemo(): def test_methoda(self): # use driver value here # how this? # self.driver.get("https://www.google.com") self.driver.find_element(by.id, "some id") print("running method a") def test_method