Posts

Showing posts from February, 2015

shell - How to pass an error exit code from a python script to the KSH script that calls it? -

i have python script called korn shell script. if python script runs error, korn shell script still exits 0. how python script tell ksh didn't terminate correctly? the rapper script looks this: python2.7 python_script.py ${inargument} >> ${log_file} 2>&1 exit_code=$? if [ ${exit_code} -ne 0 ] echo "python script failed" >> ${log_file} fi i'm not sure ksh, how python return non-zero return value, assume ksh can detect , deal that. import sys retcode = 5 sys.exit(retcode) or retcode = -128 raise systemexit(retcode)

bash script with cli options returns command not found -

this question has answer here: why should there space after '[' , before ']' in bash? 4 answers i have bash script set keyboard type of external , internal laptop keyboards (so both usable , output correct characters). the main part of script works fine, have problem switch / case capturing command line options. this full script #!/bin/bash ###functions first usage() { echo "script set internal , external keyboards french , english repectively" } setkeyboardmap() { echo "setting dual keyboard." echo "setting keyboard types..." setxkbmap -device 13 fr setxkbmap -device 10 gb echo "done" } ##the main show #capture command line parameters if ["$1" = ""]; #no command line parameters setkeyboardmap exit 0 else while [ "$1" != " ...

ember.js - modal popup with ember 1.0 rc6 -

how create modal popup latest version of ember.js? every single example i've found uses connectoutlet, deprecated while ago, , fact i'm new ember doesnt help. i have named outlet in application template, how render modal popup view outlet controller event? or should use route event? adam hawkins published excellent post on topic, can find here: http://hawkins.io/2013/06/ember-and-bootstrap-modals/ to summarize: include {{outlet modal}} in application.hbs render outlet router using events animation triggered view's didinsertelement hook , on it's close action modal's close action should target view, waits animation complete before sending close event router from adam's jsfiddle: app.applicationroute = ember.route.extend({ events: { open: function() { this.render('modal', { into: 'application', outlet: 'modal' }); }, close: function() { this.render('nothing', { into: 'a...

MatLab: Saving result and also in which line of which m-file the computation was done -

i have main.m goes delete output.txt diary output.txt x=1 y=2 diary off and a.m contains function [a1, a2] = a(x,y) a1=x+y a2=x-y while a1<5 a1=a1+1 end i want matlab save output txt file has every computational result @ line of m-file computation done: x=1 main.m, line 3 y=2 main.m, line 4 a1 = 3 a.m, line 2 a2 = -1 a.m, line 3 a1 = 4 a.m, line 5 a1 = 5 a.m, line 5 i haven't heard standard way of doing this. if there undocumented way of doing this, make debugging extremely convenient. have idea? the easist way display result function disp in matlab - http://www.mathworks.com/help/matlab/ref/disp.html you need come-up framework of output results. example, using code example: if x==1 disp('main.m - line 3') elseif y==2 disp('main.m - line 4') elseif a1==3 disp('a.m, line 2') elseif a2==-1 disp('a.m, line 3') elseif a1==4 disp('a.m, line 5') elseif a1==5 disp('a.m, l...

google spreadsheet - How can I set a range using the value of a cell? -

i having little trouble tweaking google script. have shown part of below , try explain trying do. below part of script: function setup() { var ss = spreadsheetapp.getactivespreadsheet(); (i = 1; <= 1; i++) { var sheet = ss.insertsheet('final grades'); sheet.getrange("a2").setformula("=arrayformula(if(isblank(grades!a9:a96),, vlookup(grades!a9:a96, grades!a9:g96, 4, false)))"); i trying replace range in isblank , vlookup commands based on total entries. have cell, located in 'grades' sheet in cell b5 contains total number of entries. trying have script take value in b5 , add range in isblank , vlookup commands. right range a9:a96 both isblank , vlookup, trying accomplish take value located in b5 (let's 80) new line be: sheet.getrange("a2").setformula("=arrayformula(if(isblank(grades!a9:a89),, vlookup(grades!a9:a89, grades!a9:g89, 4, false)))"); the second part of range in isblank , vlookup has changed...

Android connect bluetooth L2CAP device(PS4 Controller), how to do through root? -

i try connect phone l2cap device (ps4 controller), uses l2cap bluetooth connection protocol. documentation of dualshock 4 controller: http://www.psdevwiki.com/ps4/ds4-bt android officially not support l2cap anymore. since android 4+ 'hide' it. (but can still found everywhere in source code) source: https://android.googlesource.com/platform/frameworks/base/+/android-6.0.1_r31/core/java/android/bluetooth/bluetoothsocket.java http://developer.android.com/intl/es/reference/android/bluetooth/bluetoothsocket.html but read on internet, cannot called, trough root. does know if can done bluedroid? or have example how root? this impossible, because not allow calling function in package -> msocket = new bluetoothsocket(bluetoothsocket.type_l2cap, -1, true, true, this, 2, null); any or guidance appreciated!

java - Why is final variable not inspectable? -

i'm reworking code make usable new roottools 3.0 (which fixes important bug) : one section rewrote looks this, callback-class better readability. i'm adding size of 2 directories tell total of browser cache may cleared: @override protected void onresume() { super.onresume(); //refresh views: try { //show browser's cache size: shellcommands.getlisting("/data/data/com.android.browser/app_databases/", null, new callback<sumsize>() { @override public void call(sumsize localstore) throws interruptedexception, ioexception, timeoutexception, rootdeniedexception { final sumsize total = localstore; getfirefoxprofiles(new callback<string>() { @override public void call(string input) throws interruptedexception, ioexception, timeoutexception, rootdeniedexception { shellcommands.getlisting(input+"/cache/...

asp.net mvc 5 - Creating Model for two different tables already existent - MVC 5 -

i have problem using mvc. i created model name po_header purchase order header , other model name po_detail purchase order details. the problem have both tables created in database, po_header , po_detail how create 1 controller , views both tables? they in different tables need add them in same form when click create/add, both tables updated. model po_header: [table("po_header")] public class po_header { [key] [displayname("número pedido")] public string ponumber { get; set; } [displayname("cliente")] public int customerid { get; set; } [foreignkey("customerid")] public virtual customers customers { get; set; } [displayname("expedidor")] public string shipper { get; set; } [displayname("rta")] [datatype(datatype.datetime)] [displayformat(dataformatstring = "{0:dd/mm/yyyy}", applyformatineditmode = true)] public datetime rta { get; set; } [disp...

c# - How to read by streamreader and sort -

i'm making passaparola game , @ end of game save nickname , score stream writer nickname;score i'm trying make leaderboard dont know how sort them highest lowest @ or after saving. also display them on labels wrote ; string[] scorearray; string sc = sr.readline(); scorearray = sc.split(';'); label2.text = scorearray[0]; label3.text = scorearray[1]; which writes first line in text file.anyway how can sort , write them in labels ? sort array , use foreach loop display results: string[] scorearray; string sc = sr.readline(); scorearray = sc.split(';'); array.sort(scorearray); foreach (string s in scorearray) { //your code here. }

java - Preserving a folder and its content during an installation update -

i have solution in mind don't know how accomplish natively in install4j. i have folder containing repository of artifacts (similar maven's .m2 repository folder schema) file names uniquely generated (timestamp) during maven compilation. e.g. ./install-dir/artifacts/app-core/jar/1.2-t20160419183129/app-core-1.2-t20160419183129.jar after running installer "update existing installation" checked, install4j append these files , preserve older timestamped version of artifact. not bug , working intended. end result like: ./install-dir/artifacts/app-core/jar/1.2-t20160415154633/app-core-1.2-t20160415154633.jar ./install-dir/artifacts/app-core/jar/1.2-t20160419183129/app-core-1.2-t20160419183129.jar nothing changed in these files timestamp generated during compilation. there method can approach within install4j verify if component mentioned above newer installers counterpart. have ignore timestamp , take account version number , md5 checksum. right now, removin...

javascript - Automatically toggle html tabs -

i have following tab structure in form of form submit button on second tab. possible tabs auto-change upon condition? <ul class="nav nav-tabs"> <li class="active"><a data-toggle="tab" href="#home">home</a></li> <li><a data-toggle="tab" href="#menu1">menu 1</a></li> <li><a data-toggle="tab" href="#menu2">menu 2</a></li> </ul> <div class="tab-content"> <div id="home" class="tab-pane fade in active"> <h3>home</h3> <p>some content.</p> </div> <div id="menu1" class="tab-pane fade"> <h3>menu 1</h3> <p>some content in menu 1.</p> </div> <div id="menu2" class="tab-pane fade"> <h3>menu 2</h3> <p>some content in menu 2.</p> </div> </div> ...

apache spark - Recursive case class to DataFrame -

how make dataframe given case class references itself? take following: case class testcase(id: long, parent: option[testcase]) if do: val testcases = seq(testcase(1l, none), testcase(2l, some(testcase(1l, none)))).todf it throws big, 'olde scalareflection error. of course, do: case class testcase(id: long, parentid: option[long]) but that's not want. incidentally, avro has no issue encoding , decoding recursive schemas. don't think i'm asking impossible. seems normal use-case handling parent-child relationships. update i can manually create schema, far can tell, have hard-code how far chain can go repeatedly nesting structtype s. this: val schema = structtype(array( structfield("id", longtype, false), structfield("parent", structtype(array( structfield("id", longtype, false), structfield("parent", structtype(array( structfield("id", longtype, false), structfield("p...

asp.net mvc 5 - Visual Studio 2015 MVC Project Template Access Denied -

Image
i've created simple mvc application in vs2015 has basic css styling , html application off ground more quickly. the application runs perfectly. i've exported template using file -> export template... i created brand new project based off project type. far good. but, when run newly created project blank page "access denied" (see image). i've been going on template project , new project fine tooth comb , can't find differences. why 1 work other give access denied? out of ideas, appreciated. edit: after more research have found cause of problem, not solution. it seems project template has "anonymous authentication" disabled, , has "windows authentication" set enabled in project settings. when create project based on template these values flipped , causes access denied. here's image of project settings in template : here's image of project settings in "new" project: note both authentication se...

Reading values from file stream to an array (C) -

i have been thinking on while. given assignment says following: there text file containing numbers. (min, max, number) have read contents of file, generate random number between min , max. if generated number matches number, print "match." min: 7 max: 17 number: 15 ... i able read every number array, code: int main(void) { srand(time(null)); int nums[50] = {0}; int = 0; file * fp; /*if(fp == null) return 1;*/ if (fp = fopen("numbers.txt", "r")) { while (fscanf(fp, "%d", &nums[i]) != eof) { ++i; } fclose(fp); } (--i; >= 0; --i) printf("num[%d] = %d\n", i, nums[i]); return 0; } however, have no idea how continue. how can assign specific values random number generator function? int random(int min, int max) { return rand()%(max-min+1)+min; } solution - you shouldn't use array since don't need store numbe...

javascript - Process message from Webworker created by unreachable code -

i'm new javascript, i'm sorry if answer obvious. i want send message main thread web-worker. don't have access part of code create worker can't add worker.onmessage = [...] . have access javascript code executed @ begining of process, not 1 create workers. i wondering if there's way window.oneverymessagefromanyworker = dosomemagic() thanks lot! no, that's not possible. need handle web worker in order listen messages. make sure can't change code makes worker, if you can't read below: hacky solution if you're writing userscript or other "hacky" code, suggest override worker constructor: // execute before worker being created window.oldworker = worker; window.worker = function(path) { console.log("worker created: ", path); // original worker applied on object return new oldworker(path); } note nasty piece of code . might break things. once have code, can access worker created: window.worker ...

model - Rails: How to make a setter method find_or_create within an association? -

i have project model belongs_to company , notary . notary belongs_to company . in project model have following getter / setter methods: class project < activerecord::base belongs_to :company belongs_to :notary # getter method notary def notary_name notary.try(:name) end # setter method def notary_name=(name) self.notary = notary.find_or_create_by(name: name) if name.present? end end the setter method checks if notary exists or else creates new record. the issue if user company inputs existing notary name not create new record. the syntax should like: self.notary = current_company.notaries.find_or_create_by(name: name) if name.present? however current_company not available @ model-level. suggestions how solve this?

ServiceNow reports to pull data related to changes -

how create report give me list of changes , it's associated "affected cis". e.g. have change ticket created in servicenow chg00001 following values configuration item , affected cis: change number: chg00001 configuration item: server1 affected ci: apache jboss so when create report need these information including affected cis, don't see way pull information. you want use cis affected [task_ci] table. table contains links between change requests , configuration item . the task field in table contains reference change request . in report, try this data: table => cis affected [task_ci] type: list group by: task selected columns task configuration item filter task.task type is change request you can expand task reference in selected columns more details on change request if needed, or filter them deeper. if you've filtered task type change request , can select extended table change request , filter way ...

column subsets and indexes in R in modifying a data frame -

for dataset in r, mtcars, trying make subset of data frame, column 1, 2, , 8 , 9. want index columns 8 , 9 can call upon 1 or other in function in order output. so did highestmpg <- function(cyl, type) { type <- mtcars[, c(8, 9)] df <- mtcars[, c(1, 2, type)] i got error far function error in .subset(x, j) : invalid subscript type 'list' i don't understand error, can me figure out how circumvent error? my purpose make data frame in can later input column 2 (cyl), either column 8 or 9 value (0 or 1), in order value column 1 (mpg) i want rank mtcars cyl, type, in order end organized data frame mpg, in order later find highest mpg, depending on input ranking <- mtcars[order(cyl, type, mpg)] i apologize in advance, still beginner in r, , might not correct in terminology , appreciate advice! if execute code have given don't error report, different one. assume missed parenthesis when type second line should read: type <...

wpf - Alternatives for textbox and flowdocument for displaying testscript code in C# application -

i trying create windows application opens test script , displays contents of testscript (python script) on application's mainwindow.xaml . newbie wpf. tried using textbox , flowdocument reader. displayed script not good. there alternatives?

continuous integration - Visual Studio Team Services - release management - Build (error missing nugget) -

Image
i new visual studio team services , trying apply release management. in scenario, have local machine "a" has visual studio 2015 installed , connected vsts. i going check in code changes machine , use agent new releases release management (installed agent service on it) i have created agent under new pool mymachine , downloaded machine a, , service running. i created release definition (with 2 environments, no tasks) , bind build definition. build definition uses visual studio template: and mymachine default agent queue : i commit new changes machine a, new builds add vsts gives following error( change mymachine pool hosted , error persists) questions: where build happening when specify hosted pool , mymachine pool? what cause of build error , how fix it? you have restore nuget packages on hosted build agent. can add nuget restore step before visual studio step:

php - Uploading and accessing files in Azure without using the Data Storage -

if using windows azure , asp.net web site php script upload files, can access files server or must use data storage facilities? i.e. i'd reference files directly html\server... etc. think should able to. thank you. how hosting asp.net website. if it's hosted in web role, won't have access persistent "standard" file system role. (especially if you've scaled on multiple instances). have @ following tutorial on using blob storage php. http://www.windowsazure.com/en-us/develop/php/how-to-guides/blob-service/ you can use blob storage quite access them standard http links asp.net site. i.e. http:// your-storage-account .blob.core.windows.net/ your-container /file.txt

php - Programmatically creating new order in Woocommerce -

i having hardest time programmatically creating order in woocommerce. using code below , create order cannot customer information or product line items added order. new order create guest no items, user information, etc. the issue seems once order object created, failing when trying add data order. function create_vip_order() { global $woocommerce; $address = array( 'first_name' => '111joe', 'last_name' => 'conlin', 'company' => 'speed society', 'email' => 'joe@testing.com', 'phone' => '760-555-1212', 'address_1' => '123 main st.', 'address_2' => '104', 'city' => 'san diego', 'state' => 'ca', 'postcode' => '92121', 'country' => 'us' ); // create order $order = wc_...

Format the result of loop php -

i'm stuck of making table 4 columns, , data of table comes array, code i've done: $sample // array , has 15 values inside <table> foreach($sample $x){ $rows="<td>$x</td>".$rows; $l++; if($l==4){ echo"<tr>".$rows."</tr>"; $l=0; $rows=""; } } </table> if i'm correct code produce table width 3 rows , 4 columns, missing content need include of data inside $sample need kind of output code. [1][1][1][1] [1][1][1][1] [1][1][1][1] [1][1][1][0] the 1 array value of $sample while 0 has no value, because value og $ sample 15 only try this: <?php echo "<table border='1'>"; $sample = array("1","2","3","4","5","6","7","8","9","10","11","12","13","14","15"); #with 15 rows echo "<tr>...

how to know whether an .apk can be reverse engineered in android -

hi friends got know there website in when give our apk file whether can reverse engineered or harder reverse engineer when applied reverse engineering.but goggled lot couldn't find website can please tell me website. each .apk reversible need right tool. try xda developers forums, http://forum.xda-developers.com/showthread.php?t=1910873

swift - Catch multiple errorTypes? -

i'm looking way catch multiple types of errors in catch . i've tried fallthrough , comma separated style switch statement , neither works. docs nothing catching multiple pattern 1 . it's not clear me of pattern syntaxes work here. error definitions (sample): enum apperrors { case notfound(objecttype: string, id: int) case alreadyused } works: do { //... } catch apperrors.notfound { makenewone() } catch apperrors.alreadyused { makenewone() } catch { print("unhandled error: \(error)") } does not compile, possible this? do { //... } catch apperrors.notfound, apperrors.alreadyused { makenewone() } catch { print("unhandled error: \(error)") } if want catch apperrors , can use pattern: catch apperrors if you're looking more specific matching, seems ugly. this let catch specific cases of apperrors : catch let error apperrors error == .notfound || error == .alreadyused there's syntax seems work: ca...

reactjs - Rendering React Ajax with proper child access -

i don't see why 1 works , other doesn't hoping can shed rays of light. that is: *some component constructor this.state = { datatransform: '' }; render(){ if (this.state.datatransform === ''){ return null; } else { return ( <chart config={this.state.datatransform}/> ); } } vs https://facebook.github.io/react/blog/2014/07/17/react-v0.11.html#rendering-to-null no initialization of datatransform or undefined render(){ if (!this.state.datatransform){ return null; } else { return ( <chart config={this.state.datatransform}/> ); } } this 1 return error unable read property of datatransform of null until request done , state updated.yet, top 1 works no problem no error messages while performing request. though react example https://facebook.github.io/react/tips/initial-ajax.html loads within same component want remain stateless...

android - NullPointerException when trying to access TextView in CustomSpinner -

i trying use custom spinner calender view. have written own custom adapter. view loads fine try click on 1 of items in spinner dropdown app crashes. following activity code : public class calendareventsactivity extends activity { protected activityheader mheader; private spinner mmonthdropdown; @override protected void beforemaincontentcreated(bundle savedinstancestate) { } public void oncreatemaincontent(bundle savedinstancestate) { super.oncreatemaincontent(savedinstancestate); setrequestedorientationbyresourceid(r.integer.allow_landscape_calendar_events_activity); getwindow().setbackgrounddrawable(null); setcontentview(r.layout.activity_calendar_events); mheader = (activityheader) findviewbyid(r.id.header); getslidingmenu().setslidingenabled(false); setupmonthspinner(); } private void setupmonthspinner() { mmonthdropdown = (spinner) findviewbyid(r.id.month_spinner); string[] items = new string[] { "january", "febru...

css - Prevent link from changing when mouse button is released -

i have element like: <a id='a_id' class='a_class'>next</a> the element shows in green, underlined. when hover on element, changes lighter green, not underlined (which fine). when click, during mouse button down nothing changes. when release mouse button, element changes briefly showing green background , goes lighter green, not underlined. how can change css prevent change when release mouse button? i tried following css: .a_class { cursor:pointer; outline:none; text-decoration:none; background:#fff; } thanks. update #1 - using .a_class:active i added following css: .a_class:active { outline:none; text-decoration:none; background:#fff; color:red; } i added color:red confirm css being applied. when press down mouse button, text color changes red. , when release mouse button, background flashes in green second. any other suggestion? thanks. update #2 - adding full css of link when inspect...

Binding events when using a ngForTemplate in Angular 2 -

let's i've got simple list rendering component: import {input, component } 'angular2/core' @component({ selector: 'my-list', template: ` <div *ngfor='#item of items' (click)='onitemclicked(item)'> {{item}} </div> ` }) class mylist { @input() items: string[]; onitemclicked(item) { console.log('item clicked:', item); } } i use this: <my-list [items]='myappsitems'></my-list> so far good. next decide want user able supply own template rendered items, change component @component({ selector: 'my-list', template: ` <template ngfor [ngforof]="items" [ngfortemplate]="useritemtemplate" (click)='onitemclicked(item)'> </template> ` }) class mylist { @input() items: string[]; @contentchild(templateref) useritemtemplate: templateref; onitemclicked(item) { console.log('item clicked:...

r - Largest set of columns having at least k shared rows -

i have large data frame (50k 5k). make smaller data frame using following rule. given k, 0>k>n, select largest set of columns such k rows have non- na values in of these columns. this seems might hard computer on big data frame, i'm hoping possible. have written code operation. it seems way of doing complex. relies on (1) computing list of possible subsets of set of columns, , (2) checking how many shared rows have. small numbers of columns (1) gets slow (e.g. 45 seconds 25 columns). question: theoretically possible largest set of columns sharing @ least k non- na rows? if so, more realistic approach? @alexis_laz's elegant answer similar question takes inverse approach mine, examining (fixed-size) subsets of observations/samples/draws/units , checking variables present in them. taking combinations of n observations difficult large n. example, length(combn(1:500, 3, simplify = false)) yields 20,708,500 combinations 500 observations , fails produce combi...

c++ - Frequency - linear bins to logarithmic screenspace -

i'm working on project, need visualize spectral analysis set precise parameters. i'm conversion of bins screen space, because in linear space, magnitudes in lower frequencies squashed together. here's code in c++: float windowsize = 640; float windowheight = 480; (size_t = 0; < bins; i++) { float m = audioin.getspectrum.at(i)*windowheight; float pos = i; drawline(vec2(pos, 0), vec2(pos, m)); } i trying compute pos using different approaches, failed miserably. i'm missing crucial knowledge logarithms guess. disclaimer: personal art project, not homework assignment. typically spectrographs displayed on base 10 logarithmic scale. assuming bins in case go 0 hz nyquist hz might try (for 44.1khz audio): float nyquist = 22050.0; float logmax = log10(nyquist); float log = log10((float)i * nyquist / (float)bins); float pos = log / logmax * windowsize;

python - How do I get the log file a program creates when running it with subprocess.call()? -

i work gaussian, program molecular geometry optimization, among other applications. gaussian can take days end single optimization decided make program on python send me e-mail when finishes running. e-mail sending figured out. problem gaussian automatically generates log file , chk file, contains actual results of process , using subprocess.call(['command'], shell=false) both files not generated. i tried solve problem os.system(command) , gives me .log file , .chk file, e-mail sent without waiting optimization completion. another important thing, have run entire process in background, because said @ beginning might take days on , can't leave terminal open long. by using subprocess.call(['command'], shell=false) both files not generated. your comment suggests trying run subprocess.call(['g09 input.com &'], shell=false) wrong. your code should raise filenotfounderror . if don't see it; means stderr hidden. should fix (mak...

MySQL: where count is higher than average -

i want select posts users have specific followers higher overall average (compared other users) the problem when use avg() limits number of posts/users coming through, yet can't use group j.id break average count , where j2.fcount >= j2.oavg stops working properly here's code select * ( select j.*, round(avg(j.fcount)) oavg ( select p.id , count(fcount.id) fcount `post` p left join `table` table on ... left join `user` user on .... left join `follow` fcount on fcount.user_id=user.id , fcount.follow_id=table.ids p.user_id=fcount.user_id group p.id ) j ---- > `group j.id` - breaks average below ) j2 j2.fcount >= j2.oavg thank :) because you're trying compare average, might have inner query twice this. select *, (select avg(fcount) average (select count(fcount.id) fcount post p left join follow fcount on fcount.user_id = p.user_id group p.id )j1 )as average (select p2.id,...

Cant get a Docker image with apache to display the test webpage -

i have docker image have put apache. want when container starts, apache starts , can visit test page. however, page not appearing when try. this current dockerfile: from centos:7 maintainer me <me@me.com> run yum update -y && yum install -y httpd php run (cd /lib/systemd/system/sysinit.target.wants/; in *; [ $i == systemd-tmpfiles-setup.service ] || rm -f $i; done); \ rm -f /lib/systemd/system/multi-user.target.wants/*;\ rm -f /etc/systemd/system/*.wants/*;\ rm -f /lib/systemd/system/local-fs.target.wants/*; \ rm -f /lib/systemd/system/sockets.target.wants/*udev*; \ rm -f /lib/systemd/system/sockets.target.wants/*initctl*; \ rm -f /lib/systemd/system/basic.target.wants/*;\ rm -f /lib/systemd/system/anaconda.target.wants/*; volume [ "/sys/fs/cgroup" ] expose 80 expose 443 cmd ["/usr/sbin/init"] cmd ["/usr/sbin/httpd", "-d", "foreground"] i running container command docker run -d -p <container_name> , , wh...

php - WordPress doesn't save my custom setting in permalink section -

i have created many custom settings in wordpress using settings api, reason having trouble 1 in particular. i want include custom url shortener using wordpress's shortlink feature, added custom setting store url shortener's domain name. allows customizable. function urb_admin_init_shortlink_domain() { $option_group = 'permalink'; $option_name = 'shortlink_domain'; $sanitize_callback = null; register_setting( $option_group, $option_name, $sanitize_callback ); $id = 'shortlink_domain'; $title = 'shortlink domain'; $callback = 'urb_shortlink_domain'; $page = 'permalink'; $section = 'optional'; $args = null; add_settings_field( $id, $title, $callback, $page, $section, $args ); } function urb_shortlink_domain() { $option = 'shortlink_domain'; echo '<input type="text" name="' . $option . '" id="' . $option . '" value="' . ...

javascript - How can I print PHP POST data using AJAX? (no jQuery) -

so i've got html. <form method="post" id="myform" onsubmit="getdata()"> <fieldset> <legend>form</legend> <label>color: <input type='text' id="color" name='color'></label> <label><input type="submit"></label> </fieldset> </form> <div id="showoutput"> </div> this php: <?php $color = $_post['color']; if($color != "") { $color = htmlentities($color, ent_quotes); print "<p>the color $color</p>"; } else { print "<p>fill out form!</p>"; } ?> and js: window.onload = getdata; var req = new xmlhttprequest(); function getdata() { var poststr = "color=" + encodeuri( document.getelementbyid("color").value ); req.open("post", "lab11-1.php", true); req.onreadystatechange = user...

Spring Boot conditonally enable DataSourceAutoConfiguration based on system property -

Image
i have following dependency in project , have @springbootapplication in main class spring-boot-starter-data-jpa there way conditionally enable spring boot datasourceautoconfiguration class based when env property/system property present. thanks it appears if define property "spring.datasource.initialize" false, initialization logic skipped. if @ datasourceautoconfiguration definition, loads in configuration properties... that datasourceproperties has attribute named "initialize", , appears referenced in datasourceinitializer default implementation... i read being able use property skip datasource initialization. hope helps

ruby on rails - Implement plugin specific settings in Redmine -

i'm developing plugin redmine , encountered issue of how implement plugin specific settings in redmine in neat way. is possible have plugin specific settings in {redmine_home}/plugin/{my_plugin}/config/settings.yml while sharing core model (in mvc terms) logic reads yaml file, sets attributes of model class, provides easy access them, etc. ( {redmine_home}/app/models/setting.rb ) i think copypasting or require 'ing core model in plugin model poor design right i'm tending have plugin specific settings in core config {redmine_home}/config/settings.yml , when comes plugin controller read settings relies on core model that. ( {redmine_home}/app/models/setting.rb ) is proper design? there better ways this? thanks. i checked 3 different plugins in our project used like: options = yaml::load( file.open(file.join(rails.root, 'plugins/fancy_plugin/config', 'settings.yml'))) so copy pasting.

asp.net - Override TreeNode in databound TreeView? -

i know if subclass treenode can add nodes collection within treeview. treeview working on @ moment databound, there way tell treeview type nodes should be? thnaks, joe figured out. subclass treeview , override createnode method. public class permissionstreeview : treeview { protected override treenode createnode() { return new permissionstreenode(); } }

python - When timeout is more than 10,000 in pycorenlp I get "java.net.UnknownHostException: server: server: unknown error" on Linux (runs fine on OS X). Why? -

i trying run pycorenlp on long text. in order avoid getting corenlp request timed out. document may long error message, increased stanford corenlp specifying timeout. here code use (it's simplified version of pycorenlp's example.py ): from pycorenlp import stanfordcorenlp if __name__ == '__main__': nlp = stanfordcorenlp('http://localhost:9000') text = ( 'pusheen , smitha walked along beach. pusheen wanted surf,' 'but fell off surfboard.') output = nlp.annotate(text, properties={ 'timeout': '10001' # setting timeout 10000 or below "fixes" issue. 'annotators': 'tokenize,ssplit,pos,depparse,parse', 'outputformat': 'json' }) print(output) it outputs server: unknown error . server log contains: java.net.unknownhostexception: server: server: unknown error @ java.net.inetaddress.getlocalhost(inetaddress.java:1505) ...

openmp - run 2 different functions simultaneously C++ Open MP -

i want run 2 absolutely different functions simultaneously. tried check if works: #pragma omp parallel { #pragma omp single nowait { #pragma omp task { (unsigned long long i=0; i<numsteps; i++) sum1 = sum1 + 4.0/(1.+ (i + .5)*step*(i + .5)*step); } #pragma omp task { (unsigned long long i=0; i<numsteps; i++) sum2 = sum2 + 4.0/(1.+ (i + .5)*step*(i + .5)*step); } #pragma omp taskwait } } with 1 cycle ends in 10s , loads cpu on 100%. with 2 cycles want run simultaneously on 2 different cores ends in 24s , loads cpu on 200% expected near 10s. without #pragma omp single nowait ends calculations in 138s , loads cpu on 400%. what doing wrong?

jquery - True-False condition inline on HTML element (checkbox) -

i have code: <input type='checkbox'> i want make conditional using jquery, example, if data[1].condition true , set checked, if not not. may like: <input type='checkbox' + if data[1].condition false, unchecked + "'> <input type='checkbox' + if data[1].condition true, checked + "'> is there way set inline? like: <input type='checkbox' + data[1].condition | checked + "'> there's not way inline. using jquery... if(data[1].condition === false){ $('input').removeattr('checked'); } else { $('input').prop('checked', true); }

awk - Write two loops output in two columns in shell? -

how can write following in efficient way: for j in {1..339};do in {1..427};do echo -e $j'\t'$i >> ofile.txt done done here 1 alternative without explicit loops join -j9 -t$'\t' <(seq 339) <(seq 427) | cut -f2- > ofile.txt

Convert grib to netcdf file -

is there way convert grib file netcdf format on windows? use software named tkdegrib catches 1 argument 1 argument whereas want grib's arguments in same file. unfortunately, can't use linux. i use unidata's netcdf-java library . it reads grib , grib2 files (as many others), , can write netcdf files. , since it's java, don't have build anything, , works on platforms. there toolsui application can use if want gui, more want command line using this: java -xmx512m -classpath netcdfall-4.3.jar ucar.nc2.dataset.netcdfdataset -in infile.grib2 -out outfile.nc good luck!

java - how to use driver program in jgrasp -

i have program written , there driver program test code have written , can not figure out driver run program in jgrasp? know how accomplish this? if have source code driver, open it, compile if necessary, , run. if have .class file, there no simple way run in jgrasp.

javascript - react-native AES Encryption matching Java Decryption algorithm -

the full code of java encryption/decryption algorithm: public class aesencryptutil { private static aesencryptutil instance = new aesencryptutil(); private string password = "123456"; private key key; private cipher cipher; public aesencryptutil(){ try { keygenerator kgen = keygenerator.getinstance("aes"); kgen.init(128, new securerandom(password.getbytes())); secretkey secretkey = kgen.generatekey(); byte[] encodeformat = secretkey.getencoded(); key = new secretkeyspec(encodeformat, "aes"); cipher = cipher.getinstance("aes"); } catch (exception e) { e.printstacktrace(); } } public static byte[] encrypt(string content) throws exception { byte[] bytecontent = content.getbytes("utf-8"); instance.cipher.init(cipher.encrypt_mode, instance.key); byte[] result = instance.cipher...

How to call the right object classes based on variable in PHP? -

situation using php 5.5, i allow user submit form has dropdown. based on dropdown, call different classes particular operation. what's wrong? currently, use switch case, number of classes balloon 3 25. switch case ugly. this code // call right reader based on vendor switch($vendor) { case 'a': $vendorreader = new areader(); break; case 'b': $vendorreader = new breader(); break; case 'c': default: $vendorreader = new creader(); break; } i deliberately named these classes way, easier use variable $vendor call constructor of relevant $vendorreader class. what's way call right reader class based on variable? if user selection coming dropdown, can infer it's coming form via get/post? in case, can not use name of menu? if (isset($_post['my_class_selection_dropdown)) { $selection = $_post['my_cla...

javascript - Cursor position abnormally situated at the end of the input value in Chrome -

i coded jquery function remove automatically single , double quotes while writing text in input box. in firefox goes in chrome, if want add beginning of text, not allowed. because cursor situated @ end of input value. don't know how fix it. here code: $.fn.removequotes = function() { var elem = $(this); elem.bind("focus propertychange change click keyup input paste", function(event) { settimeout(function () { elem.val(elem.val().replace(/['"]/g, "")); }, 1); }); }; edit: after comments, tried this: $.fn.removequotes = function() { var elem = $(this); elem.bind("focus propertychange change click keyup input paste", function(event) { // store current positions in variables var start = this.selectionstart, end = this.selectionend; settimeout(function () { elem.val(elem.val().replace(/['"]/g, "")); ...

find if string contains mutliple words in r -

i have following data frame: dat <- data.frame(name = c("john", "company pty ltd", ""), surname = c("smith", "", "company b"), company = c("company d", "a ltd", "company b")) i want check if company column contains word either in firstname or surname. i have used following code: dat$cliniconly <- mapply(grepl, pattern=dat$firstname, dat$company) but checks whole string present. hence works first row, misses second row, , gets last row correct because detected blank firstname entry. how write function produces false, true, true ? how this, using intersect hard work?: v1 <- strsplit(do.call(paste, dat[1:2]), "\\s+") v2 <- strsplit(as.character(dat$company), "\\s+") mapply(function(x,y) length(intersect(x,y)) > 1, v1, v2) #[1] false true true

mips - QtSpim Character Insertion -

the program accepts single-letter keyboard input @ time. letter inputs must lower case through z (no upper-case or non-letter characters allowed; lower-case letters). 1 letter must input @ time; make sure character lower-case letter. • in data declaration, declare alphabetized string of letters (named “str”), a-z. • program must input character keyboard, determine place in string, , make space in string character, inserting in proper alphabetical order. • after alphabetized string of 26 letters, declare sequence of 30 nulls (using “.space” directive), expansion space string insert characters alphabetized list. • @ point, can ask print current string (i.e., many letter inserts have been made far) inputting capital p keyboard. • finally, program must use recursive routine insert letter in correct point in program. my code far .data str: .asciiz"abcdefghijklmnopqrstuvwxyz\n" espace: .space 30 pro...

javascript - how to show div on under button on onclick event -

from code have 3 button ,now cliked ** reply button 1** means want show 1 textarea bottom of button( reply button 1).else have select reply button 2 means want show textarea under reply button 2..i don't know how do.i new developer please me one <div class="comment"> <div class="img-thumbnail"> <img class="avatar" alt="" src="../tv/dist/img/user2-160x160.jpg"> </div> <div class="comment-block"> <div class="comment-arrow"></div> <span class="comment-by"> <strong>kani</strong> <span class="pull-right"> <a href="javascript:void(0)" rel="<?php echo $com['id']//1?>" class="reply-btn"><i class="fa fa-reply"></i> reply button 1</a> </span> </span> <p>lorem ipsum dolor...