Posts

Showing posts from May, 2012

android - Programmatically add Linear layout with five buttons placed horizontally with same size in both landscape and portrait -

Image
i have programmatically creating linear layout 5 buttons fixed size, when change orientation, buttons stretching in lanscape here code: linearlayout button_layout = new linearlayout(this); button_layout.setlayoutparams(new linearlayout.layoutparams(layoutparams.fill_parent, 100)); button_layout.setorientation(linearlayout.horizontal); button_layout.setbackgroundcolor(color.parsecolor("#dce1dc")); framelayout layout = new framelayout(this); layout.setlayoutparams(new linearlayout.layoutparams(20, 80, 1)); layoutparams params = (layoutparams) layout.getlayoutparams(); params.setmargins(30, 0, 30, 0); button = new button(this); a.setlayoutparams(params); a.settext("a"); button_layout.addview(a); button b = new button(this); b.setlayoutparams(params); b.settext("b"); button_layout.addview(b); button c = new button(this); c.setlayoutparams(params); c.settext("c"); button...

perl - Assign arrays to hash subkeys -

given array of keys , array of values, can create hash these keys , values using @hash{@keys} = @vals . however, subkeys of hash. not work: $h{"key"}{@subkeys} = @vals . $ perl -mdata::dumper -le ' @subkeys=(qw(one two)); @vals=(1, 2); $hash{"key"}{@subkeys} = @vals; (qw(subkeys vals)) { print "$_ :\n", dumper(\@{$_}) }; print "hash: \n", dumper(\%hash);' what is: subkeys : $var1 = [ 'one', 'two' ]; vals : $var1 = [ 1, 2 ]; hash: $var1 = { 'key' => { '2' => 2 } }; if possible, correct syntax following dumper result: $var1 = { 'key' => { 'one' => 1, 'two' => 2 } }; it work when using temporary hash: perl -mdata::dumper -le '@subkeys=(qw(o...

c# - xceed wpf propertygrid collection select -

i'm new in wpf , may it's stupid question, but...) have custom properties class visualased xceed wpf propertygrid public class shopproperties { private readonly observablecollection<string> _cars = new observablecollection<string>(); [category(@"carsshop")] [displayname(@"carscollection")] public observablecollection<string> carscollection { {return _cars;}} [browsable(false)] private string selectedcar {get; set;} } what simplest , finest propertygrid editor(or custom editor) need use assign selectedcar element carscollection? after search , reading http://wpftoolkit.codeplex.com/wikipage?title=propertygrid&referringtitle=documentation think minimum 2 ways in case. 1. customise xctk:collectioncontrol , edit xaml. <xctk:propertygrid name="_generalpropertygrid" dockpanel.dock="top" showsearchbox="false" showsortoptions="fa...

extracting 2D array from 4D array in matlab -

this question has answer here: how 2 last dimensions of n-d array 2d array? 3 answers i have 4d array in matlab this, test(:,:,1,1) = 0 test(:,:,2,1) = 0 test(:,:,3,1) = 0 test(:,:,4,1) = 0 test(:,:,5,1) = 0 test(:,:,1,2) = 0 test(:,:,2,2) = 0 test(:,:,3,2) = 0 test(:,:,4,2) = 0 test(:,:,5,2) = 0 test(:,:,1,3) = 0 test(:,:,2,3) = 0 test(:,:,3,3) = 0 test(:,:,4,3) = 0 test(:,:,5,3) = 0 test(:,:,1,4) = 0 test(:,:,2,4) = 0 test(:,:,3,4) = 0 test(:,:,4,4) = 0 test(:,:,5,4) = 0 test(:,:,1,5) = 0 test(:,:,2,5) = 0 test(:,:,3,5) = 0 test(:,:,4,5) = 0 test(:,:,5,5) = 0 k>> test test(:,:,1,1) = 0 test(:,:,2,1) = 0 test(:,:,3,1) = 0 test(:,:,4,1) = ...

Eclipse scala "Could not find or load main class" -

i have started learning scala, using eclipse ide it, in run configuration have set scala application project name , main class main when compile have error: not find or load main class main when check console see it's reading java/jre directory, normal or should change ? code package 1 class main { object bottles { def main(args: array[string]){ var n : int=2; while(n<=6){ println(s"hello ${n} bottles"); n+=1; } } } } the main method needs on toplevel object. bottles object wrapped in main class. remove main class , code should run. object bottles { def main(args: array[string]){ var n : int=2; while(n<=6){ println(s"hello ${n} bottles"); n+=1; } } }

installing mysql ruby gem with proper configuration options -

< update: system rhel6 > i trying install mysql using command gem install mysql -v '2.8.1' , below error building native extensions. take while... error: error installing mysql: error: failed build gem native extension. /usr/local/bin/ruby extconf.rb checking mysql_ssl_set()... *** extconf.rb failed *** not create makefile due reason, lack of necessary libraries and/or headers. check mkmf.log file more details. may need configuration options. provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/usr/local/bin/ruby --with-mysql-config --without-mysql-config /usr/local/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': compiler failed generate executable file. (runti...

bash - Nagios Output Formatting -

short version: is there better way of writing check below? ./check_snmp -h x.x.x.x -o oidstring -c public | awk '{print $4}' | sed 's/.$/.&/' | sed -e 's/$/ kb/' long version: i have nagios service check outputs 3 digit number: ./check_snmp -h x.x.x.x -o oidstring -c public snmp ok - 711 | iso.oidstring=711 this have done format liking , give accurate value: ./check_snmp -h x.x.x.x -o oidstring -c public | awk '{print $4}' | sed 's/.$/.&/' | sed -e 's/$/ kb/' 71.1 kb the output perfect , can run command within centos environment without issue, when attempting implement check within nagios, service not return , value , instead (no output on stdout). strangely, can perform service test check within nagios successfully, page displays host , service values 1 gives (no output on stdout). i think nagios doesn't way i'm attempting format output, @ least on web side of things. is there 'neater' ...

c++ - iris to screen calculation for eye tracking -

Image
i'm experimenting eye tracking i've built iris tracking algorithm using opencv contours , hough transform. next step unclear me. want know if calculations i'm doing correct translating center of eye screen. head of user has fixed position. what want algorithm works on eyes off course. there angle calculation? when user looking more right, linear? what right is: first let user @ specific points , use ransac detect iris position that's closest position on screen. 4 2d points on screen , iris. i'm using homography correct calculation. void gaussian_elimination(float *input, int n){ // ported c pseudocode in // http://en.wikipedia.org/wiki/gaussian_elimination float * = input; int = 0; int j = 0; int m = n-1; while (i < m && j < n){ // find pivot in column j, starting in row i: int maxi = i; for(int k = i+1; k<m; k++){ if(fabs(a[k*n+j]) > fabs(a[maxi*n+j])){ maxi = k; } } if (a[maxi*n+j]...

less - External Tool Configuration build options tab in Eclipse > Luna (i.e. Mars) -

Image
i had supercool hook set on eclipse compile project's .css theme file .less modules every time .less module modified monitoring resources through "external tool configuration". i select resources monitor triggering nodejs less compiler tool on launch configurations build options tab. on eclipse mars there no such tab. it bothers me loose automation. know did tab go or how can keep functionality without it? you set such custom builders via project's properties dialog. open properties, select builders section. there can use new... button configure program run builder.

python - I cannot solve Django models.DateField ValidationError -

i stuck error models.datefield() first, did this. models.py from datetime import date, datetime django.db import models class user(models.model): uid = models.autofield(primary_key=true) birthdate = models.datefield() then, got, $ python manage.py makemigrations trying add non-nullable field 'birthdate' user_profile without default; can't (the database needs populate existing rows). please select fix: 1) provide one-off default (will set on existing rows) 2) quit, , let me add default in models.py so, did, models.py from datetime import date, datetime django.db import models class user(models.model): uid = models.autofield(primary_key=true) birthdate = models.datefield(default=date.today) then, $ python manage.py migrate django.core.exceptions.validationerror: ["'' は無効な日付形式です。yyyy-mm-dd形式にしなければなりません。"] the error means, "'' invalid formate of date. should change yyyy-mm-dd". how should change...

excel - vba macro to create .txt list of filepaths -

i have macro list out files in subfolders of particular folder. want create .txt file in main folder has list of filepaths? macro create txt file lists column of excel spreadsheet. know easy without vba(you save text file) need find way automate it?! if have data in column a then: sub mkfile() dim n long, long n = cells(rows.count, "a").end(xlup).row close #1 open "c:\testfolder\testfile.txt" output #1 = 1 n print #1, cells(i, "a").value next close #1 end sub change folder or file names suit needs.

c# - get single color values from argb number -

im learning c# , following problem im trying solve taking number stored string , getting a, r, g, b values. so want go string s = "4280427042"; to int = 255; int r = 22; int g = 22; int b = 22; what best approach? you can convert string unsigned 32-bit integer, , use bitconverter individual bytes this: string s = "4280427042"; uint argb = convert.touint32(s); byte[] values = bitconverter.getbytes(argb); int = values[3]; int r = values[2]; int g = values[1]; int b = values[0]; quoting this msdn reference : the order of bytes in array returned getbytes method depends on whether computer architecture little-endian or big-endian. this means need careful order of bytes. can use bitconverter.islittleendian that.

c# - How to query IDBSet via linq -

i have table attempting query in order create menu. querying related tables pair down result. have models project contains of data models. in entities file have public idbset<agent> agents { get; set; } public idbset<userslogin> userslogins { get; set; } public idbset<role> roles { get; set; } public idbset<userrolemapping> userrolemappings { get; set; } public idbset<qualifier> qualifiers { get; set; } public idbset<tblmenus> tblmenu { get; set; } public idbset<tblusermenumapping> tblusermenumappings { get; set; } public idbset<tblrolemenumapping> tblrolemenumappings { get; set; } in interface have icollection<tblmenus> getallmenus(); then have linq query pares down , returns main menus , child menus. public icollection<tblmenus> getallmenus() { if (global.currentprofile.userid == 1) { return dataaccess.tblmenu.where(m => !m.isdeleted).tol...

png transparent image file in android -

i want save png image sd card , should without background. in sd card not see background when attach telegram see white background. here code in android: file filepath = environment.getexternalstoragedirectory(); file dir = new file(filepath.getabsolutepath() + "/background_eraser/"); dir.mkdirs(); mimagename = "image" + cal.gettimeinmillis() + ".png"; file = new file(dir, mimagename);

asp.net mvc - Razor, shortest conditional block -

i use code like: <p @if(model.sth) { ?:style="display: none;" }>some text</p> many template engines have special markers conditional blocks, example in mustache can write: <p {{#model.sth}}style="display: none;"{{/model.sth}}>some text</p> can razor code can written in shorter form? in razor can embed expressions inside parenthesis execute them inline. if conditional can written using ternary operator, can this: @(this.model.sth ? "style='display:none;'" : string.empty) the trick getting razor emit resulting string correctly html. use htmlhelper it, gets messy enough long-form conditional cleaner. in specific case of attribute, however, there's special feature of razor, of mvc4, help. if specify attribute using expression evaluates null , mvc won't emit attribute @ all, can do: <p style="@(this.model.sth ? "display:none;" : null)">some text</p> (note...

android - Avoid recreation of programmatically created menuitem in fragment -

my question how can prevent programmatically created toolbar menuitem (menu submenus) gets overridden xml layout every time fragment resumes. want create expensive toolbar menuitem when fragment first time created , not when resumes. i inflat toolbar in oncreateoptionsmenu() , store instance of menu item. private menuitem menuitem; private submenu expessivesubmenu; @override public void oncreateoptionsmenu(menu menu, menuinflater inflater) { inflater.inflate(r.menu.menu_layout, menu); menuitem= menu.finditem(r.id.menuitem); } the menuitem gets populated when async loader finishs. @override public void onloadfinished(loader<> loader, data data) { //expensive call expensivesubmenu= makeexpensivesubmenu(menuitem, data); } now menu populated , visible in toolbar , have instance of submenu. because oncreateoptionsmenu() called evertime fragment resumed menu get's overridden xml layout , have create expensive submenu ag...

postgresql - Which ORM that supports JSONB is better with Sails -

i'm trying figure out orm (or other solution) use in sails.js + postgresql application. basic rule supports jsonb data type. unfortunately waterline not ( bottom of page ), had go around find workaround. application microservice specific purpose , functionality, , not going huge or super-complex. i stumbled upon api's can integrated: bedquiltdb , postgrest , these seem overkill needs. so, sceptical using of type of solutions. then stumbled upon sequelize , bookshelf ( with knex ). there other options, these 2 seemed popular , used ones. here general points towards both options: sequelize said have weak community , hard find answers, in has x2 q&a of waterline said pain in ass when project gets have complex entity relations (if means "more usual foreign keys", can i'm not gonna have in db setup) said have documentation, basics only.. find methods basic , relationship queries 1 use, don't see negative side of docs in here. supports json...

c# - NLog Mail target timeouts -

i'm trying use nlog's mail target send emails through secured (ssl) smtp server. here configuration: <target type="mail" name="mailtarget" layout="${message}" encoding="utf-8" html="false" addnewlines="false" subject="hi8766" to="ben.g@mycompany.com" from="ben.g@mycompany.com" body="${message}" smtpusername="ben.g" enablessl="true" smtppassword="12345" smtpauthentication="basic" smtpserver="smtp.mycompany.com" smtpport="465" deliverymethod ="network" pickupdirectorylocation="" timeout="20000"/> however when use logger.info(message) nothing happens. turned on nlog's internal logging on , started wireshark, on internal logs see: 20...

json - api gateway CORS setup -

i'm attempting setup aws cors command line using aws-cli in deployment script. have created post resource following perl shell command. i'm attempting set integration-response '*' enabling cores do. aws apigateway put-method-response \\ --region "$region" \\ --rest-api-id "$api_id" \\ --resource-id "$resource_id" \\ --http-method "post" \\ --status-code 200 \\ --response-models '{"application/json":"empty"}' \\ --response-parameters '{"method.response.header.access-control-allow-origin":true}' when run following command set integration value. aws apigateway put-integration-response \\ --region "$region" \\ --rest-api-id "$api_id" \\ --resource-id "$resource_id" \\ --http-method "$method" \\ --status-code 200 ...

html - add border top right radius only without other sides or background -

Image
i trying achieve top right triangle in picture shows when apply border radius why apply borders side specified 1 side radius. although applied border-top-right-radius: 5px; instead of border-radius: 0px 5px 0px 0px; same result. help? html: <div class="pricing-head"> <h3>rainmarker</h3> <span>for 10 users</span> <div class="ribon"></div> </div> css: .pricing-head { background-color: #fff; -webkit-border-radius: 5px; -moz-border-radius: 5px; border-radius: 5px; padding: 20px; } .pricing-head .ribon { position: absolute; top: 0; right: 0; width: 75px; height: 75px; } .pricing-head .ribon:before { content: ""; position: absolute; right: 0; top: 0; border-bottom: 70px solid transparent; border-left: 70px solid transparent; border-right: 70px solid #ffad6a; border-radius: 0 5px 0 0; } for rounded top-right border...

git - How to remove commit remotely after another commits -

a git status gives me this: commit xxxxx author: aaaa date: thu feb 4 16:47:06 2016 -0500 commit yyyyy author: bbbb date: thu feb 4 16:47:05 2016 -0500 commit zzzzz author: cccc date: thu feb 4 16:47:04 2016 -0500 i want remove changes introduced yyyyy , is, want keep changes introduced xxxxx . you can revert changes introduced commit: git revert yyyyy this create new commit, preferred on doing rebase if have pushed changes long-living remote branch (such master ).

typescript - mocha test the promise, catch exception case -

i have test : it('should not save user if exists', ()=>{ var user : user = {username : 'jack', name : 'lenon'}; var user1 : user = {username : 'jack', name : 'linon'}; return repository.saveuser(user) .then((user:user)=>{ return repository.saveuser(user1) }).then((user : user)=>{ expect('second ').equals(''); }) .catch((err) =>{ expect(err).equals("a user username exist in database"); }); }); the idea test repository rejecting save second user same name. works, not happy @ way force failure in "then". there better way that?

node.js - How to force Babel to perform a transformation? -

i have following files: ./client/.babelrc ./client/index.js ./server/.babelrc ./server/index.js client ./client/index.js code is: import 'test'; ./client/.babelrc is: { "presets": [ "es2015-webpack", "stage-0", "react" ] } client code consumed webpack 2. webpack 2 supports es6 modules . es2015-webpack babel preset transforms code down es5, not transform es6 modules commonjs. therefore, transpiled code remains unchanged. server ./server/index.js code is: import './../client'; ./server/.babelrc is: { "presets": [ "es2015", "stage-0" ] } node.js v5.5.0 not support es6 modules. therefore, entire code needs transpiled down es5. however, node script needs include parts of client code (e.g., config, initial state). i try run server code using babel-node , e.g. cd ./server babel-node ./index.js this produces error...

javascript - onclick event not running, code sequence not correct -

the code below runs far alert("click on image on left") nothing upon clicking on image added left div. upon clicking on image (id="extraimage") js change color of "extraimage" element red. also, need change sequence in code executed , run alert("click on image on left") after pictures have been added. thoughts appreciated. <html> <head> </head> <body> <div id="containerleft"> </div> <div id="containerright"> </div> <script> var = 1 var pocetsmilikov = prompt("enter number of smiley faces"); alert("i add" + pocetsmilikov); while (i <= pocetsmilikov) { insert(); i++; } insertextratoleft(); function insert() { var imgdestination = document.getelementbyid...

c# - How to disable all touches for a Layout in Android -

i trying implement bottom sheet in xamarin.android , want disable touches on not bottom sheet (i.e. main layout), when bottom sheet active. main.axml: <framelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/main_layout"> <include android:id="@+id/toolbar" layout="@layout/toolbar" /> <!-- main layou --> <framelayout android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/main_content" android:paddingleft="16dp" android:paddingright="16dp" > <button android:id="@+id/btn_test" android:layout_width="match_parent" android:layout_height="wrap_content" android:text="@string/logout" android:layout_gravity=...

PHP Notice: 'Array to string conversion' while making symfony form template -

i'm following a symfony tutorial in official documentation . when field type options symfony throws error "an exception has been thrown during rendering of template ("notice: array string conversion") in form_div_layout.html.twig @ line 13." i have checked on google , typos, offending line, documentation seems be: ->add('duedate', datetype::class, array('widget' => 'single_text')) which straight documentation. context rest of file looks this: <?php namespace appbundle\controller; use appbundle\entity\task; use symfony\component\form\extension\core\type\texttype; use symfony\component\form\extension\core\type\datetype; use symfony\component\form\extension\core\type\submittype; use sensio\bundle\frameworkextrabundle\configuration\route; use symfony\bundle\frameworkbundle\controller\controller; use symfony\component\httpfoundation\request; class defaultcontroller extends controller { /** * @route("/...

c# - How do you decrypt a xml file using BouncyCastle and .pem file? -

i have xml file has been encrypted , pem file contains private key , certificate. var bytestodecrypt = file.readallbytes(@"encrypted.xml.pem"); asymmetriccipherkeypair keypair; using (var reader = file.opentext(@"privatekeyandcert.pem")) { keypair = (asymmetriccipherkeypair)new org.bouncycastle.openssl.pemreader(reader).readobject(); } var decrypted = rsadecrypt(bytestodecrypt, keypair.private); var xml = encoding.utf8.getstring(decrypted); 1st attempt of decoding throws exception "input large rsa cipher." public static byte[] rsadecrypt(byte[] data, asymmetrickeyparameter key) { var decryptengine = new rsaengine(); decryptengine.init(false, key); return decryptengine.processblock(data, 0, data.length); } 2nd attempt completes output random chars , not xml. public static byte[] rsadecryptchunk(byte[] data, asymmetrickeyparameter key) { try { var engine = new rsaengine(); engine.init(false, key); ...

youtube-api search response (java) -

using youtubeapi of java, made video search. worked using sample of following. ttps://developers.google.com/youtube/v3/code_samples/java#search_by_keyword the following data acquired. { "items": [ search resource ] } and want "nextpagetoken" , "prevpagetoken". added following code. searchresponse.getnextpagetoken(); but result "null"; what wrong? reference: ttps://developers.google.com/youtube/v3/docs/search/list this code.thanks. /* * copyright (c) 2012 google inc. * * licensed under apache license, version 2.0 (the "license"); may not use file except * in compliance license. may obtain copy of license @ * * http://www.apache.org/licenses/license-2.0 * * unless required applicable law or agreed in writing, software distributed under license * distributed on "as is" basis, without warranties or conditions of kind, either express * or implied. see license specific language go...

javascript - How do I build a Recurly.js form with div elements? -

Image
my team using recurly.js build payments page our website. we've been following docs https://docs.recurly.com/js . according docs, build form like. use data-recurly attribute identify input field targets recurly.js. identify recurly.js inject card data fields, recommend using simple div elements. the problem div elements don't show in form. here's short reproducible example based off of docs: <!doctype html> <html lang="en"> <head> <!-- recurly.js script , api key config --> <script src="https://js.recurly.com/v4/recurly.js"></script> <script>recurly.configure('... api key here...');</script> </head> <body> <form> <input type="text" data-recurly="first_name"> <input type="text" data-recurly="last_name"> <div data-recurly="number"></div> <div data-recurly="month...

How to extract a vector by 100+ unique character strings without having to type all of them by hand in R -

i have data set of more 86,000 different rows , 27 variables. list of different individuals, company, percentage attendance, among other things. each company has data 2010-2011 starting in september way 2015-2016. a portion of data set below omissions , ellipses indicate transitions. yr company month mo % attendance %change 2010-11 "015jk" 1 sep 88.21 2010-11 "015jk" 2 oct 92.51 4.31 2010-11 "015jk" 3 nov 90.97 -1.54 2010-11 "015jk" 4 dec 89.19 -1.78 2010-11 "015jk" 5 jan 86.88 -2.31 2010-11 "015jk" 6 feb 89.28 2.4 ... yr company month mo % attendance %change 2015-2016 015jk 1 jan 82 2015-2016 015jk 2 feb 64 -18 2015-2016 015jk 3 mar 94 30 2015-2016 015jk 4 april 98 4 2015-2016 015jk 5 may 50 -48 20...

c++ - Mixing typenames and values with template pack expansion -

is possible mix typenames , values when using template pack expansion? for instance, possible bar function below? template <typename t> class { public: void foo() { printf( "a.foo()\n" ); } }; template <typename t, int x> class b { public: void foo() { printf( "b.foo() x = %d\n", x ); } }; template <typename classtype, typename... subvals> void bar( classtype<subvals...> obj ) { obj.foo(); } int main(int argc, char** argv) { a<int> a; b<float, 3> b; bar<int>( ); // allowed compiler bar<float, 3>( b ); // compiler yells @ this, though. return 0; } you can away accepting non-type parameter pack of int , , letting compiler deduce third template argument class templated on type , 0 or more int values. template<typename t, int... vals, template<typename, int...> class c> void bar(c<t, vals...> obj) { obj.foo(); } ...

javascript - this.refs.something returns "undefined" -

i have element ref defined , ends getting rendered page : <div ref="russian" ...> ... </div> i want access dom element properties offset... or something. however, keep getting undefined , haven't faintest idea why. after searching it's clear refs applicable 1 file i'm not using anywhere besides 1 page. i'm saying log it: console.log('refs', this.refs.russian); what causing this? the correct place work refs inside specific react lifecycle methods e.g. componentdidmount , componentdidupdate you cannot reference refs render() method. read more cautions of working refs here. if move console.log('refs', this.refs.russian); call componentdidmount or componentdidupdate lifecycle methods (assuming on react >= 14) should not undefined result. update: also refs not work on stateless components per caution link above

Excel VBA Goalseek -

i trying leverage goalseek command in vba in excel spreadsheet. have value in f3, f7, , f18. when change value in f3 error back: run-time error '1004': reference not valid here code private sub worksheet_change(byval target range) worksheets("mdl") if target = range("f3") range("f3").goalseek goal:=range("f7"), changingcell:=range("f18") end if end end sub the goalseek requires formula in cell creating it, if change range("f3") value instead of formula error appear.

.net - How to use registry string redirection to a managed DLL for MUI support? -

i've seen how use registry string redirection enable mui support, on stack overflow . example, can add redirected string value named displayname_localized registry localize program's entry in arp ui. example: @%programfiles%\myproduct\myresources.dll,-12345 unfortunately, can find talks using string's resource id identify string resource use. applies in unmanaged resource dll. have several resource dll's managed , built .net framework. issue don't see way string's id, or if there integer id since strings identified string names in associated resx files. is possible enable mui support in way, registry, managed resource dll? the link gave using registry string redirection indicates note topic pertains win32 pe resources. if using non-win32 pe resources, must provide customized registry string redirection, if required. as understand it, mechanism not support managed resource files, built .net framework. have use different mechanism. ...

tomcat - How can I automatically run a docker container on/after image build? -

i'm new docker sorry if miss obvious my plan dockerfile. pull tomcat:7.0 start server download helper files , unzip them. download required war file , rename root.war. i've managed running these commands manually. docker run -it --rm -p 8888:8080 tomcat:8.0 then manually doing wget 's , renaming, although done in docker file. this i've managed far. from tomcat:7.0 run /bin/bash -c "cd /usr/local/tomcat/webapps" run /bin/bash -c "wget -o files.zip https://***" run /bin/bash -c "unzip files.zip" run /bin/bash -c "rm -r root" run /bin/bash -c "wget -o root.war https://***" although not sure how run docker line earlier docker run -it --rm -p 8888:8080 tomcat:8.0 i've taken line official tomcat online here . noticed mentioned run default tomcat server (cmd ["catalina.sh", "run"]): have no idea how implement this. what dockerfile does, create image not containe...

javascript - Regex to replace non-numeric characters and insert dashes for phone number as it is typed -

i need javascript format telephone number typed. replace non-numeric characters , insert dashes if user doesn't type them in. far closest i've gotten, thrown off if put dash in wrong spot. ideal solution replace dashes in wrong spots. looking way possibly replace 4th , 8th digit differently haven't come solution. $('#telephoneno').keyup(function (ev) { if (/[^0-9\-]/g.test(this.value)) { this.value = this.value.replace(/[^0-9\-]/g, ''); } if (/^(\d{3})(\d)/.test(this.value)) { this.value = this.value.replace(/^(\d{3})(\d)/, '$1-$2'); } if (/^(\d{3}-\d{3})(\d)/.test(this.value)) { this.value = this.value.replace(/^(\d{3}-\d{3})(\d)/, '$1-$2'); } }); assuming want format "123-456-7890": function formatphonenumber(s) { var s2 = (""+s).replace(/\d/g, ''); var m = s2.match(/^(\d{3})(\d{3...

cURL PHP Upload Issues -

i'm trying make plain curl upload hugefiles.net, no luck. i have set $data['srv_tmp_url'] manually, (hope can done so) , upload_id parametar, avoid page scraping now. when script executes redirect me download link, file on link there contains 25 b. here code, hope can try , point out mistakes making, thanks. <?php function upload_curl($url,$data) { $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_timeout, 1000); curl_setopt($ch, curlopt_returntransfer,true); curl_setopt($ch, curlopt_ssl_verifypeer,false); curl_setopt($ch, curlopt_post, true); curl_setopt($ch, curlopt_postfields, $data); curl_setopt($ch, curlopt_followlocation, true); curl_setopt($ch, curlopt_referer, "http://hugefiles.net/"); $result = curl_exec($ch); return $result; } $filename = "test.rar"; $data = a...

bash - running scp script from exec function - PHP -

i trying scp file 1 server external mailserver. in code use: exec('/full/path/to/script.sh' '/full/path/to/file_to_transfer.txt'); in script.sh have: scp -i /full/path/to/private.key $1 [user]@[ip]:/opt/mailman/mailman-bundler/venv-3.4/lib/python3.4/site-packages/mailman/templates/en/. when call script file via cli, script runs fine , file transfers. when run in php apache/www-data user exec() call fails code: 126 - translates to: "command invoked cannot execute". extra notes: i noticed first time every user tries this, confirmation of rsa fingerprint. thought script stalling on , problem. manually went in www-data user , confirmed fingerprint. problem still exists. after many tries, created replica set of folders, scripts , files , opened permissions - way down root see if had wrong permissions set. still receive 126 error. my project manager against using idea of using php ssh2/scp functions (ex: http://php.net/manual/en/function.ssh2-...

javascript - Meteor displaying base64 image in HTML -

i creating meteor app users ask , anwser questions. using text editor user input. allows user insert images , inserts them in database in base64 format. question is there way display them in html helpers. code now: posts: function(){ var posts = posts.find({}); var postsarray = []; posts.foreach(function(entry){ var object = new object(); object.title = entry.title; object.image = entry.content.match(/src=(.*?)style/)[1]; console.log(object); postsarray.push(object); }) return postsarray; },// returns posts html: {{#each posts}} <h3>{{title}}</h3><br/> <img src={{image}}/> {{/each}} actually, found answer. mistake in regular expression: posts:function(){ var posts = posts.find({}); var postsarray = []; posts.foreach(function(entry){ var regex = /<img.*?src='(.*?)'/; ...

regex - Java: Find Lines which start with double slashes "//" -

i'm goint read someline text file. want remove lines starts // . used below syntax find line not working. don't know right regex this. glad if can correct me: if (line.startswith("//")){ /* related stuff*/ continue; } line.startswith("//") right way of checking if line starts in 2 forward slashes ( demo ). if check same thing using regex, expression "^//.*$" , ^ anchor stands beginning of line, $ stands end of line, , .* stands else in between ( demo ).

Constraint violation when trying to set "User Cannot Change Password" in active directory from c# -

i've tried multiple ways set flag "user cannot change password" in active directory c#. the following haven't worked: setting "cannotchangepassword" true on user principle object setting access rules on user object security on directory entry ( http://urslisworld.blogspot.ca/2010/02/set-user-cannot-change-password-in-c.html ) directly setting ntsecuritydescriptor ( http://sourcefield.blogspot.ca/2009/12/cactivedirectory-check-user-cannot.html ) and of course, can't directly set user account control property according https://support.microsoft.com/en-us/kb/305144 the first 3 each give exact same, highly cryptic error message, "constraint violation" extended message: 0000051b: atrerr: dsid-030f20ba, #1: 0: 0000051b: dsid-030f20ba, problem 1005 (constraint_att_type), data 0, att 20119 (ntsecuritydescriptor) here simplest case code should have worked (option 1): using (var context = new principalcontext(contexttype.domain, mydo...

mpi - How can my program detect, whether it was launch via mpirun -

how can mpi program detect, if launched standalone application or via mpirun? considering answer , comments semiuseless , hristo iliev, there no general , portable way this. workaround, can check environment variables set mpirun. see e.g.: http://www.open-mpi.org/faq/?category=running#mpi-environmental-variables

ado.net - Why does Azure Database perform better with transactions -

we decided use micro-orm against azure database. our business needs "inserts" , "selects", decided suppress code-managed sqltransaction (no concurrency issues on data). then, noticed our instance of azure database responded slowly. " rpc completed " event occured in delays hundreds times time needed run simple sql statement. next, benchmarked our code ef6 , saw server responded quickly. ef6 implements built-in transaction, decided restore sqltransaction (readcommited) on micro-orm , noticed fine. does azure database require explicit sqltransaction (managed code) ? how sqltransaction influence azure database performances ? why implemented way ? edit : going post more precise information way collected traces. seems our azure events logs express in nanoseconds, in milliseconds. seems weird. if understand asking correctly, batching multiple sql queries 1 transaction give better results on dbs. committing after every insert/update/delet...

c# - registering observers with IEventProcessor -

this part of ieventprocessor implementation taken here : public class simpleeventprocessor : ieventprocessor { public async task processeventsasync(partitioncontext context, ienumerable<eventdata> events) { foreach (eventdata eventdata in events) { } } } as new events added eventhub, processeventsasync method invoked , foreach loop can used process events. add observers simpleeventprocessor using, example, observerregistry discussed here . proposed observerregistry looks this: public class observerregistry : iobserverregistry<iprojectionwriterfactory> { ienumerable<object> getobservers(iprojectionwriterfactory factory) { yield return new loanapplicationobserver(); yield return new offerobserver(); // more observers... } } unfortunately, there few things missing. how register several observers simpleeventprocessor events passed processeventsasync observers , when methods? fu...