Posts

Showing posts from January, 2013

Use lineinfile to fill ansible inventory file -

i have trivial task fill particular ansible inventory file new deployed vms names under roles. here playbook: - hosts: 127.0.0.1 tasks: - name: add host inventory file lineinfile: dest: "{{inv_path}}" regexp: '^\[{{role}}\]' insertafter: '^#\[{{role}}\]' line: "{{new_host}}" instead of adding new line after [role], ansible replace string hostname. aim naturally insert after it. if there no matched role should skip add new line. how achieve this? thanks! [role] getting replaced because regexp parameter regular expression ansible replace line parameter. move value insertafter , rid of regexp . as other requirement need task check if [role] exists first. lineinfile task evaluate result of checker task determine if should run. - name: check if role in inventory file shell: grep [{{ role }}] {{ inv_path }} ignore_errors: true register: check_inv - name: add host inventory file ...

Executing shell commands in VxWorks 6.9 RTP application -

how can execute shell commands dump memory (d()) , xbdcreatepartition , dosfsvolformat , dosfsshow rtp application program? linux provides system commands job, how achieved in vxworks6.9? if looking equivalent of system() , allow execute arbitrary command, out of luck. however, "shell" used interacting c interpreter, , command running available called code. call dosfsvolformat example own code. there caveat here, functionality implemented in kernel, , these functions may not available in rtp. functions available vary release release, , may dependant on kernel configuration. can compare user versions of headers kernel version see might available. you can write own system calls, however, expose kernel functionality rtp application.

Visual Studio RelatedFiles Registry Key Mysteriously Overwritten -

in order organize t4-generated files within solution, , per this excellent answer , have .reg file use add key , 3 values under following visual studio registry key (currently formulated vs 2015): hkey_current_user\software\microsoft\visualstudio\14.0_config\projects\{fae04ec0-301f-11d3-bf4b-00c04f79efbc}\relatedfiles\ periodically , intermittently, find key has been overwritten , must run .reg file again restore custom visual studio behavior. have seen happen every few months or so, many years, across several versions of windows , vs, on many machines, , 3 different domains (on 1 of sole admin). there's no obvious (to me) temporal association between overwrites , either group policy or visual studio updates, best guess either visual studio periodically performing sort of self-"repair", or else windows updates overwriting these keys reason. what mechanism causing (or how go detecting myself)? more importantly, method best practice either prevent overwrites ...

caching - WordPress styling does not display without clearing cache -

i building wordpress website underscore theme, hosted on flywheel. everytime make changes page, styling style.css file not picked unless hard reload/ clear cache. obviously want load on everyone's computer without need clear cache. reason this? , how can resolve it? thanks. you must change theme version every time make change in style.css file. version appended url query string. version identifier used cache-bust url. browser detect url – query string – new , updated file rather cached resource. see wordpress theme css , js cache busting

Passing Variables References to PHP from Javascript via AJAX -

i have idea "using", or "referencing" php variables in javascript. apply webpage send email. simplified example shown below. note: called via ajax, not case trying call php variable script has been executed. the javascript include "$midsection" string in body of email sent, , send entire body php script. php script store string, create , assign value $fmidsection, , send body string in email. if works, resulting email include main body sent client side, inserted "midsection" in middle of email (perhaps, depending on person's name , info stored in database). it seems me should work, given understanding of php. however, seems me open window attack similar sql injection (where' perhaps, can trick script assign different value $midsection, example). has taken approach, , if so, can validate whether work, , open security holes? thank you. edit: application mailing list, not contact form. have admin panel allows me send emai...

Validating string format using sql server -

check if string following correct format or not. correct format follows: 2 upper case letters; 2 digits; 1 30 characters alpha-numerical (case insensitive) e.g. gb29rbos60161331926819, gb29rbos60161331926819a, gb29rbos60161331926819b1 so far have got... declare @accountnumber varchar(1000) = 'gb99aerf12fdg8aerf12fdg8aerf12fdg8' select case when @accountnumber not '[a-z][a-z][0-9][0-9][0-9a-za-z]{30}$' 'error' else null end first, structure assumes case sensitive collation. second, sql server doesn't recognize {} or $ , have repeat pattern. however, want 30 characters, splitting pieces apart best solution: select (case when len(@accountnumber) not between 5 , 34 or @accountnumber not '[a-z][a-z][0-9][0-9]%' or right(@accountnumber, 34) '%[^a-za-z0-9]%' 'error' end)

php - get full class name from short class name -

somewhere in codebase there file abc.php class named abc: <?php namespace x\y\z; class abc { // ... } in different script, variable short class name (without namespace): $classname = "abc"; i need reflection of class, code: $r = new \reflectionclass($classname); //error: class abc not exist in... is not working since full class name "x\y\z\abc" required. building object not working same reason: $obj = new $classname(); // error: class 'abc' not found in... how find full class name short 1 ? any suggestions welcome.

java - Request - Response API for Android Wear 2.0? -

how implement request-response protocol android wear 2.0 app? scenario: when tap on button on watch, want fetch data phone , display on watch's screen. what tried: i implemented working example using messageapi , don't it. send dummy "request" in 1 place using 1 method, disregard pendingresult , hope receive message corresponding response. ideally, i'd have is: byte[] responsebytes = sendrequest(somerequestbytes); i'm not sure have tried. but code should work send byte array. wearable.messageapi.sendmessage(googleapiclient, transcriptionnodeid, voice_transcription_message_path, voicedata).setresultcallback( new resultcallback() { @override public void onresult(sendmessageresult sendmessageresult) { if (!sendmessageresult.getstatus().issuccess()) { // failed send message } ...

ocr - How to extract taxes paid from the image using Python? -

Image
as cool side project trying extract total taxes paid image of tax receipt: i want parse image (and similar others) , extract tax amount. which [383.58,0.53,0.53, 383.58] can give me leads started? tried starting ocr , used free online ocr programs , none of them seem read data correctly. how approach problem? have tried online ocr far. engines best suited purpose , key things keep in mind? are there libraries in python can me started? i have tried online programs using tesseract-ocr , did not read numbers correctly. hunch tinkering parameters of engine should help, lost trying understand parameters , start. i starting these things trying find way through without understanding underlying technical details. tesseract-ocr respectable open-source ocr library. though it's written in c++, there many documentation involving wrappers using python. tutorial pytesseract pyocr

How can I convert any nested combination of maps, seqs, and basic types to JSON in Scala? -

in python can arbitrarily nest lists , dictionaries , use mixture of types , call json.dumps(x) , result need. i can't find in scala. libraries come across seem insist on static typing , compile-time checks. rather give simplicity. seems should possible dynamically check types of inputs. as simple example, able like: tojson(map("count" -> 1, "objects" -> seq(map("bool_val" -> true, "string_val" -> "hello")))) which output string containing: {"count": 1, "objects": [{"bool_val": true, "string_val": "hello"}]} edit: here happens when try couple of libraries: scala> import upickle.default._ import upickle.default._ scala> write(seq(1, 2)) res0: string = [1,2] scala> write(seq(1, "2")) <console>:15: error: couldn't derive type seq[any] write(seq(1, "2")) ...

RCP java.lang.ClassNotFoundException: org.eclipse.swt.widgets.Canvas -

i'm building eclipse rcp application , create accordion menu using nebula pshelf. when running application, error occured following message: !entry org.eclipse.ui.workbench 4 0 2017-08-14 22:42:20.903 !message unable create view id com.y.sopiana.internal.views.menu.toolsviewer: org/eclipse/swt/widgets/canvas !stack 0 java.lang.classnotfoundexception: org.eclipse.swt.widgets.canvas @ org.eclipse.osgi.framework.internal.core.bundleloader.findclassinternal(bundleloader.java:483) @ org.eclipse.osgi.framework.internal.core.bundleloader.findclass(bundleloader.java:399) @ org.eclipse.osgi.framework.internal.core.bundleloader.findclass(bundleloader.java:387) @ org.eclipse.osgi.internal.baseadaptor.defaultclassloader.loadclass(defaultclassloader.java:87) @ java.lang.classloader.loadclass(classloader.java:358) @ java.lang.classloader.defineclass1(native method) @ java.lang.classloader.defineclass(classloader.java:800) @ org.eclipse.osgi.internal.baseadapto...

javascript - Drive picker upload to a team drive as opposed to personal google drive -

right have relational datasource holds attachment name, link, date uploaded , uploaded it. when select file drive picker widget uploads file own personal drive. there way set path file uploads? i think best bet on 1 use movefile() method server scripting library provided amu: function movefile(id, email){ var file = driveapp.getfilebyid(id); var folder = driveapp.getfolderbyid('m9jygpq1gix29lwudwqmo5sza').addfile(file); driveapp.getrootfolder().removefile(file); if(email){ setfileowner(id, email); } you can folder id out of url of drive.

android - Can't load images and videos inside Webview with JavaScript enabled -

Image
i'm loading data website webview in application. and need make video plays inside webview .my problem when don't use setjavascriptasenable images , video loads fine can't play video inside webview gives me following error an error occurred. try watching video on youtube or enabe javascript. however when use setjavascriptasenable(true) images , videos inside webview disappears following image. here's code webview void setupwebview(final webview webview) { if (build.version.sdk_int >= build.version_codes.kitkat) { webview.getsettings().setlayoutalgorithm(websettings.layoutalgorithm.text_autosizing); } else { webview.getsettings().setlayoutalgorithm(websettings.layoutalgorithm.normal); } webview.setwebviewclient(new webviewclient() { @override public void onpagefinished(webview view, string url) { // add padding html page webview.loadurl("javascript:(function(){ document....

performance - Trying to optimize this algorithm/code to compute the largest subset of mutually coprime integers between a and b -

i'm writing function in haskell takes in 2 integers , b , computes length of largest subset(s) of [a,b] such elements mutually coprime. now, reason because believe investigating such values might yield means of producing trivial lesser bounds (possibly one's large enough imply actual primes in various per conjectured ranges such consecutive squares). naturally i'm trying run pretty large numbers. unfortunately below code not running fast enough practical me use. think flaw haskell's laziness policy causing issues, neither know syntax nor place need force execution prevent operations accumulating. subsets [] = [[]] subsets (x:xs) = subsets xs ++ map (x:) (subsets xs) divides b = (mod b == 0) coprime b = ((gcd b) == 1) mutually_coprime [] = true mutually_coprime (x:xs) | (coprime_list x xs) = mutually_coprime xs | otherwise = false coprime_list _ [] = true coprime_list (x:xs) | (coprime x) = coprime_list xs | othe...

bash - How do I check (in shell) whether I have a valid Kerberos ticket for a specific service? -

i able check (in bash script) whether have valid unexpired ticket specific service. can information hand if klist , bit of work programmatically parse expiration time, service principals, etc. there easier way this? thanks.

linux - Fitting multiple curves to one data set -

i have data set receive outside source, , have no real control over. can edit ad infinitum, cannot choose parameters filter set. data, when plotted, shows 2 clumps of points several sparse, irrelevant points, well. here sample plot: raw plot (sorry, don't have adequate privileges embed picture) there clump of points on left, clustered around (1, 16). clump part of set of points lies on (or near) line stretching (1, 17.5) (2.4, 13). also, there apparent curve (1.75, 18) (2.75, 12.5). finally, there sparse points above second curve, around (2.5, 17). visually, it's not difficult separate these groups of points. however, need separate these points within data file 3 groups, i'll call line, curve, , other (the curve group 1 need). i'd write program can reasonably without needing visually see plot. now, i'm going add couple items make worse. sample set of data. while shapes of curve , line relatively constant 1 data set next, positions not. these regions can ...

c++ - Could not step in cpp file when debug Openjdk8 hotspot in mac -

i compiled openjdk8 in mac. when used gdb debug simple java class(just system out), showed error no source file name init.cpp . (had added breakpoint in init.cpp: 95 line). however, step c file main.c. not sure whether had compiled openjdk8 correctly or use correct version dependencies. checked libjvm.dylib libjvm.dylib.dsym exist in ld_library_path. [when debug in eclipse cdt, has same issue] using env: mac sierra 10.12.6 gdb 7.12.1 debug command: export ld_library_path=~/openjdk/build/macosx-x86_64-normal-server-fastdebug/hotspot/bsd_amd64_compiler2/fastdebug ggdb --args ~/openjdk/build/macosx-x86_64-normal-server-fastdebug/jdk/bin/java test result1 (breakpoint in cpp file): (gdb) break init.cpp:95 no source file named init.cpp. make breakpoint pending on future shared library load? (y or [n]) y breakpoint 1 (init.cpp:95) pending. (gdb) run starting program: ~/openjdk/build/macosx-x86_64-normal-server-fastdebug/jdk/bin/java test [new thread 0x1...

r - match spatial projections of spatial objects and overlay plots -

i trying overlay 2 spatial objects using plot() function. understand projections of 2 objects (of class spatiallinesdataframe , spatialpolygonsdataframe) need same in order have them visualized in same plot. i've found similar questions here , here , none of these can me want achieve. here's coding spatialpolygonsdataframe. (v.map list of .kml files , loccoor object stores location , corresponding x , y coordinates): map.l<-list() (i in 1:length(v.map)){ ll<-ogrlistlayers(paste(loccoor,"/",v.map[i],".kml",sep="")) shp<-readogr(paste(loccoor,"/",v.map[i],".kml",sep=""),layer=ll) map<-sptransform(shp, crs("+proj=longlat +datum=wgs84")) map.l[[i]]<-map } plot(map.l[[1]],xlim=c(min(coor[,3]),max(coor[,3])), ylim=c(min(coor[,2]),max(coor[,2]))) (i in 2:length(v.map)){ plot(map.l[[i]],xlim=c(min(coor[,3]),max(coor[,3])), ylim=c(min(coor[,2]),max(coor[,2])),add=t) } proje...

java - How to add data after existing childs in firebase,using push() -

in firebase adding data using push() . whenever try add it, added @ top , not after existing pushed children. how can add new push data after existing pushed data in realtime database? here query android studio this image of firebase consle

c++ - Is there a way to prepend a fixed number of bytes before a std:: stringbuf? -

i’m trying prepend 4 byte header existing std::stringbuf object. example if data in stringbuf ‘h’,’e’,’l’,’l’,’o’ , header ‘0x00’,’0x10’, ‘0x00’,’0x0a’ need change stringbuf ‘0x00’,’0x10’, ‘0x00’,’0x0a’, ‘h’,’e’,’l’,’l’,’o’ . i’ve been trying below approach inefficent because has 3 copies of data in sbuf , textstream , buff. using new char[] more problematic because needs continuous block of memory , can have large streams. can me showing me how can in better optimized way? mean there way prepend bytes before existing stringbuf? std::stringbuf createstreamwithheader(std::stringbuf &sbuf) { int = sbuf.str().size(); std::stringbuf textstreambuf; uint32_t streamsize = sbuf.str().size(); char* buff = new char [streamsize + 5]; //using char buffer not memory efficient needs big contonuous chunk of memory. zeromemory(buff, (streamsize + 5)*sizeof(char)); buff[0] = (streamsize >> 24) & 0xff; //in case header needs contain size of data in ...

java - no images being displayed in GridView -

i new app development , have been trying create image gallery app. when click open app, nothing being displayed.i expect display images stored on sd card in gridview. have read quite few questions on related haven't been of help. can't find wrong in code.can tell me wrong code? imagegallery.java : import android.app.activity; import android.os.bundle; import android.os.environment; import android.widget.gridview; import java.io.file; import java.util.arraylist; public class imagegallery extends activity { arraylist<string> images; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_image_gallery); images = new arraylist<>();// list of file paths getfromsdcard(); gridview gridview = (gridview) findviewbyid(r.id.gridview); gridview.setadapter(new imageadapter(this, images)); } file[] listfile; public void...

list - How to either read from one file or another in bash? -

i have 2 files trying read line line, want continue reading file or other on given iteration of loop. (i unsure how check eof). here pseudocode: #initialize variables line1=read <file1.txt line2=read <file2.txt #compare lists while true #check if there match if [[ "$line1" == "$line2" ]] echo match break elif [ "$line1" -lt "$line2" ] line1=read <file1.txt # <-should read next line of f1 else line2=read <file2.txt # <-should read next line of f2 fi #check eof if [[ "$line1" == eof || "$line2" == eof ]] break fi done obviously, stands now, continue reading first line of f1 , f2. appreciated! you need open each file once , don't reset file pointer before each read. read have non-zero exit status time tries read past last line of file, can check terminate loop. { read line1 <&3 read line2...

javascript - Login Timing in AngularJs using `$q(resolve, reject)` -

i having issue login timing in angular app. intention when user logs in, api key set in localstorage , available call on accessing api. after login, want app redirect user home state. happening user redirected, gets 401 - , based off have setup - redirected login. if hard refresh on browser after logging in works. here have going. .factory('localstor', function($q, $log, $window, $rootscope) { var apikey = false; return { getapi: function() { return $q(function(resolve, reject) { var data = $window.localstorage.getitem('apikey'); if (data == null) { return $rootscope.$broadcast('notauthorized'); } else { var key = data; return resolve(key); } }); }, setapi: function(key) { return $q(function(resolve, reject) { apikey = false; if (key === undefined) { return reject(); } ...

language agnostic - Is floating point math broken? -

0.1 + 0.2 == 0.3 -> false 0.1 + 0.2 -> 0.30000000000000004 why happen? binary floating point math this. in programming languages, based on ieee 754 standard . javascript uses 64-bit floating point representation, same java's double . crux of problem numbers represented in format whole number times power of two; rational numbers (such 0.1 , 1/10 ) denominator not power of 2 cannot represented. for 0.1 in standard binary64 format, representation can written as 0.1000000000000000055511151231257827021181583404541015625 in decimal, or 0x1.999999999999ap-4 in c99 hexfloat notation . in contrast, rational number 0.1 , 1/10 , can written as 0.1 in decimal, or 0x1.99999999999999...p-4 in analogue of c99 hexfloat notation, ... represents unending sequence of 9's. the constants 0.2 , 0.3 in program approximations true values. happens closest double 0.2 larger rational number 0.2 closest double 0.3 smaller rational number 0.3 . sum ...

routerLink not render well angular 4.3.x -

i've upgraded angular 4.3.2. i have following span links, default page inbox. when click on new, add page on/above inbox page, when page loaded, inbox page disappears , add page stays there. then, when click on inbox, inbox page on/above add page, when page loaded, add page disappears , inbox page stays there. see it's working stack. how can in order avoid stack render? <span routerlink="/inbox">inbox</span> <span routerlink="/add">add</span> i've upgraded web app angular 4.3.6 , see renders on chrome , ie 11, not confirmed on firefox. seems angular bug.

javascript - Load a SPA webpage via AJAX -

Image
i'm trying fetch entire webpage using javascript plugging in url. however, website built single page application (spa) uses javascript / backbone.js dynamically load of it's contents after rendering initial response. so example, when route following address: https://connect.garmin.com/modern/activity/1915361012 and enter console (after page has loaded): var $page = $("html") console.log("%c✔: ", "color:green;", $page.find(".inline-edit-target.page-title-overflow").text().trim()); console.log("%c✔: ", "color:green;", $page.find("footer .details").text().trim()); then i'll dynamically loaded activity title statically loaded page footer: however , when try load webpage via ajax call either $.get() or .load() , delivered initial response (the same content when on view-source): view-source:https://connect.garmin.com/modern/activity/1915361012 so if use either of the following ajax ca...

Supressing Dialog Box Using VBScript -

i have automated testing program, uses soapui, executed using vbscript. however, whenever execute testing program soapui dialog box opens asking "do want improve soapui sending usage statistics." manually click "no," , testing program keeps running along. is there way suppress dialog box never appears when run automated testing program. vbscript code below. option explicit dim rootfolder, execfolder, command, fso, shell set fso = createobject("scripting.filesystemobject") set shell = createobject("wscript.shell") rootfolder = fso.getparentfoldername(fso.getparentfoldername(wscript.scriptfullname)) execfolder = fso.getparentfoldername(wscript.scriptfullname) on error resume next 'clean previous log files call fso.deletefile(execfolder & "\*.txt", true) call fso.deletefile(rootfolder & "\test\*.txt", true) call fso.deletefile(execfolder & "\*.log", true) 'execute command = chr(34) ...

condition - register is not a legal parameter of an Ansible Play -

i trying run simple ansible playbook keep getting following error , i'm not sure why. error: register not legal parameter of ansible play below code trying execute --- - name: selinux sestatus command: sestatus | grep enforcing | grep 'config file' register: sestatus - name: check if module1.pp exists stat: path: bin/module1.pp register: module1_pp - name: disable selinux if enforcing sudo: yes command: "{{ item }}" with_items: - setenforce 0 - semodule -i bin/module1.pp - setsebool -p httpd_can_network_connect 1 when: sestatus.rc == 0 , module1.stat.exists == true that's entire playbook? you're missing hosts , tasks declaration. - hosts: some_hosts tasks: - name: selinux sestatus command: sestatus | grep enforcing | grep 'config file' register: sestatus - name: check if module1.pp exists stat: path: bin/module1.pp register: module1_pp - name: disable ...

contenteditable - JavaScript - Split Parent of Selection -

using javascript (and potentially rangy ) trying create utility function allow me "split" element based on selection , selector pass in. instance, let's had following: <div class="designer" contenteditable="true"> <div class="content"> <p> here <span style="color: pink;">some cool</span> stuff. <p> </div> </div> now let's user had cursor between "some" , "cool". want able call function this: $splitparent('p'): which yield following: <div class="designer" contenteditable="true"> <div class="content"> <p> here <span style="color: pink;">some</span> <p> <p> <span style="color: pink;"> cool</span> stuff. <p> </div> </div> an...

javascript - Angular 4 Bootstrap dropdown require Popper.js -

i have fresh created angular 4 cli app. after running this: npm install bootstrap@4.0.0-beta jquery popper.js --save and editing .angular-cli.json this: "styles": [ "styles.css", "../node_modules/bootstrap/dist/css/bootstrap.min.css" ], "scripts": [ "../node_modules/jquery/dist/jquery.slim.min.js", "../node_modules/bootstrap/dist/js/bootstrap.min.js", "../node_modules/popper.js/dist/umd/popper.min.js" ], i still have issue in chrome console: uncaught error: bootstrap dropdown require popper.js (https://popper.js.org) @ eval (eval @ webpackjsonp.../../../../script-loader/addscript.js.module.exports (addscript.js:9), <anonymous>:6:17548) @ eval (eval @ webpackjsonp.../../../../script-loader/addscript.js.module.exports (addscript.js:9), <anonymous>:6:23163) @ eval (eval @ webpackjsonp.../../../../script-loader/addscript.js.module.exports (addscript.js:9), <anonymous>...

Git methodology for text files -

i have project builds large data base several text files (csv/json). in first few days when had 10~ files added them git, got 100~ (total size 70mb) , number grow. what best methodology handle large text files in project? a possible solution make zip of every file (the size reduce 225kb 1.2mb per file) , support in code (extract , use it) think there better ways handle situation.

binary - How to transform data into suitable table for calculating single linkage clustering in R -

i'm trying transform data data table binary code (for clustering later on). data i've got looks this: order_number product_id 34 37552 5 24852 10 24852 15 33290 7 23586 35 22395 4 16766 33 46393 9 12916 61 12341 what want column order_number row header , paste 0 or 1 depending on whether product product_id in order_number cell or not. order_number should basket. i'd similar this: order_number product_id 34 5 37552 1 0 24852 0 1 24852 0 1 does know how it? highly appreciated, i'm stuck. how simple table ? > table(df$product_id, df$order_number, dnn=c("product id","order number")) ## order number ##...

html - Google Analytics JavaScript onClick issues with 'if' statement for hostname -

so basic function works sending pageview, have onclick events setup in html not working within same function in javascript if hostname = 'mydomain.com' . javascript (works fine): (function(w,d){ var hostname = w.location && w.location.hostname; if(hostname == 'mydomain.com'){ ga("create","ua-104xxxxxx-1",{name:"new"});ga("new.send","pageview"); }})(window,document); if add function within function, onclick event not work pageview still does. there multiple domains , there more javascript file rest pertains different domains other countries, etc. javascript (doesn't work fine): (function(w,d){ var hostname = w.location && w.location.hostname; if(hostname == 'mydomain.com'){ ga("create","ua-104xxxxxx-1",{name:"new"});ga("new.send","pageview"); function myfunc() { ga('send', 'event',...

How to query azure SQL from node.js server -

i'm having trouble querying db on azure sql (i new sql). i'm following steps on https://docs.microsoft.com/en-us/azure/sql-database/sql-database-connect-query-nodejs , includes tutorial steps on how read tables, not manipulate them. trying insert , delete requests on node.js server, getting request error in 1 of node modules, makes me think i'm going requesting operations wrong. here's code: var connection = require('tedious').connection; var request = require('tedious').request; // create connection database var config = { username: 'user_name', password: 'password', server: 'server_name', options: { database: '_dbname' , encrypt: true } } var connection = new connection(config); // attempt connect , execute queries if connection goes through connection.on('connect', function (err) { if (err) { console.log(err) } else { querydatabase(); } } //this works fi...

c - Change non-modifiability of an array by using a structure -

from kerrek sb's comment on why can't modifiable lvalue have array type? you can trivially assign arrays making them members of struct , assigning lvalues. what mean? mean if structure has array member, array member can modifiable? following example doesn't work: i define struct type member being array typedef struct { int arr[3];} mytype; then mytype mystruct; mystruct.arr = (int[]) {3,2,1}; and got error: assignment expression array type . no, means if assign instance of struct 1 in example struct assigning arrays. struct array { int array[3]; }; struct array a; struct array b = {{0, 1, 2}}; // chris dodd // valid! = b;

cryptography - How to determine the encryption scheme of a zip file -

i looking @ encrypted zip files (using pkzip format) , don't understand how encryption scheme encoded in binary format. in research, found this paper outlining various encryption schemes used in pkzip formatted files. found encrypted files i've been looking @ match magic number format 50 4b 03 04 outlined in article. according paper, encryption scheme type used can determined 2-bytes after file name in file (17 00 "strong encryption" , 01 99 "winzip aes encryption". not state such signature "traditional pkware encryption". i created encrypted zip file using keka examine contents , see kind of encryption used. neither of magic numbers mentioned in article appeared after file name, instead found bytes 54 73. in fact, upon adding more bytes plaintext file encrypted, noticed after encrypting, these bytes changed little bit, suggesting not in fact indicator of encryption scheme used. i've looked @ output of zipdetails try , see if there more...

javascript - How to convert this string into separate string objects -

new google tag manager , not sure how this. on thankyou page, let's there is: var purchased = "product1;product2;product3" how separate each string in 'purchased' have (product), tag manager can understand there 3 unique strings: var product = {"product1"}, {"product2"}, {"product3"} or var product = {"product1", "product2", "product3"} i tried these wasn't needed: var products = purchased.split(';'); var products = purchased.split(';').map(e => e); // both of these return ["product1, product2, product3"] how splitting ;(space) ? code leaves space. var products = purchased.split(';');

python - Wrong number of dimensions. Keras -

i'm having troubles grasping shape input first layer of network. architecture: # model hyperparameters filter_sizes = [1, 2, 3, 4, 5] num_filters = 10 dropout_prob = [0.5, 0.8] hidden_dims = 50 model_input = input(shape=(x.shape[0], x.shape[1])) z = model_input z = dropout(0.5)(z) # convolutional block conv_blocks = [] fz in filter_sizes: conv = convolution1d(filters=num_filters, kernel_size=fz, padding="valid", activation="relu", strides=1)(z) conv = maxpooling1d(pool_size=2)(conv) conv = flatten()(conv) conv_blocks.append(conv) z = concatenate()(conv_blocks) if len(conv_blocks) > 1 else conv_blocks[0] z = dropout(dropout_prob[1])(z) z = dense(hidden_dims, activation="relu")(z) model_output = dense(3, activation="softmax")(z...

node.js - Passing command args to docker api -

i'm attempting find equivalent of docker run -it networkstatic/nflow-generator -t localhost -p 9995 when using docker api (i'm using dockerode, answer http api good). tried no luck: docker.createcontainer({ image: 'networkstatic/nflow-generator', args: [ '-t', 'streamsets-dc', '-p', '9995' ] }); how pass arguments without command? since networkstatic/nflow-generator dockerfile defines entrypoint /go/bin/nflow-generator , should able pass these arguments running container command s this: docker.createcontainer({ image: 'networkstatic/nflow-generator', cmd: [ '-t', 'streamsets-dc', '-p', '9995' ] });

c# - Milight - Limitlessled Admin App not controlling Lights -

i want write app control limitlessled lights (milight) , i'm facing issue. for information, i'm using visualstudio 2017 / c#. so far, able sessionstart wifi bridge session id1 id2 using code below : ipendpoint ep = new ipendpoint(ipaddress.parse("192.168.1.13"), 5987); var client = new udpclient(); //connect limitlessled wifi bridge receiver client.connect(ep1); byte[] limitlessled = new byte[] { 0x20, 0x00, 0x00, 0x00, 0x16, 0x02, 0x62, 0x3a, 0xd5, 0xed, 0xa3, 0x01, 0xae, 0x08, 0x2d, 0x46, 0x61, 0x41, 0xa7, 0xf6, 0xdc, 0xaf, 0xd3, 0xe6, 0x00, 0x00, 0x1e }; client.send(limitlessled, limitlessled.length); var receiveddata = client1.receive(ref ep); unforutnatly, if try send command turn light on, suceess responce nothing happen. i facing same issue limitlessled admin app(v6): got success noting happen, below log soft. start wifi bridge session... send udp commands 192.168.1.13 port 5987 s...

algorithm - Implement a queue in which push_rear(), pop_front() and get_min() are all constant time operations -

i came across question: implement queue in push_rear(), pop_front() , get_min() constant time operations. i thought of using min-heap data structure has o(1) complexity get_min(). push_rear() , pop_front() o(log(n)). does know best way implement such queue has o(1) push(), pop() , min()? i googled this, , wanted point out algorithm geeks thread . seems none of solutions follow constant time rule 3 methods: push(), pop() , min(). thanks suggestions. you can implement stack o(1) pop(), push() , get_min(): store current minimum each element. so, example, stack [4,2,5,1] (1 on top) becomes [(4,4), (2,2), (5,2), (1,1)] . then can use 2 stacks implement queue . push 1 stack, pop one; if second stack empty during pop, move elements first stack second one. e.g pop request, moving elements first stack [(4,4), (2,2), (5,2), (1,1)] , second stack [(1,1), (5,1), (2,1), (4,1)] . , return top element second stack. to find minimum element of queue, @ smallest 2 elements o...

Identical HTML code read differently using python -

excuse amateurish code, i'm sure it's painful @ experience. i'm trying write code able save data on following link: http://pq.gov.mt/pqweb.nsf/bysitting?openview , , save them in searchable csv file. the code have written seems work fine, in manages save information need in different columns of csv file. breaks down when reaches 1 question, 412 on page: http://pq.gov.mt/pqweb.nsf/bysitting!openview&start=1&count=20&expand=9#9 , fails register last entry reason (marked arrow <<<<<-----). as far can tell, html page identical rest, seem work fine can't understand how or why different. not sure how i've explained problem happy elaborate if necessary. thanks in advance. code below item in html_search_1: x = item.find_all('a',href = true) t in x: store = [] y = t.get('href') new_url = ("http://pq.gov.mt"+y) page_2 = urllib.request.urlopen(new_url).read() ...

Does Xamarin offer a native number picker that I can use with Xamarin.Forms? -

i have used standard picker comes box on screen , allows me select list. but there native xamarin picker can used pick numbers , populate binder number? see on applications telephone keypad type thing displays numbers 1,2,3,4,5,6,7,8,9,0 , backspace. seems common kind of control when user wants enter number or dollar amount. i in sample apps not find example of this. if there not 1 way implement series of numbers in list ? the kind of control interested in 1 when click on input field opens box on bottom of screen number pad use entry keyboard property set numeric <entry keyboard="numeric" />

How to have vim highlight color change for the pattern under cursor? -

Image
is there way have search highlight text in vim under cursor have different color compared search text not under cursor? my .vimrc has codes: function! hiinterestingword(n) " {{{2 " save our location. normal! mz " yank current word z register. normal! "zyiw " calculate arbitrary match id. nothing else using it. let mid = 77750 + a:n " clear existing matches, don't worry if don't exist. "silent! call matchdelete(mid) try call matchdelete(mid) catch 'e803' " construct literal pattern has match @ boundaries. let pat = '\v\<' . escape(@z, '\') . '\>' " match words. call matchadd("interestingword" . a:n, pat, 1, mid) endtry " move our original location. normal! `z endfunction "clear highlighting function! clearallhi() in range(1,6) let mid = 77750 + sile...

excel vba - Move cursor to non-adjacent cell after pasting -

my spreadsheet has several non-adjacent blocks of cells filled in: a3:d4, f3:i7, k3:n7, a9:d10, f9:i13, k9:n13, etc. paste data copied internet each block, 1 after other. once paste 1 block, cursor automatically shift start of next block ready next paste, i.e. f3 when a3:d4 pasted, k3 when f3:i7 pasted, a9 when k3:n7 pasted, etc. i found , tried macro practice before trying adapt it, not work because not listed in alt-f8 menu. seems close need, in appears "once a1 has value, move cursor c15; once c15 has value, go f9; once f9 has value, go a1". private sub worksheet_change(byval target excel.range) select case target.address() case "$a$1" range("$c$15").select case "$c$15" range("$f$9").select case "$f$9" range("$a$1").select end select end sub a "brute force" approach might be: private sub worksheet_change(byval target excel.range) if not intersect(target, range("a...