Posts

Showing posts from April, 2010

javascript - How do I merge two transparent png files in Cordova -

i have 2 transparent png files identical width , height in cordova/ionic app. wish combine 2 png files new png file of same width , height 1 file overlayed on top of other file. i.e., 1 image layer on top of image. result must transparent png. how can in javascript cordova app? you adding both images canvas create on fly, or have in dom not displayed, read canvas using canvas' todataurl("image/png"). use 2d context on canvas load images in. something like: var canvas = document.getelementbyid('mycanvas'); // or create 1 don't display var ctx = canvas.getcontext('2d'); var image1 = '<image url>'; var image2 = '<image url>'; var image = new image(); var compositeimage; image.src = image1; ctx.drawimage(image, 0, 0); image = new image(); image.src = image2; ctx.drawimage(image, 0, 0); compositeimage = canvas.todataurl("image/png"); compositeimage has data url of composite image can use whatever ...

bash - Replace and increment tag value in XML file with sed -

i'm working in linux , in xml file i'd replace <version> tag value string, when number value incremented 1 one. example if have xml file this: <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://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelversion>4.0.0</modelversion> <groupid>com.rm.core</groupid> <artifactid>rm-dt-agr</artifactid> <version>0.0.1-snapshot</version> <packaging>pom</packaging> <name>rm-dt-agr</name> </project> i'd replace 0.0.1-snapshot in tag <version> 0.0.2-snapshot if it's 0.0.2-snapshot value i'd replace 0.0.3-snapshot , on... i tried use "sed" command without success. this 1 of situation should use tool m...

angularjs - Wait for page redirection in Protractor / Webdriver -

i have test clicks button , redirects user dashboard. when happens webdriver returns: javascript error: document unloaded while waiting result. to fix insert browser.sleep(2000) @ point redirection occurs , assuming cpu usage low, solves issue. however, 2000 ms arbitrary , slow. there browser.waitforangular() wait angular load on redirected page before expect(..) ? it('should create new user', () => { $signup.click(); $email.sendkeys((new date().gettime()) + '@.com'); $password.sendkeys('12345'); $submit.click(); browser.sleep(2000); // need alternative sleep... // doesn't it... // browser.sleep(1); // browser.waitforangular(); $body.evaluate('user') .then((user) => { expect(user).tobe(true); }); }); do think work you? wait 10 seconds url include text 'pagetwo', or whatever put in. var nextpagebutton = $('#nextpage'); nextpagebutton.click().then(function...

multithreading - C++ Passing a reference variable to the thread in g++-4.7.4 -

i need start thread passing complex parameters (std::thread<>) parameter when thread starts. i´m using `std::ref. code works fine updated environments (g++-4.8.2 running on ubuntu). now have compile same code in old compiler (g++4.7.4) , i´m getting errors. the code shown below, error: readerthread.hpp class readerthread { void start(reader reader, synccontroller &synccontroller); } readerthread.cpp void readerthread::start(reader reader, synccontroller &synccontroller) { something... } main.cpp int main() { ...do stuff... /* * create , start reader thread. created object must live * during whole thread life. * std::ref used pass reference */ myreader = readerfactory(params); std::shared_ptr<readerthread> ptr(new readerthread); std::thread th(&readerthread::start, ptr, myreader, std::ref(synccontroller)); ...do other stuff... } error: in file included /usr/gcc-4.7.4/lib/gcc/i...

c++ - Given Two line segments and endpoints, return configurations where segments share endpoint -

i'm stuck on problem we're given starting position (p0) , length (l0) of 1 line segment , starting position (p1) , length (l1) of line segment, , return configurations both segments end @ same point. i'm coding function in c++ returns 1 valid configuration such inputs, or indicates no configuration valid. below files made, utilize eigen c++ libraries. segmentconfigurations.cpp /* segmentconfigurations.cpp : defines utility function calculates * orientation 2 input line segments such share common * endpoint, , other endpoints specified inputs. * details on implementation described in write-up document. */ #include "rotationmatrix.h" #include "segmentconfigurations.h" using namespace std; using namespace eigen; // calculate square of number "x" #define square(x) ((x)*(x)) // calculate magnitude of vector coordinates (x,y,z) #define magnitude(x,y,z) (sqrt((x)*(x) + (y)*(y) + (z)*(z))) /* returns configuration such 2 input line ...

linq.js - get all values from dictionary -

i'm using linqjs in website , i'm trying values of dictionary populated todictionary() library extension. here code: var imagesdictionary = enumerable.from(data) .select(function (x) { var images = enumerable.from(x.imagessections) .selectmany(function (y) { return enumerable.from(y.images) .select(function (z) { return z.thumb; }); }) .toarray(); return { title: x.title, images: images }; }) .todictionary("$.title", "$.images"); var imagestopreload = imagesdictionary.toenumerable() .selectmany("$.value"); i imagestopreload become array of images contained in dictionary can't understand how , this: var imagestopreload = imagesdictionary.toenumerable() .selectmany("$.value"); seems way used obtain that. could me? since appears you're using li...

Meteor Upload to AWS S3 -

Image
i have meteor app in insert document (title, description, customer, ...) database. app using autoform, simple schema , collection2. want add possibility upload file s3. to keep things simple, present filepicker part of 'create document' , once file uploaded, url field (from autoform), should show url of document on s3 (once uploaded) url stored in document collection when create button clicked. realise there might better ways, wanted keep things simple now. i have tried combine tutorial here . upload s3 works, fail url uploaded file stored documents collection. below screenshot shows layout. idea's? my current code can found here . there appear autoform add-on packages address s3 file upload (see "files" section here ), since seem using learning opportunity, i'll try explain how i'd using core meteor. but first, before forget, uploader template child of #autoform has form element of it's own. think cause generated html have nest...

Meteor: Can I copy third party login emails to the root emails key in user document? -

i have collaboration app, depends on user having unique username or email. i planning on using google third party login. i've tested , notice when login google account email available under services key, no email key or username key exists. so have done in accounts.oncreateuser function extract email address , manually create emails key address , verified keys user have if signed up. like this accounts.oncreateuser (options,user) -> unless user.emails? emaildata = address: determineemail(user) * gets [user.services.google.email] verified: false user.emails = [] user.emails.push emaildata if options.profile? if options.profile.name? namearr = options.profile.name.split(" ") firstname = namearr[0] lastname = namearr[1] options.profile.firstname = firstname options.profile.lastname = lastname user.profile = options.profile user so extracting email google services , make email avail...

vb.net - Visual Basic Advanced Browser -

i creating browser in visual basic, having problem saving settings. in advanced options, under privacy tab have browser retain settings after closing window. if click "never remember password", , close window, settings not stored. also, when type url in, after searching url not updated correctly. does have ideas how can make these parts of project work? new coding, tips or ideas add browser welcomed , appreciated see functional. thank you! :d form 1 imports system.net imports system.io public class magycka private declare sub keybd_event lib "user32" (byval volumeupordown byte, byval v1 byte, byval v2 integer, byval v3 integer) private sub magycka_formclosing(sender object, e formclosingeventargs) handles me.formclosing file.delete("c:\magycka\history.txt") each link string in history.lsthistory.items file.appendalltext("c:\magycka\history.txt", link & vbnewline) next each favoritename string in l...

JSONDoc Flows Not Showing in Documentation -

i using jsondoc documentation on rest api , reason flows show description , give error the following errors prevent correct functionality of playground , not provide enough documentation data api users: - no method found id: session_create i have flow constants defined in class follows: public class apiflowconstants { public final static string session_create = "session_create"; public static final string create_rfi = "create_rfi"; public static final string get_rfi = "get_rfi"; public static final string list_rfis = "list_rfis"; public static final string update_rfi = "update_rfi"; public static final string delete_rfi = "delete_rfi"; } i have controller classes annotated this: @apimethod(id = apiflowconstants.create_rfi) @requestmapping(value = "/", method = requestmethod.get) public list<bamrfi> getallrfis(){ java.util.list<bamrfi> rfis = ...

yamldotnet - How to deserialise child classes? -

i have list holds items of same base class of different child classes. how can deserialize this? for example class base { } class child: base { int property { get; set; } } class ser { public list<base> values { get; set; } } thanks the deserializer has no way infer automatically child type expecting. therefore need tell type of child using tag. e.g: yaml - !!child property: 1 - !!child property: 2 c# var deserializer = new deserializer(); deserializer.registertagmapping("tag:yaml.org,2002:child", typeof(child)); var items = deserializer.deserialize<ser>(...); i have put working fiddle here

osx - Cocoa - Multiple NSControls working but not NSTextFields -

i new using interface builder, , building mac os x. have nstableview in main window, nstablecellview subclasses of each have own set of controls. of these controls (there sliders, buttons, etc.) work (they call appropriate action method when use them), except nstextfields, reason can't select or edit. setting in ib indicate should editable. view controller supports nstextfielddelegate protocol, , i've implemented -(bool)acceptsfirstresponder method in view controller return yes . why aren't text fields responsive? for whatever reason, turning off (row) highlighting solves problem, specified in https://stackoverflow.com/questions/7101237/respond-to-mouse-events-in-text-field-in-view-based-table-view . i'm not sure if 1 wanted highlighting, however...

sed - Linux: Remove lines starting with [ -

i know can use grep -v '^#' remove lines starting # now run issues when try remove [ ie. grep -v '^[' or sed '/^[/ d' why happening , how can accomplish this? consider test file: $ cat brackets keep [remove] using grep: $ grep -v '^\[' brackets keep or: $ grep -v '^[[]' brackets keep using sed: $ sed '/^\[/d' brackets keep or: $ sed '/^[[]/d' brackets keep why when computer command fails work expected, important @ error message. consider: $ grep -ve '^[' brackets grep: invalid regular expression the error message reporting invalid regular expression found. because [ regex-active character: [...] used define character list. thus, if regex contains unescaped [ , must contain matching ] . there 2 ways avoid this: escape it. if [ regex-active character, \[ treated regular (inactive) character. put in character list. [[] character list matches 1 character: [ . ...

python 3.x - Image doesn't load in pygame -

i'm having trouble uploading image in pygame. here's code. import pygame, sys pygame.locals import * def capitals(): pygame.init() displaysurf = pygame.display.set_mode((500, 400)) pygame.display.set_caption('capitals') black = ( 0, 0, 0) white = (255, 255, 255) red = (255, 0, 0) green = (0, 255, 0) blue = (0, 0, 255) displaysurf.fill(white) displaysurf=pygame.image.load('usa.jpg').convert() while true: event in pygame.event.get(): if event.type==quit: pygame.quit() sys.exit() pygame.display.update() the picture isn't having problem loading on python page, there no "cannot open file error", on actual pygame window, image isn't loading. to display image on screen, have draw on display surface (using blit ). doing here displaysurf=pygame.image.load('usa.jpg').convert() is loading image , assign displaysurf variable. so use instead: im...

ios - Provisioning profile is downloaded but cannot choose -

Image
i have provisioning profile, allows push notifications , spent long time working getting right. figured out , push notifications work! updating same app reason cannot choose right profile. when choose profile submit with, cannot pick right profile but here when click on accounts in xcode! it's inschoollawpushnotificationsproduction. i have found file , double clicked it, dragged onto xcode on dock, everything. have tried other xcode projects, nothing except profiles in first image showing up! do? please double check followings check if identifier same in profile , in app. make sure select profile in settings select right certificate. when going upload choose same account used create profiles , certificate.

c - How to fix console return of malloc(): memory corruption (fast) -

when ran program, console output showed following: malloc(): memory corruption (fast) , followed seemed address in memory. have narrowed down few functions, feel free memory allocate properly. the following function takes string representing file name. void readandprocessfile(char* filename){ file *fileptr; char* word = malloc(32*sizeof(char)); fileptr = fopen(filename, "r"); while(fscanf(fileptr,"%s",word) != eof){ processword(word); } fclose(fileptr); free(word); } this function takes word, removes non-alphabetic characters , changes letters uppercase. void processword(char* text){ char* processedword; processedword = trimandcaps(text); if(processedword != null && processedword[0] != '\0'){ addword(processedword); } free(processedword); } here's trim , cap function char* trimandcaps(char* text) { int = 0; int j = 0; char currentchar; char* rv =...

javascript - Not able to access ms crm page using "parent.window.xrm.page" from aspx page through chrome -

we getting exception "blocked frame origin "https:domain1:port1" accessing frame origin "https:domain1:port2". protocols, domains, , ports must match". @ code "window.parent.xrm.utility.openentityform("entityname", null, parameters, windowoptions);" in ms crm 2015 we loading custom page in sitemap(not in iframe of entity) providing cutomwebapps’url @ sitemap level. when trying access xrm of parent page getting above error. this working fine in ie11 fails above error in chrome , firefox. did faced issue? please help. thanks i think running cross frame scripting issues here more browsers in general crm. there content here suggests using window.postmessage instead. there further links in article provide additional detail. there times when want enable communication iframe contains content on different domain. window.postmessage browser method provides capability versions of internet explorer no earlier i...

c++ - When to use `asio_handler_invoke`? -

question when necessary use asio_handler_invoke achieve cannot done wrapping handler? a canonical example demonstrates case asio_handler_invoke required ideal. background the boost asio docs contain example of how use asio_handler_invoke here , don't think compelling example of why use invocation handler. in example appears make changes following (and remove asio_handler_invoke ) , achieve identical result: template <typename arg1> void operator()(arg1 arg1) { queue_.add(priority_, std::bind(handler_, arg1)); } similarly, in answer relating handler tracking appears unnecessary use asio_handler_invoke , despite tanner sansbury's answer suggesting using invocation hook solution. this thread on boost user group provides more information - don't understand significance. from have seen, appears asio_handler_invoke called asio_handler_invoke(h, &h) , doesn't appear make sense. in cases arguments not (essentially) copies of same object?...

javascript - Differences of ecommerce and enhanced ecommerce of Google Analytics -

i learn google analytics, ecommerce, , enhanced commerce, implemented on website. actually, else implemented google analytics , ecommerce, , maybe enhanced ecommerce, right tried understand code , implement enhanced commerce if hasn't been implemented. is ecommerce object starting "ecommerce:" ? ga('ecommerce:'...) ? noticed enhanced ecommerce has prefix of "ec:". "ecommerce:" , "ec:" interchangeable? btw, found documentation @ google, stated the enhanced ecommerce plug-in should not used alongside ecommerce (ecommerce.js) plug-in same property. this raised concern, don't know this. mean have remove previous ecommerce implementation? cannot set new track object , track id enhanced ecommerce. thanks. the core difference between enhanced ecommerce , standard ecommerce latter tracks transactions on order confirmation/thank-you page only, whereas former allows track transaction processes adding cart, payme...

Passing a table as argument to function in Lua -

i want loop through different indexed tables passing initial table argument. have table: local table = { stuff_1 = { categories = {}, [1] = { name = 'wui', time = 300 } }, stuff_2 = { categories = {'stuff_10', 'stuff_11', 'stuff_12'}, stuff_10 = { categories = {}, [1] = { name = 'peo', time = 150 }, [2] = { name = 'uik', time = 15 }, [3] = { name = 'kpk', time = 1230 }, [4] = { name = 'aer', time = 5000 } }, stuff_11 = { categories = {}, [1] = { name = 'juio', time = 600 } }, stuff_12 = { categories = {}, [1] = { name = 'erq', time = 980 }, [2] = { name = '...

Android Studio opencv C++ compile link libraries error at runtime -

i'm using android studio 1.3.2 gradle 2.6 experimental ndk. this error: dlopen("/data/app/face.rt.jeanc.facert-2/lib/arm/libface.so", rtld_lazy) failed: dlopen failed: "/data/app/face.rt.jeanc.facert-2/lib/arm/libface.so" has unexpected e_machine: 40 also, lib face should appears libface.so in folders (armabi, armabi-v7, etc) doesn't appear (compile ?) here build.gradle: apply plugin: 'com.android.model.application' model { android { compilesdkversion = 23 buildtoolsversion = "23.0.1" defaultconfig.with { applicationid = "face.rt.jeanc.facert" minsdkversion.apilevel = 19 targetsdkversion.apilevel = 19 versioncode = 1 versionname = "1.0.1" } } android.buildtypes { release { minifyenabled = false proguardfiles += file('proguard-rules.txt') } } and...

Python File Output, Looping, and Increasing -

number = 1 name = 'frames' + str(number) + '.html' usednumbers = [] if number in usednumbers: number += 1 else: open(name,'w') how go doing 'number' increases 1, puts out html document, until gets 18, stops before gets 19? ("frames1.html. frames2.html, ..., frames18.html") just use loop, like: for number in range(1,20): # rest of stuff. resources on for loops , range .

php - SyntaxError: expected expression, got '<' JQuery -

<script> $(document).ready(function(){ $(function() { $("#country").val("<?php echo $_session['country'];?>"); }); }) <td>country:</td> <td colspan="2"><select name="country" id="country"> <option value="93">93-afghanistan</option> <option value="355">355-albania</option> <option value="213">213-algeria</option> <option value="1-684">1-684-american samoa</option> <option value="376">376-andorra</option></td> i trying select drop-down list based on users selection. code given 1 of current user there syntax-error occur. can solve this? the best solution problem go thrrough appropiate selection , below - $(document).ready(function(){ var v="<?php echo $_session['country'];?>"; $('#country...

Split a string(a word) to letters in C -

i need string split letters , save in array .i have no clue how .its possible in c++ in c seems there no way do. or if there way take input string(a word )and save separate letters in array ideal .i have used below mentioned code input #include <stdio.h> #include <stdlib.h> #include <math.h> #include<string.h> int(){ char inputnumber; printf( "enter number" ); // word --> hellooo scanf("%s", &inputnumber); int i=0; printf(inputnumber[i]); } update: solved ,i did not declare pointer char here ,that's part missing can read word letter letter ,thanks look @ code , see mistakes #include <stdio.h> // #include <stdlib.h> // dont need // #include <math.h> // or // #include<string.h> // or //int(){ int main (){ // <-- int main here printf( "enter number" ); // declare...

Can't create new vagrant box from existing created one -

i have problem while creating new vagrant box existing created one. means trying create new box base box hashicorp/precise64 , created e.g. name : first_box.box . but, while trying create anothe new box using first_box.box base box , it's not created, looks created hashicorp/precise64 not first_box.box , details please see commands below: first step, vagrantfile this: vagrant.configure("2") |config| config.vm.define "first" |first| first.vm.box = "hashicorp/precise64" first.vm.network "private_network", ip: "192.168.31.10" first.vm.hostname = "firstserver" first.vm.synced_folder "/home/eman/dev", "/home/vagrant/dev" end end and run commands: vagrant box add hashicorp/precise64 vagrant up vagrant ssh sudo apt-get update sudo apt-get install bla-bla-bla exit vagrant package --output first_box.box now have first_box.box inside vagrant directory. and con...