Posts

Showing posts from September, 2011

sed - Bash: How to Remove Multiple Prefix Variants From a String -

i'm trying remove prefix of url string parsed package.json file using bash. issue found not enters repository:url consistently in package files. e.g.: git+https://github.com/<user>/<repo>.git https://github.com/<user>/<repo>.git and have found: http://github.com/<user>/<repo>.git so question is, how remove either string prefix might found in .json? below unsuccessful attempt. repo_url="`node -pe 'json.parse(process.argv[1]).repository.url' "$(cat $pkg_json)"`" repo=${repo_url#git+} repo=${repo_url#https://github.com/} repo=${repo%.git} echo "${repo}" update: i discovered adding wildcard before prefix eliminate before , including prefix. how handle http ? e.g.: repo=${repo_url#*https://github.com/} each of assignments repo uses original $repo_url source, removals previous assignment aren't maintained. should use $repo source, except first one: repo_url="`node -

php - Where should the credentials for mysql be put? -

logging mysql database requires credentials. have these credentials in php class called class.dbone.php . this in git repo on server. use push deploy. i want share repo contract devs, don't want them have access credentials. how mitigate this? are credentials supposed be? here snippet: <?php // creates 1 instance of database class dbone { private $db_user = 'foo'; private $db_pass = 'foo'; private $db_driver = 'mysql:dbname=foo;host=localhost'; // singleton uses static variable ensure 1 instance @ time private static $database; private function __construct() { $this->checkforcleardb(); // self::checkforclearpostgres(); try { // instaniate database connection self::$database = new pdo( $this->db_driver, $this->db_user, $this->db_pass ); } catch( pdoexception $pdoerror ) {

c# - Getting height/width from a unity gameobject -

i'm working on version of conway's game of life in unity, , here setup making grid: i've created prefab of individual cell responding mouse click basis creating cell grid. have empty gameobject act controller create grid. i'm putting in code controller so, pointing prefab field: [serializefield] private gameobject cell; private camera _camera; my idea dimensions of cell , instantiate grid, _camera pointing main camera boundaries. however, i'm not sure how height/width gameobject. what's best way find out? i don't know if found answer, common way using collider (if have one, mouse click needs it) or renderer (if have mesh) using: getcomponent<collider>().bounds.size getcomponent<renderer>().bounds.size game of life nice, i've written paper bachelor seminar it. have fun!

linux - Ansible "missing become password" on one machine but not another -

the situation this: machine on target machine b, run below shell code , completes successfully. machine on target machine c, run below shell code , gives me "become password missing". can log both machine , b credentials without being prompted sudo password or anything. i go ansible.cfg , uncomment ask_sudo_pass , causes code prompt me sudo password request. however, want automate dozens of machines, can't enter sudo password every 1 every time use this. i'm in process of setting ssh keys these machines, there's been delays there need way automate in short term. suggestions please? these shell commands i'm using: export ansible_host_key_checking=false sshpass -p ${ssh_password} ansible-playbook -i hosts site.yml -u ${ssh_username} --extra-vars="ssh_user=${ssh_username}" i remove password of user on target passwd --delete username and rely on id_rsa connect, of course "username" on target part of wheel group. you can

dependency injection - gcc linking of shared libraries: secondary dependencies with $ORIGIN -

this follow-up question this one . i understand using $origin in -rpath option generates dynamic absolute path point specified location - no matter use library. what's confusing me, following: use library generate shared binary , set (again) -wl,-rpath option using $origin enable binary find library. original $origin value of library not available anymore or wrong because seems overwritten new one. somehow understandable since generating new shared object - binary - has own $origin . way around this, provide binary's -rpath both locations, 1 library , 1 library needs. in opinion makes -rpath useless, because can't link library , specify location need specify library's dependency location. my question: there way specify hierarchical -rpath values using $origin ? avoid absolute paths, fix issue.

javascript - Babel: The CLI has been moved into the package `babel-cli` -

i working on js file @ work had babel installed, running babel file.js | node sent file home work in evening, installed babel @ home , got following error when run above command: the cli has been moved package 'babel-cli' any ideas? thank in advance :) if install cli - following code fails compile: function sumarrayindex(array, i, separator) { return array .map(x => x.split(separator) .map(c => { return parseint(c) }) ) .map(x => { return x[i]; }) .reduce((x, y) => { return x += y }, 0); } function mintosec(m) { return m * 60 } function secondstominutesandseconds(s) { var min = s / 60; var sec = s % 60; minutes += math.floor(min); seconds += sec; } function outputtime() { return hours + ':' + minutes + ':' + seconds; } babel version 6 split project several modules. message indicates cli has moved babel-cli . i suggest use same version use @ work (which v5): npm install -g babel@5 ho

debug spring boot in vagrant and docker -

i'm trying setup development environment spring-boot project based on docker , vagrant. i'm using intellij running on windows write code , vagrant able run project in docker containers on system. i'm building project maven. i'm able run application packaged in jar in docker container running in ubuntu on virtualbox via vagrant. cannot figure out how debug application in intellij, start application remote debugging on, correctly (or @ least think i'm doing right) configure port forwarding, intellij still tells me "connection reset" , cannot connect debugger. here dockerfile: from java:8 volume /tmp add test-1.0-snapshot.jar app.jar entrypoint ["java", "-djava.security.egd=file:/dev/./urandom", "-xdebug -xrunjdwp:server=y,transport=dt_socket,suspend=n,address=8000", "-jar", "/app.jar"] vagrantfile: env['vagrant_default_provider'] = 'docker' vagrant.configure("2") |config

sql - How do I specify column to to select from result of join -

my table ce_data has column "fut_id" why "ambiguous" error on first line? tx."fut_id" not work either select "fut_id" ( select * "ce_data" m join (select "fut_id", max("date") "most_recent" "ce_data" group "fut_id" ) r on r."fut_id" = m."fut_id" , r."most_recent" = m."date" ) tx the outer query picks fut_id inner subquery. there two different sources choose fut_id from: table ce_data (alias m ) and derived table alias r . can work around problem using alias field within derived table: select "fut_id" ( select * "ce_data" m join (select "fut_id" "fut_id2", max("date") "most_recent" "ce_data" group "fut_id" ) r on r."fut_id2" = m."fut_id" , r."most_recent&q

javascript - getSubscription upon activation of sw -

i'm not sure i'm making mistake. i want register service worker , moment it's "activated" make xhr request server in order store subscription data. self.addeventlistener('activate', function(event) { console.log('activated', event); event.waituntil( self.registration.pushmanager.getsubscription().then(function (subscription) { console.log(subscription);//this null }) ) }) so far wasn't able subscription inside sw, can other javascript on site. not udnerstanding? edit: this how register pushmanager function reg(){ if ('serviceworker' in navigator) { navigator.serviceworker.register(sw).then(function(reg) { reg.pushmanager.subscribe({ uservisibleonly: true }).then(function(subscription) { send_subscription(subscription); }); }).catch(function(error) { console.log(':^(', error); }); } } function send_

c# - Unity 5.3 non-generic type error with WeakReference -

i'm using unity 5.3.5f1 visual studio community 2015 , keep getting error: "the non-generic type `system.weakreference' cannot used type arguments" when try use weakreference generics. know supported here . snippet of code: using system; using system.diagnostics; using system.collections.generic; using system.collections; namespace aim4.util { /** initial id */ private int initid; /** next id */ private int nextid; /** mapping ids weak references of objects */ private sorteddictionary<int, weakreference<t>> idtoobj = new sorteddictionary<int, weakreference<t>>(); i have feeling related unity because if load script in vs outside of project doesn't complain. appreciated. thanks. [converting comment answer] rule of thumbs: if works in vs latest .net fw not in unity (mono, .net v2.0) it's either bug or implementation detail. need workaround either way. of question in comment. porting unity j

iis - Website will not start in Visual Studio 2015 Enterprise, but works fine in 2013 Pro -

i'm having problem running website vs 2015 enterprise, don't have issue running vs 2013 pro. error is: this configuration section cannot used @ path. happens when section locked @ parent level. locking either default (overridemodedefault="deny"), or set explicitly location tag overridemode="deny" or legacy allowoverride="false". error code: 0x80070021 config source: <authentication> <windowsauthentication enabled="true" /> <-- line red </authentication> i have set machine.config values allow tags, applicationhost. also, when trying run directly iis server manager (pointing same location source files), 503 service unavailable . i can provide more information if needed. other solutions have tried: https://serverfault.com/a/221501 https://serverfault.com/a/516921 https://serverfault.com/a/560492 https://stackoverflow.com/a/12867753 https://stackoverflow.com/a/12343141 https://stackoverflow.c

ruby - Print a string in a cryptic manner, the string is invisible in the code -

how can print secret string "secret foo string" using ruby code, without having string in code itself? when runs code, print out string surprise. preferably in 1 line of code, in return statement. thanks :) i mean, base64 encode string first, , return decoded version: require "base64" /* ... */ return base64.decode64("u2vjcmv0igzvbybzdhjpbmc=")

cross fade - ffmpeg - make a seamless loop with a crossfade -

i want apply crossfade last x frames of video first x frames in order obtain seamless loop. how can that? let's video 30 seconds long , fade 1 second long. command be ffmpeg -i video.mp4 -filter_complex "[0]split[body][pre]; [pre]trim=duration=1,format=yuva420p,fade=d=1:alpha=1,setpts=pts+(28/tb)[jt]; [body]trim=1,setpts=pts-startpts[main]; [main][jt]overlay" output.mp4 the video split 2 identical streams. first trimmed first second, has alpha channel added, , faded. last filter on first stream delays 28 seconds since final output have trimmed off first second of original clip , overlap last second. 2nd stream trimmed start @ t=1 , processed first stream overlaid on 2nd. since alpha channel faded in first stream, crossfades in.

javascript - How can I get script after end of <html> tag -

have this: <html> <head></head> <body></body> </html> <script id="ajaxify-data" type="application/json"> .... <script> how can script element? dom functions $("#ajaxify-data") , document.getelementbyid("#ajaxify-data") dont work p.s.: saw script on site . can`t in consolt? possible? please, note element outside < /html > tag not rendered, not valid logic put element of webpage outside of considered end of webpage. if paste code in https://validator.w3.org/#validate_by_input receive error "document type not allow element script here". so, fine if put script right before closing tag. $(body).append() function work.

python - Appending more datasets into an existing Hdf5 file without deleting other groups and datasets -

i have hdf5 file contains groups , subgroups inside there datasets. want open file , add datasets groups. took following approach quite simple in python. import h5py f = h5py.file('filename.h5','w') f.create_dataset('/group1/subgroup1/dataset4', data=pngfile) f.close() the before file looked before file image after file looks after file image but want not delete other datasets , groups rather append dataset4 in line. just python open() function, 'w' truncate existing file. use 'a' mode add content file: import h5py f = h5py.file('filename.h5','a') f.create_dataset('/group1/subgroup1/dataset4', data=pngfile) f.close()

jquery - Rails Javascript onsubmit validate() Uncaught ReferenceError: validate is not defined -

i have form of following characteristics: = nested_form_for reservation, html: { onsubmit: "return validate()"} ... and following file reservation.js: jquery(function() { $('div.modal').on('loaded.bs.modal', function(e) { ...some code... }); $('div.modal').on('shown.bs.modal', function(e) { ...some code... }); function validate(){ var guests = 0; $('.guests-input').each(function(i, e){ guests = guests + $(e).val(); }); if (guests < 1){ alert('sum of percentage must 100'); return false; } return true; } }); but, when click submit button error: uncaught referenceerror: validate not defined i don't know should define it. i've searched other questions couldn't solve problem them. i'm not entirely sure either should look. i'll edit more information if needed. as rory mccrossan says on comment, solution move out valida

python - How to secure client connections to an HBase Thrift Server? -

anyone knows port , host of hbase thrift server, , has access network, can access hbase. security risk. how can client access hbase thrift server made secure? you secure hbase thrift server setting authentication via kerberos , setting property in hbase-site.xml <name>hbase.thrift.security.qop</name> <value>auth</value> http://www.cloudera.com/documentation/enterprise/latest/topics/cdh_sg_hbase_authentication.html

Is it possible to use Sass & BEM in Joomla system? -

i new joomla , after doing research haven't found solution whether possible make use of combination of sass & bem(block element modifier) in joomla environment? sass precompiles css. methodologies bem, smacss, etc used naming conventions have no technical bearing on final css output. the short answer yes, can use sass , bem create/modify joomla css.

multithreading - multiple streams in one GPU device -

i have multi-threaded program supposed run on 6 gpu devices. want open on each device 6 streams reuse during lifetime of program (36 in total). i'm using cudastreamcreate() cublascreate() cublassetstream() create each stream , handle. use gpu memory monitor see memory usage each handle. however, when @ gpu memory usage on each device, grow on first stream creation, , doesn't change in rest of streams create. as far know there isn't limitation on amount of streams want use. can't figure out why memory usage of handles , streams don't show on gpu memory usage. all streams create residing within single context on given device, there no context related overhead creating additional streams after first one. streams lightweight , (mostly) host side scheduler abstraction. have observed, don't in consume (if any) device memory.

javascript - Why doesn't my function to calculate monthly car payments work? -

i creating small web app users can enter ideal car price , find out how (on average) monthly payment be. half of function works , able tophalf variable calculation not rest of equation. formula used http://teachertech.rice.edu/participants/bchristo/lessons/carpaymt.html html used <input type="input" placeholder="carprice" id="rprice"> <input type="input" placeholder="deposit" id="deposit"> <input type="input" placeholder="interest rate" id="irate"> <input type="input" placeholder="loan term" id="tmonth"> <a onclick="findpayment()">calculate</a> javascript used function findpayment() { /* add user's unique input fields here */ var regprice = document.getelementbyid("rprice").value; deposit = document.getelementbyid("deposit").value; rate = document.getelementbyid(

amazon emr - Spark streaming 1.6.1 is not working with Kinesis asl 1.6.1 and asl 2.0.0-preview -

i trying run spark streaming job on emr kinesis. spark 1.6.1 kinesis asl 1.6.1. writing plain sample wordcount example. <dependency> <groupid>org.apache.spark</groupid> <artifactid>spark-streaming-kinesis-asl_2.10</artifactid> <version>1.6.1</version> </dependency> <dependency> <groupid>com.amazonaws</groupid> <artifactid>amazon-kinesis-client</artifactid> <version>1.6.3</version> </dependency> <dependency> <groupid>com.amazonaws</groupid> <artifactid>amazon-kinesis-producer</artifactid> <version>0.10.2</version> </dependency> this throws following exception java.lang.runtimeexception: java.util.concurrent.executionexception: java.lang.noclassdeffounderror: com/google/protobuf/protocolstringlist @ com.amazonaws.services.kinesis.cl

osgi - No SchemaFactory that implements the schema language specified by: http://www.w3.org/2001/XMLSchema could be loaded -

when trying expose service aegis databinding in cxf dosgi error in java 8. in java 7 works fine. caused by: java.lang.illegalargumentexception: no schemafactory implements schema language specified by: http://www.w3.org/2001/xmlschema loaded @ javax.xml.validation.schemafactory.newinstance(schemafactory.java:215) @ org.apache.cxf.aegis.type.xmltypecreator.(xmltypecreator.java:122) see full stacktrace here i think reason code not see impl class com.sun.org.apache.xerces.internal.jaxp.validation.xmlschemafactory . any ideas how fix this? btw. exception can observed running cxf-dosgi build in java 8. i still not have found real solution this. have committed workaround on cxf master ignore exception in static code. aegis binding not schema checked @ least works. see cxf-6959 . i happy hints working again.

Visual Studio 2015 Update 3 - "Xamarin Update Available" Popup -

Image
i installed xamarian , have recent version of visual studio. every time open project uses xamarin, message box: no matter click on it, never takes me update page. 1) need update? 2) if not, how can rid of dialog box? check icons near clock, there xamarin icon there. also if doesn't work, go tools > options , find 'xamarin' page. there should 'check now' link there should give dialog info! here can decide whether want receive stable, beta or alpha updates. remember set same setting in mac counterpart if using mac build machine, uses mac agent. whether or not need update you! check out release notes , decide if worth while upgrade. far know there isn't way rid of message without upgrading , don't think should want that. upgrade isn't there nothing, things better , fixed!

c++ - How to know if libstdc++ support std::regex -

i have application uses std::regex,it builds , runs fine on computer. however, on ubuntu 14.04, builds doesn't work, because std::regex not implemented on old libstdc++. i #ifdef lines in code workaround issue can seem find reliable way figure out if libstdc++ supports or not. i'm using cmake, happy if able version of library (/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.19 -> 6019). you can write simple test check whether works. first cmake part: include(cmakepushcheckstate) include(checkcxxsourceruns) cmake_push_check_state() set(cmake_required_flags "${cmake_required_flags} -std=c++11") check_cxx_source_runs(" #include <regex> int main() { return std::regex_match(\"stackoverflow\", std::regex(\"(stack)(.*)\")); } " have_cxx_11_regex) cmake_pop_check_state() then have include variable have_cxx_11_regex config.h. can test #ifdef have_cxx_11_regex .

windows - C++ Windows32 GDI Fill Triangle -

Image
the standard way of fillrect in gdi rectangle(hdc, x_, y_, x_ + width_, y_ + height_); but how fill triangle ? how approach without using other resources ? use polygon function, uses current brush fill polygon. following example draws triangle outlined in red , filled blue: #include <windows.h> #include <windowsx.h> ... hpen hpen = createpen(ps_solid, 2, rgb(255, 0, 0)); hpen holdpen = selectpen(hdc, hpen); hbrush hbrush = createsolidbrush(rgb(0, 0, 255)); hbrush holdbrush = selectbrush(hdc, hbrush); point vertices[] = { {200, 100}, {300, 300}, {100, 300} }; polygon(hdc, vertices, sizeof(vertices) / sizeof(vertices[0])); selectbrush(hdc, holdbrush); deleteobject(hbrush); selectpen(hdc, holdpen); deleteobject(hpen); the result looks this:

twitter bootstrap - Aurelia tutorial collapsible navbar not working -

i'm following aurelia tutorial , i've noticed bootstrap collapsible navbar isn't working @ all. i've found someone's heroku app online exact same problem. here's source <template> <require from="bootstrap/css/bootstrap.css"></require> <require from="font-awesome/css/font-awesome.css"></require> <nav class="navbar navbar-default navbar-fixed-top" role="navigation"> <div class="navbar-header"> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#example-navbar-collapse"> <span class="sr-only">toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> <a

windows - How to call a subroutine from `for` processed items (after `in`)? -

@echo off setlocal enabledelayedexpansion %%a in (*.*) ( set /a "pre+=1 ) /f %%a in ('call :star') ( set /a "count=count+10000" set /a "fi=10000/pre" set /a "en=!fi!*!count!" set "br=!en:~0,-6!" title !br! ) pause :star echo stuff. echo more. exit /b i'm trying create progress bar updates while commands run. things have been working well, except need able use call command within command, , current setup (below) not working. how can use call command in loop? it's not possible directly call subroutine processed items. but it's possible workaround this aacini's trick : @echo off if /i "%1" equ "call" shift & shift & goto %2 setlocal enabledelayedexpansion %%a in (*.*) ( set /a "pre+=1 ) /f %%a in ('%0 call :star') ( set /a "count=count+10000" set /a "fi=10000/pre" set /a "en=!fi!*!count!" set "br=!en:~0,-6!" title

osx - Issue with "requests" import in Python 2.7 -

using os x i've installed python 2.7 , requests module through terminal. if run pip list can see requests (2.10.0) on list. however, when open script , write import requests in ide error: no module named requests . i've tried lot of solutions, none of them work.

wpf - Dependency Property doesnt trigger -

i have problem dependency properties. have been searching quite while "how tos" nothing me far. i need grid change background color when drag it. here code far: vb friend shared readonly isdragoverpropertykey dependencypropertykey = dependencyproperty.registerreadonly("isdragover", gettype(boolean), _ gettype(ucpagecontrol), _ new propertymetadata(false)) public shared readonly isdragoverproperty dependencyproperty = isdragoverpropertykey.dependencyproperty private _isdragover boolean = true public property isdragover() boolean return cbool(getvalue(isdragoverproperty)) end set(byval value boolean) setvalue(isdragoverproperty, value) end set end property private sub grid_dragenter(sender object, e windows.drageventargs)

symfony - Some methods have its returned value persisted only if other fields are changed before PreUpdate -

my budget entity has methods executed on prepersist , preupdate . methods are: /** * @return \datetime */ public function generatenextpaymentdate() { if ($this->getstartsat() !== null) { $date = new \datetime($this->getstartsat()->format('y-m-d')); return $date->add(new \dateinterval('p' . $this->getcheckfor() . 'd')); } } /** * @return decimal */ public function calculatetotalbudgetprice() { $totalbudgetprice = 0; foreach ($this->getitems() $item) { $totalbudgetprice += $item->getprice(); } return $totalbudgetprice; } /** * @return decimal */ public function calculateinstallmentrateprice() { return $this->calculatetotalbudgetprice() / $this->getinstallmentrate(); } /** * @orm\prepersist * @orm\preupdate */ public function onpreevents() { $this->setnextpaymentdate($this->generatenextpaymentdate()); $this->setinstallmentrateprice($this->calcula

linux - Full space occupied by the file system -

how can find how space file system occupies on block device, when file system not cover whole partitions? consider basic example demonstrate core problem: dd if=/dev/zero bs=1024 count=20480 of=something.img losetup -f $pwd/something.img mke2fs /dev/loop0 mount /dev/loop0 /mnt but df -k /mnt gives output: filesystem 1k-blocks used available use% mounted on /dev/loop0 19827 172 18631 1% /mnt i have created device of precisely 2048kb, statvfs() syscall (and df displayed above) reports file system takes 19827kb. it seems that statvfs() reports blocks usable user, doesn't report full actual size of file system. so far, find ext2/3/4-specific hacky solution : tune2fs -l /dev/loop0 | grep 'block count:' or dumpe2fs -h /dev/loop0 | grep 'block count:' . little bit more cleaner use libext2fs library (part of e2fprogs package) read superblock, prefer file-system neutral syscall, if available. if you're looking p

xlslib build success in iOS 7 but failed in iOS 8. How can I do? -

Image
i have searched http://sourceforge.net/projects/xlslib/files here , download library. added library xcode project this my xcode version 6.4 , project ios deployment target 8.0. after added project without typing code, built see if works. but failed , these information: ld: building ios simulator, linking against dylib built macosx file '(myproject directory)/xlslib/libxls.3.dylib' architecture x86_64 clang: error: linker command failed exit code 1 (use -v see invocation) when changed ios deployment target 7.0, build project using ios simulator ios version 7.1, works. library doesn't support ios 8.0 , later ? btw, other link flag empty, should solve problem? any appreciated.

c++ - Register first button pressed. -

i'm making simple quiz app on raspberry under raspbian using c++. want store pressed button first. 4 momentary buttons connected pi via gpio, testing using keyboard. how should function reading buttons avoid simultaneous presses? thanks if record timestamp nanosecond resolution of when "press" happened unlikely duplicates. , in unlikely event do, pick random 1 of dupes since that's right whatever else ;) see http://en.cppreference.com/w/cpp/chrono

haskell - Why can't I get overloaded strings? -

this code have in file temp.hs : {-# language overloadedstrings #-} module temp import data.string string1 = "darth vader" string2 = "obi-wan kenobi" the problem want overloaded strings. understand, overloaded strings polymorphic, belonging typeclass isstring . when load above file in ghc , :t string1 , i should string1 :: data.string.isstring => a but is: string1 :: string help! this answer in based on user2407038 's comment. turns out adding {-# language nomonomorphismrestriciton #-} code solves problem. wouldn't recommend it. read monomorphism restriction . but turns out, don't have it. ghc monomorphism thing , sets type of string1 string , because thought didn't want else. overloadedstrings extension still in effect! you'll notice if string1 = "darth vader"::bytestring ghc more happy make string1 variable bytestring . one more thing noticed in haskell's monomorphism

Dyanamic tabs in android with dynamic content from json -

i m creating dynamic tabs in android in data tabs populated json following json response { "shop_details": [ { "id": "36", "shop_name": "all in 1 mart", "shop_no": "23223", "shop_address": "tinkune", "phone": "9804966595", "email": "arjundangal4@gmail.com", "user_name": "arjun", "address": "", "tel": "", "fax": "", "facebook": "", "twitter": "", "googleplus": "", "image": "", "featured_image": "" } ], "category": [ { "category_id": "35", "category_name": "skirt", "product": [ {

android - How to generate an Barcode and convert it to Bitmap using new Google Vision API? -

how generate barcode , convert bitmap using new google vision api? barcode barcode = new barcode(); barcode.email email = new barcode.email(); email.address = "my_email@gmail.com"; email.subject = "my subject; email.body = "my body content."; barcode.email = email; //implement conversion bitmap barcodeimage = barcodetobitmap(barcode);// know part. you can detect barcodes using google vision api , use zxing generate barcodes. try this, uses zxing library: public static bitmap getbitmap(string barcode, int barcodetype, int width, int height) { bitmap barcodebitmap = null; barcodeformat barcodeformat = converttozxingformat(barcodetype); try { barcodebitmap = encodeasbitmap(barcode, barcodeformat, width, height); } catch (writerexception e) { e.printstacktrace(); } return barcodebitmap; } private static barcodeformat converttozxingformat(int format) { switch (format) { case

Running Batch Jobs on Amazon ECS -

i'm new using aws, , more ecs. currently, have developed application can take s3 link, download data link, processes data, , output information data. i've packaged application in docker container , resides on amazon container registry. want start cluster, send s3 link each ec2 instance running docker, have container instances crunch numbers, , return results single node. don't quite understand how supposed change application @ point. need make application running in docker container service? or should send commands containers via ssh? assuming far, how communicate cluster farm out work potentially hundreds of s3 links? ideally, since application compute intensive, i'd run 1 container per ec2 instance. thanks! your story hard answer since it's lot of questions without lot of research done. my initial thought make stateless. you're on right track making them start , process via s3. should expand use sqs queue. sqs messages contain s3 link. appli

antlr4 literal string handling -

i have following antlr4 grammar: grammar squirrel; program: globalstatement+; globalstatement: globalvardef | classdef | functiondef; globalvardef: ident '=' constantexpr ';'; classdef: class ident '{' classstatement+ '}'; functiondef: function ident '(' parameterlist ')' functionbody; constructordef: constructor '(' parameterlist ')' functionbody; parameterlist: ident (',' ident)* | ; functionbody: '{' statement* '}'; classstatement: globalvardef | functiondef | constructordef; statement: expression ';'; expression: ident # ident | ident '=' expression # assignment | ident ('.' ident)+ # lookupchain | constantexpr # constant | ident '(' expressionlist ')' # functioncall | expression '+' expression # addition; constantexpr: integer | string; expressionlist: expression (',' expression)* | ; construct

Accurately testing a JavaScript analytics delivery system in Rails -

i work on large rails app. have javascript feature acts general analytics data delivery system. announces general analytics data based on various page interaction events (clicks, page views, etc) framework agnostic, in that, data isn't specific what, say, google analytics wants out of box. it's general data interaction. the idea adapter module google analytics (or other 3rd party analytics tool) can written take data produced general library, augment data fit needs of 3rd party, , send endpoint. my question testing feature accurately. we use rspec bulk of our testing , teaspoon our javascript unit tests. ideally i'd write feature test navigates our app, clicks on various triggering elements, , confirms general analytics data being announced correctly. is possible, or our teaspoon tests going have suffice? rspec integration tests can you. unfortunately it's slow way test javascript, regression testing, performance may not important, rspec feature tes

kubernetes - Kubelet fails to update node status -

on latest rhel atomic host (kubernetes 1.2) regularly seeing following entries in kubelet logs: kubelet.go:2761] error updating node status, retry: nodes "x.y.z" cannot updated: object has been modified; please apply changes latest version , try again this causes node temporary go notready. during these notready periods, pods on node show ready, looks kubernetes stops routing traffic them, causing problem. in go sources can see during heartbeat of kubelet fetch latest status, overwrites own status, , sends put apiserver. this see in logs: jul 15 12:42:45 lxa160j.srv.pl.ing.net kubelet[3736]: i0715 12:42:45.086322 3736 round_trippers.go:264] https://lxa160g.srv.pl.ing.net:6443/api/v1/nodes/lxa160j.srv.pl.ing.net jul 15 12:42:45 lxa160j.srv.pl.ing.net kubelet[3736]: i0715 12:42:45.091579 3736 round_trippers.go:289] response status: 200 ok in 5 milliseconds jul 15 12:42:45 lxa160j.srv.pl.ing.net kubelet[3736]: i0715 12:42:45.373091 3736 round_trippers.go:2

c# - How to convert day (day of the week) and time as string to different Timezones in .Net -

i have convert various amount of strings in local timezone ( .tolocaltime() ) unlike normal datetime string strings contain day , time (they supposed in utc) so: sunday:17:00 friday:16:50 monday:20:50 thursday:07:00 i looking clever way "convert" strings local timezone since can not datetime out of have manually avoid. (also not split string... ) you cannot handle timezoneoffset correctly without knowing exact date, because offset may change 1 day other (dst vs non-dst). getting correct time easy part (if have correct date), use appropriate constructor of datetime. datetime(int year, int month, int day, int hour, int minute, int second, system.datetimekind kind) and specify kind system.datetimekind.utc . have timestamp utc time , can use tolocaltime() correct time in local timezone. the hard part seems me, getting correct date out of data. sunday meant, next 1 (ie 2016-07-10) or last 1 (2016-07-03)? important dates near switch of dst because may res

javascript - Dynamically set option selected -

how can set option value selected dynamically? have tried same by, function editfromdb(optval) { $.get("/myend", function(mydata) { var s = $('<select id="' + optval + '" name="selectname" ></select>'); $(mydata).each(function(iter, element){ $('<option></option>', { value: elem.name, text: elem.name }).appendto(s); }); $("#" + optval).val(optval); // ... just add " selected : true" $('<option></option>', { value:"lol2", text: "yo2", selected : true }).appendto($("#test")); two ways use : $(mydata).each(function(iter, element){ if (your_condition_for_selected) { $('<option></option>', {

sql server - how to select all value from two table -

tablea tableb idprice price id tax idprice ---------------------- ------------------------------------ 4 100 1 20 4 ------------------------ ------------------ ------------------ 5 150 2 10 6 ------------------------ ------------------ ------------------ 6 270 ------------------------ result = price id tax ---- --- ---- 100 1 20 150 2 10 270 null null query select price,id,tax tableb inner join tablea on tablea.idprice= tableb.idprice result price id tax ---- --- ---- 100 1 20 150 2 10 select a.price price, b.id id, b.tax tax tablea left outer join tableb b on a.idprice = b.idprice use left outer join can records tablea.

c# - member login and read own notes -

i have created website user can become register , log in username / password when log in, can create own notes + (here's problem started> must option can read or see own notes ex on second page. i confused, maybe guys can me , try different sql statements , different inner join but,nothing happens on page,where users can see own notes after finished create own notes. my db looks this. 2 table. tbluser (fldid, fldusername, fldpassword) , tblnote (fldid, fldnotes) my code-behind , sql statements this: code-behind: createnotes.aspx protected void btncreate_click(object sender, eventargs e) getcontent objnote = new getcontent(); objnote._note = txttext.text; objnote._idnote = convert.toint32(session["userid"]); objnote.addnotes(); litsvar.text = "you have create notes"; response.addheader("refresh", "5; url=createnote.aspx"); } sql statement : public void addnotes() { string strsql =

ios - Swift 2.2 #selector for delegate/protocol compile error -

Image
here code: protocol customcontroldelegate: anyobject { func buttontapped(sender: anyobject) } class customcontrol: uiview { var delegate: customcontroldelegate? { didset { abutton.addtarget(delegate, action: "buttontapped:"), forcontrolevents: uicontrolevents.touchupinside) } } as of swift 2.2, compile error asking use #selector. can't figure out how correctly use #selector in case. the compiler gave suggestion: but when used, gave compile warning saying: i tried , did not compile error, however, doubt it's right solution. don't want add @objc protocol: @objc protocol customcontroldelegate: anyobject { func buttontapped(sender: anyobject) } class customcontrol: uiview { var delegate: customcontroldelegate? { didset { abutton.addtarget(delegate, action: #selector(customcontroldelegate.buttontapped(_:)), forcontrolevents: uicontrolevents.touchupinside) } } i don't

r - How can I access the data in a Cassandra Table using RCassandra -

i need data in column of table cassandra database. using rcassandra this. after getting data need text mining on it. please suggest me how connect cassandra, , data r script using rcassandra my rscript : library(rcassandra) connect.handle <- rc.connect(host="127.0.0.1", port=9160) rc.cluster.name(connect.handle) rc.use(connect.handle, 'mykeyspace') sourcetable <- rc.read.table(connect.handle, "sourcetable") print(ncol(sourcetable)) print(nrow(sourcetable)) print(sourcetable) this print output as: > print(ncol(sourcetable)) [1] 1 > print(nrow(sourcetable)) [1] 18 > print(sourcetable) 144 bbc news 158 ibn live 123 reuters 131 ibn live but cassandra table contains 4 columns, here showing 1 column. need each column values separated. how individual column values(eg.each feedurl) changes should make in r script? my cassandra table, named sourcetable i have used cassandra , r correct cran jar files, rcassandra easier. rcas