Posts

Showing posts from April, 2013

R - Filtering datetimes that are less than a set of datetimes -

i have 2 dataframes. one data have several variable columns , several datetime related columns (datetimes, week #, dates, hour, minute, second), has data everyday in 2017. example, > glimpse(data) observations: 8,001,013 variables: 12 $ id <chr> "(2, 3, 4)", "(5,)", "(6,)", "(7,)", "(8,)", "(9,)", "(10,)", "(11,)", "(12,)", "(13,)", "(14,)", "(15,)", "(16,)", "(17,)", "(18,)", "(19,)", "(20,)", "(21,... $ x <int> 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1... $ num <chr> "set([4225])", "set([4712])", "set([5271])", "set([5334])", "set([5395])", "set([5658])", "...

ssl - how to prevent Nginx to redirect location to a configured proxy_pass url and port number -

hi guys having problem nginx, have configure phpmyadmin run nginx phpmyadmin configured run on port 8080 . access phpmyadmin via localhost/phpmyadmin , give me proper login screen below. phpmyadmin login screen after login url on address bar changes configure port localhost/phpmyadmin localhost:8080/phpmyadmin , throws error message here nginx configuration: server{ listen 443 ssl; ssl_dhparam /etc/ssl/certs/dhparam.pem; ssl_certificate /etc/certificate/live/localhost/permission.pem; ssl_certificate_key /etc/certificate/live/localhost/privkey.pem; include /etc/certificate/live/localhost/ssl-nginx.conf; access_log /var/log/nginx/apache2-access.log; error_log /var/log/nginx/apache2-error.log; location /phpmyadmin{ proxy_set_header x-forwarded-host $host; proxy_set_header x-forwarded-server $host; proxy_set_header host $http_host; proxy_set_header x-ssl on; proxy_set_header x-nginx-proxy true; ...

Speeding up SQL Server cross apply to get aggregated data -

Image
in sql server, trying put single query grabs row , includes aggregated data 2 hour window before row aggregated data 1 hour window after. how can make run faster? the rows have time stamps millisecond precision, , not evenly spaced. have on 50 million rows in table, , query not seem completing. there indexes in many places, don't seem help. thinking using window function, not sure possible have sliding window unevenly distributed rows. also, future 1 hour window, not sure how done sql window. box string , has 10 unique values. process string , has 30 unique values. average duration_ms 200 ms. errors account less 0.1% of data. 50 million rows describes years worth of data. select c1.start_time, c1.end_time, c1.box, c1.process, datediff(ms,c1.start_time,c1.end_time) duration_ms, datepart(dw,c1.start_time) day_of_week, datepart(hour,c1.start_time) hour_of_day, c3.*, c5.* metrics_table c1 cross apply (select avg(cast(datediff(ms,c2.start_time,c2.end_time) numeric)) avg...

c# - Editing Excel templates with Open XML SAX -

i'm working on .net c# application queries data database , writes excel template files. tamplate can whatever excel file user uploads system, need place data starting on given row , column. i using closedxml, turns out doesn't support gradient filling yet, client complained of report being generated without original formatting. then changed pure openxml, i'm facing out of memory problems large queries. i searched around , found out write large amounts of data excel using sax approach. problem need maintain whatever else in template spreadsheet, whether data, formatting, image, anything. need able place data in there, add rows or merge data original rows. i still haven't grasped how sax , haven't find many exemples work with, couple of topics: using template openxml , sax is there sax way loop through openxml rows? http://polymathprogrammer.com/2012/08/06/how-to-properly-use-openxmlwriter-to-write-large-excel-files/ , none of them quite deal exact situ...

Python converting strings to dictionary -

i have task. convert .po msgid , msgstr dictionary. parsed , got something, this cancel anuluj close zamknij continue kontynuuj now need dictionary. example, first line mean english, second translations. part of code mess = {} mess[string.replace(string.replace(native_language, '\\"', '"'), '\\n', '\n')] = string.replace(string.replace(translation_language, '\\"', '"'), '\\n', '\n') everything ok. problem in last couple of strings. example. have not written couple of continue kontynuuj . think have problem in \n . ? can me ? full text of script: source = '/var/www/pl.po' target = '/var/www/mess.json' file = open(source, 'rb') = 0 isignore = false issrc = false lang = '' native_language = '' translation_language = '' mess = {} str in file: += 1 if < 15: str = str.strip() if str[0:10] == '"language:...

node.js - Can't run "npm install" without deleting node_modules after upgrading to NPM 5.4.1 -

i've upgraded npm 5.3.0 5.4.1 , after that, seems command npm install works if i've removed node_modules . when try rerun installation, i'm getting following error message. (after that, if again remove node_modules , command run install works - once .) ps c:\source\website> npm install npm err! path c:\source\website\node_modules\fsevents\node_modules\aproba\package.jsonvet.web npm err! code eperm npm err! errno -4048 npm err! syscall unlink npm err! error: eperm: operation not permitted, unlink 'c:\source\website\node_modules\fsevents\node_modules\aproba\package.json' npm err! { error: eperm: operation not permitted, unlink 'c:\source\website\node_modules\fsevents\node_modules\aproba\package.json' npm err! stack: 'error: eperm: operation not permitted, unlink \'c:\source\website\node_modules\fsevents\node_modules\aproba\package.json\'', npm err! errno: -4048, npm err! code: 'eperm...

android - Gradle: Resolve dependencies ':app:_debugApk' -

i have problem in android studio. of sudden, stucks @ starting app building. tried changing repos , nothing changes. if create new project have no errors. this error message: gradle: resolve dependencies ':app:_debugapk'. loading bar moving endlessly. this entire project build.gradle: buildscript { repositories { jcenter() } dependencies { classpath 'com.android.tools.build:gradle:2.3.3' classpath 'com.google.gms:google-services:3.0.0' } } allprojects { repositories { mavencentral() } } task clean(type: delete) { delete rootproject.builddir } here app build.gradle: apply plugin: 'com.android.application' android { compilesdkversion 25 buildtoolsversion '25.0.3' defaultconfig { applicationid "app id" minsdkversion 17 targetsdkversion 25 versioncode 1 versionname "1.0" testinstrumentationru...

multithreading - SparkSession.getOrCreate() failing to return previously configured session, job fails -

we running spark 2.1.0 in scala in cluster. invoke jobs through rest api, here sample java command line generated client , invoked: "/usr/lib/jvm/jre-1.7.0/bin/java" "-cp" "/opt/spark/spark-2.1.0-bin-hadoop2.7/conf/:/opt/spark/spark-2.1.0-bin-hadoop2.7/jars/*" "-xmx3072m" "-dspark.jobnumber=162740893" "-dspark.submit.deploymode=cluster" "-dspark.master=spark://clusterhost.foobar.com:7077" "-dspark.executor.memory=12g" "-djobnumber=162740893" "-dspark.driver.memory=3g" "-dspark.app.name=foobar-loader-162740893" "-dspark.eventlog.dir=/opt/spark/events" "-dspark.jars=/opt/spark/foobar-1.0.jar" "-dspark.eventlog.enabled=false" "-xx:maxpermsize=256m" "org.apache.spark.deploy.worker.driverwrapper" "spark://worker@10.10.10.241:44745" "/opt/spark/foobar-1.0.jar" "com.foobar.loader" "aaa,bob,ccc...

java - Evaluation and advice for improvement of the REST controller -

i wrote rest controller message management https://pastebin.com/xuhgnlvw .i ask opinion on names of addresses, number of objects , whole controller. think such rest controller ok or should improved? @getmapping(value = "/sent/{id}") @getmapping(value = "/received/{id}") @deletemapping(value = "/sent") @deletemapping(value = "/received") @getmapping(value = "/sent/search") @getmapping(value = "/received/search") @getmapping(value = "/sent/list") @getmapping(value = "/received/list") is such division of addresses ok?

performance - How to structure JavaScript loading and deps? -

i have lots of javascript on site, including jquery, jquery ui (autocomplete), ads, social widgets, internal scripts, metrics (like ga) , on. structure how resources being loaded (from top priority lowest): jquery & jquery ui enable auto-complete; internal scripts; ads; metrics; social widgets. currently moved scripts bottom , loading them async (except jquery isn't handling onload if async-loaded). load js stuff after content, loaded in specific order. what industry-grade solution task? load javascript.js ou wanted : function include(src){ var scriptelem = document.createelement('script'); scriptelem.setattribute('src',src); scriptelem.setattribute('type','text/javascript'); document.getelementsbytagname('head')[0].appendchild(scriptelem); }; // import random query parameter avoid caching function includenocaches(src){ var ms = new date().gettime().tostring(); var timer= "?" + ms; i...

Javascript for json object nothing shows in the html page? -

i'm following js tutorial, , i've faced problem: list not showing in browser. i checked script part, it's okay. didn't find error in code. the output on page's browser should somthing list: *facebook:... *instagram:... script: var info= { "full_name": "tim berner ", "tile": "staff author", "links": [ {"facebook": "https://web.facebook.com/"}, {"instagram": "https://www.instagram.com/"} ] }; var output = ''; (var = 0; <= info.length; i++){ (key in info.links[i]){ if (info.links[i].hasownproperty(key)){ output += '<li>' + '<a href= "' + info.links[i] [key] + ' ">' + key + '</a> ' + '</li>' ; } //hasownproperty } //for each object } //for each array element var update = document.getelementbyid('links'); update.inn...

r - Copying Attribute Data Attached To Column As Another Column -

i have data set each column having attribute storing data. meaning, columns has row wise values , attributes columns have value. i can read data attached column attribute using attr() . however, goal capture these attribute values , replicate columns. reading attribute > attr(data$`column1`, "metadata")$dp.somenumber1 "6200" > attr(data$`column2`, "metadata")$dp.somenumber2 "7200" input data column1 column2 -0.01 0.05 -0.01 0.05 -0.01 0.05 -0.01 0.05 -0.01 0.05 -0.01 0.05 -0.01 0.05 -0.01 0.05 then using above code, want append values shown below. output data column1 somenumber1 column2 somenumber2 -0.01 6200 0.05 7200 -0.01 6200 0.05 7200 -0.01 6200 0.05 7200 -0.01 6200 0.05 7200 -0.01 6200 0.05 7200 -0.01 6200 0.05 7200 -0.01 6200 0.05 7200 -0.01 6200 0.05 7200 how can implem...

machine learning - Visualizing an RNN/LSTM -

i new recurrent neural network , lstms. have idea of work , training procedure. having hard time visualizing them, after reading tensorflow docs , understanding related terminologies. while building lstms, hidden layer units lstm cell? mean if have 100 units in hidden layer, mean there 100 lstm cells? while building lstms, hidden layer units lstm cell? no. i mean if have 100 units in hidden layer, mean there 100 lstm cells? no. i don't know more. recommend reading understanding lstm networks . i this code has 1 lstm layer 128 units. 1 lstm unit consists of multiple nodes.

javascript - Live search results from dxTagBox? -

i'm trying connect dxtagbox search function , can't figure out how 2 working together. it seems tag box looking predefined set of results on load want generate results based on user types in: search function: var searchusers = function (query) { return $pnp.sp .search({ querytext: "*", sourceid: "b09a7990-05ea-4af9-81ef-edfab16c4e31", startrow: 0, rowlimit: 500, rowsperpage: 50, selectproperties: ["preferredname", "workemail", "pictureurl", "accountname", "jobtitle", "id"] }) .then((r) => { var results = _.filter(r.primarysearchresults, user => _.includes(user.accountname, "membership")); // console.log(results) var users = results.reduce((prev, u) => { prev.push({ name: u.preferredname, ...

MySQL: Return all tables from 'select tables_names ...' -

i using: select table_name tables information_schema.tables table_name 'address_%' ... list of table in database. advised use method, rather 'show tables', see: mysql: show tables - define column name ... can name column (the clause, above, not available show tables). as expected, gives me following output: tables address_13e625c01bea04b1d311 address_147e32243c710542fb43 address_3b046272656fa61d7550 address_4f83b2740fc4f038775a etc. if try , change select statement tables (not starting 'address_') of following: select table_name tables information_schema.tables table_name '%' select table_name tables information_schema.tables table_name '' select table_name tables information_schema.tables these return: tables character_sets client_statistics collations collation_character_set_applicability columns column_privileges etc. i don't know these values (database attributes looks of it), not list of tables in database...

asp.net - Error in Visual Studio Team Services CI after upgrading .NET Core from 1.X to 2.0 (NU1105) -

after upgrading asp.net core app .net core 1.x 2.0, visual studio team services ci failing on restore/build/test. the error error nu1105: unable find project information '[project path]/portal.csproj'. project file may invalid or missing targets required restore. the error occurs after vsts tries building test project e.g. portal.tests.csproj references portal.csproj in portal.csproj, need delete or comment out following line: <dotnetclitoolreference include="bundlerminifier.core" version="x.x.xxx" /> it seems causing issues vsts.

html - Individual Google Sheet Cell Value to JavaScript -

i'm trying pull data individual cells in google sheet webpage. far have this: function loadprice() { var url="mygooglesheetslink"; xmlhttp=new xmlhttprequest(); xmlhttp.onreadystatechange = function() { if(xmlhttp.readystate == 4 && xmlhttp.status==200){ document.getelementbyid("price").innerhtml = xmlhttp.responsetext; } }; xmlhttp.open("get",url,true); xmlhttp.send(null); } <body onload="loadprice()"> <div id="price"></div> </body> it pulls sheet page, , i'm trying figure out how can individually place cell values sheet in particular places on page. thanks in advance! this updates select options spreadsheet. google app script: function getselectoptions() { sortoptions(); var ss=spreadsheetapp.getactive(); var sh=ss.getsheetbyname('options'); var rg=sh.getdatarange(); var va=rg.getvalu...

Angular 2+ reactive form validation - either this or that -

i have 3 field form - first name, last name, id number - want set user must either enter data 2 name fields or enter id number form valid , "submittable". my code ngoninit() { this.person = this.fb.group({ 'fname': [], 'lname': [], 'certid': [] },{ validator:(formgroup:formgroup)=>{ return this.validateinput(formgroup); } } ); } validateinput(formgroup:formgroup){ if(formgroup.controls["fname"].value && formgroup.controls["lname"].value || formgroup.controls["certid"].value){ console.log('ok'); return {validateinputdata:true}; } else { console.log('not ok'); return null; } } while validation runs when form/page loaded , generates 'fail'('not ok'), submit button nevertheless active: <button type="submit" class="btn btn-success" [di...

javascript - How to remove ESlint error no-unresolved from importing 'react' -

Image
no-unresolved https://github.com/benmosher/eslint-plugin-import/blob/master/docs/rules/no-unresolved.md after installing eslint-import-resolver-webpack my .eslintrc config { "extends": "airbnb", "rules": { "comma-dangle": ["error", "never"], "semi": ["error", "always"], "react/jsx-filename-extension": 0, "react/prop-types": 0, "react/no-find-dom-node": 0, "jsx-a11y/label-has-for": 0 }, "globals": { "document": true, "window": true }, "env": { "jest": true }, "settings": { "import/resolver": "webpack" } } my package.json { "name": "coinhover", "version": "0.0.1", "main": "index.js", "author": "leon gaban", "lic...

swift3 - TableView crashes under uncaught exception 'NSUnknownKeyException', this class is not key value coding-compliant for the key x.' -

i can't seem make tableview custom cells work. runtime error terminating app due uncaught exception 'nsunknownkeyexception', reason: '[ setvalue:forundefinedkey:]: class not key value coding-compliant key causecampaigndescription.' the weird thing that property not called anymore. cell file mainviewcontrollertableviewcell // // mainviewcontrollertableviewcell.swift // // // created on 9/13/17. // copyright © 201. rights reserved. // import uikit class mainviewcontrollertableviewcell: uitableviewcell { @iboutlet weak var causecampaignimageview: uiimageview! @iboutlet weak var causedescription: uilabel! @iboutlet weak var daystofinishlabel: uilabel! @iboutlet weak var raisedovertotallabel: uilabel! @iboutlet weak var percentagecompletedlabel: uilabel! @iboutlet weak var goalprogresview: uiprogressview! //card used on @ibinspectable var cornerradius : cgfloat = 2 @ibinspectable var shadowoffsetw...

Designing multi tenant app in rails -

i'm implementing multi tenant app rails. approach not use postgres inbuilt multi tenant feature , add column record subdomain. question :) let's example class organisation < activerecord::base has_many :users end class user < activerecord::base belongs_to :organisation end i'm thinking 2 approaches here, approach 1 add subdomain column organisations pros - way how relational databases should work \0/ cons - when have more complex queries , make code slow approach 2 add subdomain column both organisations , users pros - make queries faster cons - i'm going against relational databases so question is, sort of method should follow between above two, or there different approach didnt think about thanks in advance we run multi-tenant rails app fewer 500 table-backed classes, , if had guess i'd around 400 of them relate client data. client-specific attributes held in client model, add client_id every client table...

python - Get text of next sibling based on text of previous sibling -

i have following html: <div id="infotable"> <h4> user </h4> <table> <tbody> <tr> <td class="name"> <a href="/userpage/123">billybob12345</a> </td> </tr> <tr> <td class="name"> <a href="/userpage/124">jimbob43</a> </td> </tr> </tbody> </table> <h4> super user </h4> <table> <tbody> <tr> <td class="name"> <a href="/userpage/112">cookiemonster</a> </td> </tr> </tbody> </table> </div> basically, looking 2 lists: users = [{...

linux - Crontab Centos Run Perl every 2 Minutes -

i have server rhel 7 must run script "perl" in every 2 minutes , hour , day , week . so made theses steps , nano /etc/crontab and inserted command below . 2**** projop /web/projop/packages/intranet-helpdesk/perl/./import-pop3.perl but not running . full crontab : shell=/bin/bash path=/sbin:/bin:/usr/sbin:/usr/bin mailto=root # details see man 4 crontabs # example of job definition: # .---------------- minute (0 - 59) # | .------------- hour (0 - 23) # | | .---------- day of month (1 - 31) # | | | .------- month (1 - 12) or jan,feb,mar,apr ... # | | | | .---- day of week (0 - 6) (sunday=0 or 7) or sun,mon,tue,wed,thu,$ # | | | | | # * * * * * user-name command executed #29 3 * * * /root/bin/export-dbs > /var/log/postgres/export-dbs.log 2>&1 #24 3 * * * /usr/bin/find /export/backup -name '*.tgz' -mtime +6 | xargs rm #25 3 * * * /usr/bin/find /export/backup -name '*.bz2' -mtime +6 | xargs rm 2**** projop /web/pro...

How can I force a Integer-to-String export to Excel using php/mysql? -

i need export data mysql table excel. i'm using code below, working fine. the problem is: there 2 fields integers more 30 digits. when export .csv file, excel transforms them scientific notation. example: field "95145612345641859415634194164163" transforms "9.51456e+31" how can force read string? <?php exportmysqltocsv('export_csv.csv'); function exportmysqltocsv($filename = 'export_csv.csv') { $conn = dbconnection(); if ($conn->connect_error) { die("connection failed: " . $conn->connect_error); } $sql_query = "select * cadastros"; $result = $conn->query($sql_query); $f = fopen('php://temp', 'wt'); $first = true; while ($row = $result->fetch_assoc()) { if ($first) { fputcsv($f, array_keys($row)); $first = false; } fputcsv($f, $row); } // end while $conn->close(); $size = f...

javascript - How can I merge a module in an instance? -

i'm trying find way merge or add methods , attributes of module in class. function user(data){ this.name = data.name; } user.prototype.sayhello = function(){ return this.name+' says hello.'; } module.exports = user; i add user attributes , methods player class once has joined game exemple. function player(user){ this.chances = 3; } player.prototype.run = function(){ return this.name+' running.'; } i tried subclass loose parameters user , have player's one. : var user = new user({name:jacques}); user.sayhello() // jacques says hello. user.becomeplayer(); user.run(); // jacques running. or possible add attributes , methods user variable ? user.becomeplayer() // user can run. if want add method on object user,you can sth this: user.prototype = { sayhello : function(){ return this.name+' says hello.'; }, becomeplayer: function () { //do thing } } if user want access player's me...

process - Opening AD from vb.net with different credentials -

i have found following code dim p new processstartinfo { .filename = "c:\windows\system32\dsa.msc", .arguments = "/savecred /user:domain\username" } ' start process process.start(p) i want able pass following cmd prompts username c:\windows\system32\runas.exe /savecred /user:domain\username "c:\windows\system32\mmc.exe c:\windows\system32\dsa.msc" which works opening app not pass username or prompt password, cant figure out how forse different cred along arguments. ideas ?? ok figured out - here code used function converttosecurestring(byval str string) dim password new securestring each c char in str.tochararray password.appendchar(c) next return password end function private sub button2_click(sender object, e eventargs) handles button2.click dim passwordstring string passwordstring = "..........." dim password securestring = converttosecurestrin...

express - ejs, how to add dynamic attributes of html tag? -

i use express.js + ejs , have 2 cases: 1. <a href="<%= prevdisabledclass ? '' : ?page=<%=+page - 1%>%>">prev</a> but give me error: could not find matching close tag "<%="./nundefined/nerror: not find matching close tag "<%=". i want prevdisabledclass ? <a href=''>prev</a> : <a href='?page=<%=+page - 1%>'>prev</a> 2. like above, dynamic add href attribute html tag <a> i want this: prevdisabledclass ? <a>prev</a> : <a href='?page=<%=+page - 1%>'>prev</a> how can solve these 2 problem? for first 1 have this: <a href="<%= prevdisabledclass ? '' : ?page=<%=+page - 1%>%>">prev</a> you can't nest <%= , try instead: <a href="<%= prevdisabledclass ? '' : ('?page=' + (page - 1)) %>">prev</a> for second 1 i...

vba - Looping through seriescollection and format series fill color -

i'm trying work on code in powerpoint(ppt) loop through column charts in ppt , format each column bars in series collection specific colors. works when number of bars = number of lines wrote series fill color. eg. when have 15th line ".seriescollection(15).format.fill.forecolor.rgb = rgb(250, 10, 10)" charts have 10 columns, have error. when there 15 columns works. but chances number of column random on ppt , ask if there's way =1 seriescollection.count if i=1, choose ".seriescollection(1) color, i=2, choose ".seriescollection(1) color , on... my code below, great appreciate if point me how should modify codes , make works thanks for each slide in activepresentation.slides each shape in slide.shapes if shape.haschart = true if shape.chart.charttype = xlcolumnstacked sh.chart each ser in .seriescollection .seriescollection(1).format.fill.forecolor.rgb = rgb(10, 10, 10) .seriescollection(2).format.fill.forecolor.rgb = rgb(30, ...

java - How to use log4j to log different package's message into same log file? -

i beginner using log4j, please don't mind stupid questions. now have jar contain methods use in different classes. let calculator method. method has several messages , exception handling need log. i have 2 classes need use method calculation , these 2 classes have own log file. classa.log , classb.log the question how log message , error came calculator in classa.log , classb.log depends on class calling calculator. i want classa.log , classb.log like: [datetime] info - [foo.a] class [datetime] info - [foo.a] calling calculator [datetime] info - [cal.mycal.calculator] enter calculator , start calculating [datetime] warn - [cal.mycal.calculator] warning message calculator [datetime] error - [cal.mycal.calculator] error message calculator [datetime] info - [foo.a] mistakes made. [datetime] info - [foo.a] class done in log4j.xml, need add logger , ref class need log <logger name="foo.a"> <level value="info" /> <appender-re...

svg relative to absolute conversion -

i have been developing application requires transformations in svg flattened, , co-ordinates absolute. conversion relative (or incremental) absolute causing me problem. original svg fragment sourced inkscape conversion of pdf svg (and yes it's pretty ordinay image!). inkscape has defined "paths" using relative co-ords. ran code convert absolute co-ordinates think trivial files render differently. appears start points fot paths moved. i have been searching explanation why occurs. have looked @ converted file cannot see problem. starting point of paths match in each file match? can offer reason why conversion not result in same result? the source 2 files are: original relative: <?xml version="1.0" encoding="utf-8" standalone="no"?> <svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" viewbox="2420 3960 70 40" height="300" width=...

Add SSH key in GitHub -

Image
i have created ssh keys in computer , copied contents of id_rsa.pub github. ssh- , rsa can't on same line. ssh- rsa when press delete, '-' deleted, , ssh , rsa @ same line. input '-', situation go back. because of ,i can't add ssh keys github. i'd have see doing sure, able add github ssh key doing following: use puttygen.exe generate new public/private key pair. save public key id_rsa.pub. open id_rsa.pub in text editor. copy lines make key. do not copy comment line or begin ssh2 , end ssh2 public key lines! log github. click profile pic , click "settings". click "ssh , gpg keys" option. add "ssh-rsa " (don't forget space after rsa) front of key text. this worked me without issue. hoping helps.

javascript - How "Math.random() * arr.length | 0" works for return a random index for an array -

i've been working in legacy code have functionality should return random item array , see following expression: array[math.random() * arr.length | 0] my first impression try undestand the | operator can't figure out how work. test expression in chrome console , see returns valid index this: let array = [1,2,3,4] for(let = 0; < 5000; i++){ console.log(array[math.random() * arr.length | 0]); } how "math.random() * arr.length | 0" works return random index array? math.random() returns number >= 0 , < 1. * arr.length returns number >= 0 , < arr.length, yet can't used index, because have fractional part | 0 coerces left expression integral number applies bitwise or number zero, other number this said, makes work implicit conversion (called coersion) in operator | .

windows - Force Unmounting a VHD in Windows10 ( without a restart ) -

there requirement monitor pool of 20 servers. each servers create vhds periodically perform xyz tasks , unmounts them safely. vhd mounting , unmounting scripts legacy ones , written in batch diskpart.exe , not powershell more ever stale vhds start pile in these servers on period of time (a week or several reasons). there way force unmount vhd discarding changes periodically part of cleanup routine? diskpart not effective ejecting drive or unmounting disk manager not clean approach , throws errors if vhd not unmounted restarting server cleanest way not preferred is there way force unmount vhd drives via powershell or inbuilt win10 tools when .vhdx file not available. preferred approach use powershell script on diskpart avoid these kind of issues?

Displaying the error message in android edittext on the right side when using validation instead of on the below edit text -

Image
this question has answer here: design android edittext show error message described google 5 answers public class mainactivity extends activity { private edittext emailedittext; private edittext passedittext; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); emailedittext = (edittext) findviewbyid(r.id.edittext_email); passedittext = (edittext) findviewbyid(r.id.edittext_password); findviewbyid(r.id.btn_signup).setonclicklistener(new onclicklistener() { @override public void onclick(view arg0) { final string email = emailedittext.gettext().tostring(); if (!isvalidemail(email)) { emailedittext.seterror("invalid email"); } final string pass = passedittext.gettext().t...

android - How to Show Popup Menu near to Listview each item on Item Click Event? -

how show popup menu near listview each item on item click event ? this code. want show popup menu near listview item on item click. shows @ bottom only. me show popup menu near list item clicked. thank . package saro.example.com.task2_listview; import android.app.dialog; import android.content.context; import android.content.dialoginterface; import android.os.build; import android.support.annotation.requiresapi; import android.support.v7.app.alertdialog; import android.support.v7.app.appcompatactivity; import android.os.bundle; import android.view.contextmenu; import android.view.gravity; import android.view.layoutinflater; import android.view.menu; import android.view.view; import android.view.viewgroup; import android.widget.adapterview; import android.widget.arrayadapter; import android.widget.listview; import android.widget.listadapter; import android.widget.popupwindow; import android.wid...