Posts

Showing posts from July, 2011

unit testing - Cannot setup `babel-plugin-rewire` for React tests -

i'm trying setup babel-plugin-rewire in jest tests can generate small test snapshot wrapper component instead of having huge 1 child components in it. the settings seem correct following error: referenceerror: wrapper not defined @ _get_original__ (app\components\wrapper\tests\index.te st.js:22:2168) @ _get__ (app\components\wrapper\tests\index.test.js:22: 1912) @ suite.<anonymous> (app\components\wrapper\tests\index. test.js:8:82) @ object.<anonymous> (app\components\wrapper\tests\index .test.js:6:1) @ process._tickcallback (internal\process\next_tick.js:103:7) package.json "babel": { "presets": [ [ "latest", { "es2015": { "modules": false } } ], "react" ], "env": { "test": { "plugins": [ "babel-plugin-rewire", "transform-es2...

javascript - Position two divs in a jQuery UI tabs properly? -

Image
i noob css programmer , need little help. here 2 screenshots: and i need position tree , tinymce editor exist in divs in tab area. can see bottom tab border high instead of below tree , editor. here html code: @{ viewbag.title = "demo"; } <link href="../../plugins/jqueryui/css/jquery-ui.css" rel="stylesheet"/> <link href="../../content/style.css" rel="stylesheet" type="text/css" /> <link href="../../plugins/jstree/style.css" rel="stylesheet" type="text/css" /> <link href="../../plugins/tinymce/skins/lightgray/skin.min.css" rel="stylesheet" type="text/css" /> <link href="../../plugins/tinymce/skins/lightgray/content.min.css" rel="stylesheet" type="text/css" /> <h2>demo</h2> <fieldset> <legend>select language: </legend> <label for="mk-mk...

How can I populate a dynamically sized 2D array in Swift 3.0 to be an X by 4 two-D array? -

i want write function in swift 3.0 populate 2d array of string arrays, meaning {{"mr.", "john", "q.", "public"} {"ms.", "jane", "e.", "doe"}...} in program, titles in array of own, first, while middle initial , last names in own arrays together. so far, have: func build2dstringarray() -> [[string]]{ var col = 0 var row = 0 var string2darray = [[string]]() title in titles{ string2darray[col][row].append(title){ firstname in firstnames{ string2darray[col][row].append(firstname){ lasttwo in lasttwo{ string2darray[col][row].append(middleinit) string2darray[col][row].append(lastname) col += 1 row += 1 } } } } } return string2darray } but when run it, "index out of range." how can need. of now, need have 150 se...

How to add new group for project role? JIRA 7 API, JAVA -

lets have project role developers , want asing new group called database_developers it. problem can not find way create instance of roleactor . guessing implementation need com.atlassian.jira.security.roles.actor.grouproleactorfactory.grouproleactor there no such factory. edit 1: think found (overlooked method): roleactorfactory roleactorfactory = componentaccessor.getcomponentoftype(roleactorfactory.class);

sql - mySQL - Query to count rows and total percentage too slow -

table named 'log', has 50 million rows: | id | domainip | | foo | 158.132.34.5 | | bob | 128.12.244.3 | | bob | 128.12.244.3 | | bob | 19.152.134.4 | | bob | 168.152.34.9 | | alice | 178.132.64.10 | | alice | 188.152.214.200 | | peter | 208.162.36.153 | | peter | 208.162.36.153 | | peter | 208.162.36.153 | | peter | 198.168.94.201 | i have following query, number of times id used each 'domainip', , percentage of each: select `log`.`id`, `log`.`domainip`, count(`log`.`domainip`) "times", totalstable.totals, (count(`log`.`domainip`)/totalstable.totals)*100 "percentage" `log` join ( select `id`, count(`domainip`) totals `log` group `id` ) totalstable on (`log`.`id` = totalstable.`id`) group `log`.`domainip` order `log`.`id` asc, "percentage" desc it returns: | id | domainip | times | totals | percentage | foo ...

c# 4.0 - Saving data read from sql database -

i have 4 textboxes , metrogrid, inside textboxes data read them sql database, while saving data in textboxes 1 save , others vanish. please need code search button: private void btnsearch_click(object sender, eventargs e) { try { using (sqlconnection connection = new sqlconnection(@"server = .\sql2012; database = dbacceptance; integrated security = true; ")) { sqlcommand command = new sqlcommand($"select * acceptance regno = {txtregno.text}", connection); connection.open(); sqldatareader read = command.executereader(); if (read.read()) { txtfullname.text = (read["fullname"].tostring()); txtdepartment.text = (read["department"].tostring()); txtfaculty.text = (read["faculty"].tostring()); txtmodeofstudy.text = (read["modeofstudy"].tostring()); txtprogramme.t...

powershell - Compare directories exactly - including moved files -

my aim compare 2 directories - including structure of directories , sub-directories. i need this, because want monitor if in folder e:\path2 changed. case copy of full folder in c:\path1 . if changes has done in 2 directories. it important us, because if changed in directory (accidentally or not) break down other functions in our infrastructure. this script i've written: # compare files "copy default folder" # script compares files , folders synced every client. # source: https://mcpmag.com/articles/2016/04/14/contents-of-two-folders-with-powershell.aspx # 1. compare content , name of every file recursively $sourcedocshash = get-childitem -recurse –path c:\path1 | foreach {get-filehash –path $_.fullname} $destdocshash = get-childitem -recurse –path e:\path2 | foreach {get-filehash –path $_.fullname} $resultdocshash = (compare-object -referenceobject $sourcedocshash -differenceobject $destdocshash -property hash -passthru).path # 2. compare name of every f...

android - Can tensor flow be a good tool for gesture detection? Or Can it be used for gesture detection? -

i want train model different gesture later if give gesture want android app detect gesture or predict close possible gesture. can tensor flow in work? i want give gesture example i'll give gesture of or b , also if i've gesture keyboard i'll give gesture moving finger on different keys. i want detect letter first case and second case letters upon gesture has gone on in gesture keyboard, want predict word letter of gesture(which has gone on letter word creating). thanks in advance. yes, tensorflow can used gesture detection. https://www.youtube.com/watch?v=y6olbrkwmpk

python - unable to login with scrapy -

i'm trying scrape page have login first, reason, scrapy crawl page have nothing do, after use formrequest. see code below: # coding: utf-8 import scrapy scrapy.http import request, formrequest usuario = 'myemail' senha = 'mypassword' urllogin = 'https://ludopedia.com.br/login' urlnotificacoes = 'https://ludopedia.com.br/notificacoes' class notificacao(scrapy.item): """contem os dados dos anuncios da ludopedia""" jogo = scrapy.field() colecao = scrapy.field() tipo = scrapy.field() link = scrapy.field() class loginspider(scrapy.spider): name = 'ludopedia' custom_settings = { 'concurrent_requests': 1, 'log_level': 'debug', } start_urls = [ urllogin ] def parse(self, response): return formrequest.from_response( response, formname='form', formid='form', for...

aws api gateway - Postmates Webhook -

for deliveries sent postmates, don't receive webhook on our api gateway endpoint. there no footprint of message on api gateway logging. the same scenario works fine if application hosted on stand alone server. we take same url , send posts other sources able capture requests, url working one.

ios - XCode doesn't recognize variable ProfileHandler with pods -

guys, i have pod file not old project # uncomment next line define global platform project # platform :ios, '9.0' target 'myapp' # comment next line if you're not using swift , don't want use dynamic frameworks use_frameworks! # pods myapp pod 'alamofire', '~> 4.0' pod 'swiftyjson' pod 'keychainswift', '~> 7.0' pod 'keychainswift', '~> 7.0' pod 'facebookcore' pod 'facebooklogin' pod 'facebookshare' pod 'fabric' pod 'crashlytics' pod 'rskimagecropper' pod 'koloda', :git => 'https://github.com/yalantis/koloda.git', :branch => 'swift-3' pod 'mbautogrowingtextview' pod 'ccbottomrefreshcontrol' pod 'sdavassetexportsession', :git => 'https://github.com/rs/sdavassetexportsession.git' pod 'firebase/core' pod 'iqkeyboardmanagerswift' target 'myapptests' inher...

dataTable Buttons will not show up -

function init_datatable() { $(document).ready(function(){ $('#table').datatable( { dom: 'lfrtipb', buttons: [ 'copy', 'excel', 'pdf' ] } ); }); } the datatable initiates , works properly, buttons not load. any idea what's going wrong here? using these cdn links (network loads them well): <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.10.15/css/jquery.datatables.css"> <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.10.15/js/jquery.datatables.js"></script> <!--datatable cdn buttons--> <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.3.1/css/buttons.datatables.min.css"> <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/butt...

How to call DblClick sub from code VBA Excel -

i have excel worksheet 2 forms: form1 , form2 . form1 has textbox1 double-click events: public sub textbox1_dblclick(byval cancel msforms.returnboolean) ' activity... end sub form2 has commandbutton2 click event: private sub commandbutton2_click() ' activity... end sub i need call textbox1_dblclick sub commandbutton2_click sub. how can make call this? create new module , add sub operations wish perform sub mysubroutine() ' stuff end sub then call both of click handlers ' in form1 public sub textbox1_dblclick(byval cancel msforms.returnboolean) mysubroutine end sub ' in form2 private sub commandbutton2_click() mysubroutine end sub if wanted pass stuff (like text box strings etc) forms, include input arguments in sub sub mysubroutine(str string, n long) ' passing arguments ' stuff end sub then pass arguments when make call anywhere ' string , long data on form, call mysubroutine mysubroutine str:...

python regex match and replace beginning and end of string but keep the middle -

i have dataframe holiday names. have problem on days, holidays observed on different days, on day of holiday. here example problems: 1 "independence day (observed)" 2 "christmas eve, christmas day (observed)" 3 "new year's eve, new year's day (observed)" 4 "martin luther king, jr. day" i want replace ' (observed)' '' , before comma if ' (observed)' matched. output should be: 1 "independence day" 2 "christmas day" 3 "new year's day" 4 "martin luther king, jr. day" i able both independently: (foo['holiday'] .replace(to_replace=' \(observed\)', value='', regex=true) .replace(to_replace='.+, ', value='', regex=true)) but caused problem 'martin luther king, jr. day'. replace.py import re input = [ "independence day (observed)", "christmas eve, christmas day (observed)...

python - Making a list of all possible 5 card poker -

i'm trying make list of possible 5 card poker hands use in computations (that may slow preferably speedy). list, wrote following code: import itertools # possible cards: cards = ['2s', '2h', '2d', '2c', '3s', '3h', '3d', '3c', '4s', '4h', '4d', '4c', '5s', '5h', '5d', '5c', '6s', '6h', '6d', '6c', '7s', '7h', '7d', '7c', '8s', '8h', '8d', '8c', '9s', '9h', '9d', '9c', 'ts', 'th', 'td', 'tc', 'js', 'jh', 'jd', 'jc', 'qs', 'qh', 'qd', 'qc', 'ks', 'kh', 'kd', 'kc', 'as', 'ah', 'ad', 'ac'] hands = [] # collect non-trivial cartesian products element in itertools.product...

gdb - How to add stack trace to core dump -

i want automatically add step core dump generation procedure (preferably cores process if not possible processes well). want add text file containing chunk of core in same folder. at moment using core_pattern generate core name , compress want run gdb on core before compression print stack trace file , compress. is possible? take @ apport, does of want .

c# - WPF ObservableCollection not updating in view -

i working on project using mvvm user connects database server , presented list of database areas on server use. list of areas, using combobox has itemsource bound observablecollection. combobox itemssource="{binding areacollecton}" selecteditem="{binding selectedarea}" in viewmodel, have observablecollection defined this: private observablecollection<string> areacollection = new observablecollection<string>(); public observablecollection<string> areacollection { { return areacollection; } set{ areacollection = value; onpropertychanged("areacollection"); } } the collection updated when server name entered , connect button clicked. click event poll server entered areas available , return list viewmodel. public void connect() { areacollection.clear(); serverconnection = new serverconnect(); arealist = serverconnection.getarealist(server); //arealist defined dictionary<string, str...

How to perform some action when my Android app is launched -

i creating android app. want voice sort of message execute when app launches . have figured out message part using text speech, cannot execute automatically on app startup.can me out ? if want execute code once wehn app starts 1 possible solution: public class myapp extends application { public myapp() { // method fires once per application start. // getapplicationcontext returns null here log.i("main", "constructor fired"); } @override public void oncreate() { super.oncreate(); // method fires once constructor // application has context here log.i("main", "oncreate fired"); } } then should register class application class inside androidmanifest.xml <application android:label="@string/app_name" android:name=".myapp"> <------- here <activity android:name="myactivity" android:label=...

java - How to store the values into a dictionary using jquery -

i have function return properties , values of element under mouse pointer. i'm not able add values dictionary want use other purpose. can me out in this. appreciated. code goes follows: public void function1(){ ijavascriptexecutor j; j.executeasyncscript(@"return $('body').hover(function(evt){var x=document.elementfrompoint(evt.pagex,evt pagey);var att={}; $(x.attributes).each(function(){att[this.nodename]=this.nodevalue;});console.log(att);});"); //want use dictionary containing properties , values }

winforms - VB.NET: What happens if I run CPU-bound code using Await? -

i trying understand async/await. understand should not await cpu-bound method, understanding curious happens if do. consider: public async function dosometasks() await longrunningcpuboundmethod1() longrunningcpuboundmethod2() end function public async function longrunningcpuboundmethod1() task ' stuff synchronously end function public sub longrunningcpuboundmethod2() ' stuff synchronously end sub how task scheduler handle cpu resources? in order these methods execute? longrunningcpuboundmethod1 or longrunningcpuboundmethod2 execute first? the thing remember here async / await code not multi-threaded. can use them multi-threaded code awaiting items start separate thread, allow break several tasks efficiently in same thread. this doesn't come without overhead; switching between asynchronous tasks has cost. when await cpu-bound tasks, you've added cost cpu-intensive work, , therefore made things worse rather better. however, if ...

Can a Java 8 stream process an expanding number of elements? -

i had programming exercise find palindrome combinations. example, palindromes in list [ "abc", "def", "zzb", "cba", "yes", "fed" ] the answers be ["abc", "cba"], ["cba", "abc"], ["def", "fed"], ["fed", "def"], ["abc", "def", "fed", "cba"] and on. maybe 8 data set. i note number of combinations consult depends on n!, meaning list small ten elements means searching on 3 million combos. to conserve memory wrote functions took initial list , created permutations, each found permutation , processed. @ no time entire bloated list in memory. i didn't use java 8 streams because presume can't add stream source (in case, 6 elements), , internally system buffer permutations maximum list size overflow memory. is there stream solution in java exercise? know how create palindromes. seek how...

r - shiny conditional panel not updating -

i have issue conditional panel. show in sidebarpanel either daterange or sliderinput depending on selected choice in radiobutton, in sidebarpanel. if try run below example fail following error message: error : formal argument "condition" matched multiple actual arguments if comment out of 2 conditions can see example variable has value a or b depending on options chosen. i'm pretty sure i'm missing something, cannot figure out what. did around , couldn't find helpful. library(shiny) # server --------------------------------------------- server = shinyserver(function(input, output){ output$debug <- renderprint({ input$example }) }) # ui ------------------------------------------------- ui = { fluidpage( sidebarpanel( radiobuttons('example', 'select examples: ', choices = c('a', 'b'), selected = 'a'), conditionalpanel( condition = "input.example == 'a...

php - MYSQLI database design/structure -

i don't have coding question more of structure related one. if had site example allowed user sign up, login, , manage finances, or family photobook or whatever.(the job front end performing irrelevant) if have multiple users registering , creating there own accounts correct way store data? assume not have single table different users data proper create single table user logins automatically create new table exclusive each new user hold data related there personal login? take online check book example, have table manages user logins during registration process automatically create table user hold data entries own check book. correct? if data requires multiple tables manage 1 particular users data? also have links on proper database structure check out? not knowing correct terminology hindering searches. thanks in advance! do not create table each user, create 1 table keyed user's unique identifier , put user's data it. can create 1 such table each logic...

java - Hibernate H2 database locks after project rebuild -

i setting spring hibernate h2 application. when server starts works after update (rebuild project in eclipse without restarting tomcat) following error messages saying database file can't accessed. error messages: java.lang.illegalstateexception: file locked: nio:/home/bob/datastore.mv.db [1.4.187/7] java.nio.channels.overlappingfilelockexception org.apache.commons.dbcp.sqlnestedexception: cannot create poolableconnectionfactory (database may in use: after googling error tried adding file_lock=no , db_close_on_exit=true url no luck. context.xml file <context:annotation-config /> <context:component-scan base-package="com" /> <mvc:annotation-driven /> <mvc:resources mapping="/resources/**" location="/resources/" /> <bean id="datasource" class="org.apache.commons.dbcp.basicdatasource"> <property name="driverclassname" value="org.h2.driver...

git - Vagrant is refusing connection to github -

Image
i running command "vagrant provision" on mac terminal error displaying regarding connection github when open github on browser working fine. this when run command.

Google Cloud SQL MySQL 2nd Gen Concurrent Connections? -

the pricing page gives information 1st gen. know concurrent connection limits 2nd gen? second generation instances configured allow 4000 connections though not mean can safely run workload @ 4000 connections given instance size. different workloads have different demands still need monitor/benchmark application choose appropriate instance size. e.g. might able make 4000 concurrent connections n1-standard-1 instance it's unlikely perform many workloads

wpf - Binding errors on ContentControl after changing Content before ContentTemplate is applied -

i'm having annoying issue not causing problems, generating ton of binding errors unnecessarily. i've tracked problem down fact setting content on contentcontrol changes datacontext of content before applies new contenttemplate. since new content not of same type old contenttemplate expects, generates binding errors old contenttemplate. here's how have contentcontrol set up. content bound viewmodel selected tab, , contenttemplate bound datatemplate view tab. used have using contenttemplateselector instead of converter contenttemplate, had same issues tried instead. <contentcontrol content="{binding selectedtab, converter={staticresource configurationviewmodelconverter}}" contenttemplate="{binding selectedtab, converter={staticresource configurationtemplateconverter}}"/> perhaps i've got wired wrong somehow working exception of binding errors when switching tabs, seemingly due content , contenttemplate getting briefly out of sync. ...

javascript - Angular4 - My script events doesn't work after routerLink click -

i'm new in angular. have script in jquery sintax , scripts many efects on dom. when start application script works after click in routerlink inside dom mouse events dosen't work, click events. ideia problem? tks! example of code: $(document).ready(function(){ $.material.init(); $("#side-menu").children().children().mouseover(function(){ $(this).addclass('_active'); }).mouseout(function(){ $(this).removeclass('_active'); }); }

python - Replace a variable number of asterisks with NaN in a dataframe -

i'm trying scrub climate data ncdc , has columns varying number of asterisks indicate empty fields. want replace np.nan . i have tried df.replace struggling regex syntax handle variable length of asterisks in field. suspect need df.replace('?', np.nan) '?' regex match number of asterisks. here clip of data: usaf wban yr--modahrmn dir spd gus clg skc l m ... slp alt stp max min pcp01 pcp06 pcp24 pcpxx sd 0 722543 12977 200601010053 160 6 *** 722 clr * * ... 1010.9 29.83 1007.2 *** *** 0.00 ***** ***** ***** ** 1 722543 12977 200601010153 160 9 *** 722 clr * * ... 1011.0 29.83 1007.2 *** *** 0.00 ***** ***** ***** ** 2 722543 12977 200601010253 160 9 *** 722 clr * * ... 1011.1 29.83 1007.2 *** *** 0.00 ***** ***** ***** ** 3 ...

javascript - Document level event listeners being duplicated -

Image
i using sammyjs route website, , i'm using file structure, inside of controller/ , have 4 main pages. inside, this, (function() { var app = sammy.apps.body; app.get('#/clients', function(context) { context.render('/view/clients/index.html', function(view) { $('body').html(view); }); }); app.get('#/clients/edit', function(context) { context.render('/view/clients/edit.html', function(view) { $('body').html(view); $(document).on('click', '#updateclient', function() { //do stuff updating client here... }); }); }); }); with first navigation works fine. html , javascript load , buttons work intended. upon page navigation (i'm using href 's handle navigation) page , back, event listeners being duplicated, can seen here (using chrome) before(first navigation) after(second navigation) is there way stop thi...

Namespaced key lookup on Rails 5 association with ActiveRecord -

i have following models: class supervision::applicationrecord < activerecord::base self.abstract_class = true def self.table_name_prefix "supervision_" end end --------------- class supervision::activity < supervision::applicationrecord has_one :supervision_missed_visit, class_name: supervision::missedvisit (...) end --------------- class supervision::missedvisit < supervision::applicationrecord belongs_to :supervision_activity, class_name: supervision::activity (...) end and have model, isn't namespaced: class activity < applicationrecord (...) end whenever try reach supervision::missedvisit through has_one relationship, in @supervision_activity.supervision_missed_visit i following error: error: column supervision_missed_visits.activity_id not exist how make rails understands i'm looking supervision_missed_visits.supervision_activity_id ? you specify foreign key: has_one :supervision_missed_visit,...

listview - ExpendableListView Child doesn't appear in Android Nougat -

Image
expandablelistview child doesn't appear in android nougat. as in image, it's working in android version less android 7 , display childs

node.js - ForeverJS bash script errors on first line -

im trying foreverjs script run node server on ec2 instance. script looks like: #!/bin/bash forever stopall forever hakuna-matata store in appropriate logs start 'full/qualified path' even if add echo "getting here" statement first line still error. not know bash scripting well, may permissions, relative/absolute path, ec2/node, environment variable related, not know. stacktrace: [ec2-user@12-34-56 folder]$ forever startup.sh warn: --minuptime not set. defaulting to: 1000ms warn: --spinsleeptime not set. script exit if not stay @ least 1000ms /home/user/var/www/folder/startup.sh:2 echo "gh" ^^^^ syntaxerror: unexpected string @ createscript (vm.js:74:10) @ object.runinthiscontext (vm.js:116:10) @ module._compile (module.js:533:28) @ object.module._extensions..js (module.js:580:10) @ module.load (module.js:503:32) @ trymoduleload (module.js:466:12) @ function.module._load (module.js:458:3) @ function.m...

java - Kotlin: appendText and closing resources -

i'm new kotlin, have strong java background (java day job). i'm loving of shortcut functions in kotlin. 1 of big ones file.appendtext(). it's convenient, imo. my question closing resources. if use writer, this: out8.writer().use { ... } but don't see thing directly on appendtext method indicates closing resources. kotlin handle behind scenes me, or have worry in way? thanks. you can jump implementation of appendtext in ide find out ( ctrl + b on windows, ⌘b on mac). here's implementation of method: public fun file.appendtext(text: string, charset: charset = charsets.utf_8): unit = appendbytes(text.tobytearray(charset)) and here's appendbytes method delegates work to: public fun file.appendbytes(array: bytearray): unit = fileoutputstream(this, true).use { it.write(array) } you can see uses use helper method you've expected.

swift - UIVisualEffectView with CAGradientLayer not working on iOS 10 -

i'm trying create effect whereby photo blurry @ top, not @ bottom, , blurriness 'fades off' gradually. achieved code below, worked fine in ios9, not in ios10. i'm aware of known bug, described in question , prevents layer having mask , blur on same layer. the difference between question , 1 linked, i'm not interested in using cashapelayer mask, rather cagradientlayer. i've tried fiddling adding views/masks/layers in different orders, not having luck. var visualeffectview = uivisualeffectview(effect: uiblureffect(style: .light)) visualeffectview.frame = cgrect(x: 0.0, y:0.0, width: photo.bounds.width, height: photo.bounds.height) photo.addsubview(visualeffectview) let maskstartcolour = uicolor(red: 0.0, green: 0.0, blue: 0.0, alpha: 1.0) let maskendcolour = uicolor(red: 0.0, green: 0.0, blue: 0.0, alpha: 0.0) let gradient = cagradientlayer() gradient.frame = cgrect(x: 0, y: 0, width: visualeffectview.bounds.width, height: v...

c# - Working with Dropdowns in MVC 5 -

i need dropdown inaccessible (in can visible or not, preferably invisible). approach take? i’m using c#, asp.net mvc 5, , razor syntax. thanks in advance answers. this bit abstract since you're asking in general sense. in razor, i'd evaluate condition determines if should shown or not , within "if" block, put code build dropdown. @if (showdropdown){ @html.dropdownlistfor(model => model.myfield, myselectlist) } else { @html.hiddenfor(model => model.myfield) } if want value of myfield stick around when post form, use hidden field value when dropdown supposed invisible.

java file system WatchService not picking up file when file is created by another java programm -

i have implemented watchservice on file system directory. there java process writes directory. when manually create file in directory, watchservice able pick when java process creates file in directory, watchservice not able pick up. i'm using below sample code write file. com.google.common.io.files.write("test content".getbytes(), new file("/var/tmp/dir/1.txt")); the problem mounted nfs file system. had use apache file watcher api resolve issue.

annotations - Annotate Type Parameter in Java for Kotlin Compiler -

in java, have following method: public optional<foo> getfoo() { // return non-null value } in kotlin code, return type of method given optional<foo!>! . using @nonnull annotation can cut down optional<foo!> (i.e. foo type not null-checked anymore). is there way annotate method make kotlin compiler null-check return value correctly? you can annotating type use of foo of nullability annotations kotlin compiler understands . unfortunately, annotation libraries list don't support type use annotation. i found @notnull org.jetbrains:annotations:15.0 (but not 13.0) has type_use target, can add library dependency project , annotate type use: import org.jetbrains.annotations.notnull; ... public @notnull optional<@notnull foo> getfoo() { // return non-null value } then return type seen optional<foo> in kotlin. this, of course, can done other nullability annotations list mentioned above support type_use target. ...

How to retrieve nested properties along with the id from Azure DocumentDB -

Image
i have documents stored in documentdb follow basic design: { "id": "abc123", "hiddenfield": "xxxxxx", "attributes": { "x": "7", "y": "8", "z": "9" } } in example there 3 properties under attributes, not constant in practice. want retrieve without hidden field , project arbitrary number of attributes root of document alongside id: { "id": "abc123", "x": "7", "y": "8", "z": "9" } with query can x, y, , z root: select value c.attributes c which produce result: { "x": "7", "y": "8", "z": "9" } ...but query invalid: select c.id, value c.attributes c which understandable docs can either list properties or use value operator. fair enough. is there way use join operator or other projecti...

angularjs - Value not saved after edit ng repeat angular -

i have little trouble angular. have td element. initially, populated value 'item.comparedproducts.value'. when click on it, let me edit value. want remain saved after refresh it. if delete ng-repeat, it's successful. or if delete code after ng-init.. =false; (item <- this) there no values initially, brought comparedproducts, if edit label , refresh, value saved. have ideas how resolve simpler? or helpful information share me it? lots of <tr class="col-new3"> <td>value</td> <td ng-repeat="item in list" ng-init="editcorrectvalue = false; item.correctedmonthlyvalue=item.comparedproducts.value" data-ng-click="editcorrectvalue = true; focusinput($event)" class="add-comma is-editable"> <input ng-blur="editcorrectvalue = false" ng-show="editcorrectvalue" data-ng-model="item.correctedmonthlyvalue" type="nu...

replication - Postgresql 9.4 and BDR SELECT bdr.bdr_group_join ERROR -

i'm trying configurate postgresql 9.4 bdr, have 2 servers master has address 169.254.9.90 , slave has address 169.254.12.48. have configurated master when try join slave replication i'm getting error: command join: select bdr.bdr_group_join( local_node_name := 'node2', node_external_dsn := 'host=169.254.12.48 port=5432 user=postgres dbname=amstest password=postgres', join_using_dsn := 'host=169.254.9.90 port=5432 user=postgres dbname=amstest password=postgres' ); the error im getting is: error: connection remote local in replication mode failed detail: remote reported: error: establish bdr: fatal: no pg_hba.conf entry replication connection host "169.254.9.90", user "postgres", ssl on fatal: no pg_hba.conf entry replication connection host "169.254.9.90", user "postgres", ssl off detail: connection string 'replication=database fallback_application_name='bdr ...

eps - Postscript: paths and nested call to run -

i making .ps file (using dvips) contains many .eps graphics located in multiple other directories, in turn contain code imported text files using postscript "run" command. my problem paths. to view .eps in gsview (as write , debug it) relative path text file must relative location of .eps file. the problem in order view final .ps relative paths various text files must relative location of .ps file. the way can .eps files display both directly , when embedded in .ps specifying absolute path included text file. is there way make work using relative paths, or other trick make project location independent? have dozens of .eps files don't want drop them in same directory. probably sensible way override 'run' operator in final postscript program amends path in string supplied with. the eps files work (if do) because run not @ time redefined. enclosing postscript file redefine 'run' prefixes strings correct path, eps files work when encap...

javascript - How to map multiple commands to a key in CodeMirror? -

currently have code uses codemirror set keystrokes/keymaps in text area. when presses tab , keystroke result in 2 space tab. stuff.area = codemirror.fromtextarea(elem, { mode: "some_language" indentunit: 4 tabsize: 4 extrakeys: "tab": ((cm) => cm.replaceselection(" ", "end")), }) however, make can use codemirror autocomplete feature work when hit tab well. there way set multiple keymaps specific key? either using existing codemirror functionality or editing codemirror source.

How to calculate a count of users who did a thing X times during a rolling 7-day period in SQL Server? -

Image
i want calculate count of unique users have posted 5 or more times on course of 7-day rolling period. how do this? i know how calculate count of users have posted 1 or more times on course of 7-day rolling period. query looks this: with postsperday ( select cast(creationdate date) [day] , owneruserid [user] , count(*) post posts creationdate > '2017-07-01' group cast(creationdate date) , owneruserid ) select [day], count(distinct [user]) dailyposters, rolling7daycount postsperday outer apply ( select count(distinct [user]) rolling7daycount postsperday ppd ppd.[day] >= dateadd(dd, -7, postsperday.[day]) , ppd.[day] < postsperday.[day] ) rolling7daycount group [day], rolling7daycount order 1 here @ stack exchange data explorer . desired results ideally i'm looking four-column result: day , dailyposters , rolling7daycount , rolling7daycount5xposters . (the sample query returns first 3 columns.) to clear: i'm hoping count...

ionic framework - Cordova sharing plugin does not share mesage on facebook. -

i'm using cordova share plugin share on facebook profile. need share link, message , image. willing share message , can never it. nothing appears. works me twitter , whatsapp not facebook. why? var text="any text"; var image_gif="" //image gif of cellphone var link="https://play.google.com/store/apps/details?id=com.facebook.katana" $cordovasocialsharing.shareviafacebook(text, image_gif,link).then(function(result) { // success! }, function(err) { alert("problem") }); i using android device this limitation of plugin. read plugins documentation . facebook android: sharing message not possible. can share either link or image (not both), description can not prefilled. see facebook issue won't solve. alternative can use shareviafacebookwithpastemessagehint since plugin version 4.3.4. see below details. note sharing url on non standard domain (like .fail) may not work on android. make sure test th...

javascript - Use ngx-translate in component -

i'm using ngx-translate no-problems in views, using pipes. need use in component, example show error message, or define datatable column default content. i'm trying like: translate.instant("area.new"); or translate.get("area.new").subscribe((res: string) => { console.log(res); }); i've tried calling in ngoninit() , ngafterviewinit() but in both cases "area.new", not translated word. asume json dictionary loaded after call, don't realize how make work.

TypeScript Generic Collection: List -

i trying learn typescript, , need advice on implementing generic collection types. put dictionary , hashset in question, here i'd advice on list type. especially foreach-operation looks bit strange. think found in question here, , "improved" returning true or false give feedback if iteration stopped or completed. import { iforeachfunction } "./iforeachfunction" export class list<t> { private _items: array<t>; public constructor() { this._items = []; } public count(): number { return this._items.length; } public item(index: number): t { return this._items[index]; } public add(value: t): void { this._items.push(value); } public removeat(index: number): void { this._items.splice(index, 1); } public remove(value: t): void { let index = this._items.indexof(value); this.removeat(index); } public foreach(callback: iforeachfunction...

sql server - Is it possible to inventory MSSQL-Linux running within Docker? -

part of job involves data collection size workloads transferred cloud. element of being able enumerate sql instances within client's environment insights such "hey have out of support legacy sql here supposed decommed years ago, what's deal." with release of sql server 2017, i've created instance of sql server enterprise 2017 on linux container (using this image ) i'm running locally on windows 10. can connect instance via ssms , select @@version confirm it's legit, question if possible inventory device , find sql instance without knowing connection string. things i've tried: -running on windows 10 believe supported via hyper-v, when try go through hyper-v manager connect vm docker spun up, can't interface there (which figured, since docker emulates apps rather full vms) -tried sqlcmd -l win10 host device , don't see instance (don't have sql installed on windows 10 device i'm running from) -i can find docker image via dock...

vba - Trigger macro at text+F9 -

i run macro if text has been typed , if f9 pressed afterwards, example: the patient has been diagnosed dia1 , followed f9 key. word should react on f9 key , run macro dia1 erase word "dia1" typed text , insert text. how this? two things: 1- solution finds "dia1" within last line, doesn't check last word. if insist on last word here is: sub lastword() dim rng range, wrd string set rng = activedocument.paragraphs.last.range wrd = strreverse(trim(left(strreverse(rng), instr(1, strreverse(rng), " ", vbtextcompare)))) msgbox wrd end sub 2- f9-f12 reserved closest option f8. alternatively can assign macro f9 following these steps , @ibo suggested. solution: 1-bind f8 macro sub bind() application.customizationcontext = thisdocument.attachedtemplate keybindings.add keycode:=buildkeycode(wdkeyf8), keycategory:=wdkeycategorymacro, command:="runme" end sub 2- "find , replace" macro: ...

r - Why are these numbers not equal? -

the following code wrong. what's problem? i <- 0.1 <- + 0.05 ## [1] 0.15 if(i==0.15) cat("i equals 0.15") else cat("i not equal 0.15") ## not equal 0.15 general (language agnostic) reason since not numbers can represented in ieee floating point arithmetic (the standard computers use represent decimal numbers , math them), not expected. true because values simple, finite decimals (such 0.1 , 0.05) not represented in computer , results of arithmetic on them may not give result identical direct representation of "known" answer. this known limitation of computer arithmetic , discussed in several places: the r faq has question devoted it: r faq 7.31 the r inferno patrick burns devotes first "circle" problem (starting on page 9) david goldberg, "what every computer scientist should know floating-point arithmetic," acm computing surveys 23 , 1 (1991-03), 5-48 doi>10.1145/103162.103163 ( revision availa...