Posts

Showing posts from May, 2011

jquery - web client to get progressive server response - how to? -

been trying this, perhaps efforts not heading right, appreciate help. my html page has button , div. when click button, server has keep pushing numbers couple of seconds interval, , server pushes numbers, need them on div, progressively, in-synch server's status. how achieve this? tried using asynccontext, behaves similar response , flushes whole output @ end not want. protected void doget(httpservletrequest request, httpservletresponse response) throws servletexception, ioexception { response.setcontenttype("text/html"); asynccontext ac = request.startasync(request, response); ac.start(new runnable() { @override public void run() { (int = 1; <= 5; i++) { try { ac.getresponse().getwriter().print("hello-"+i); system.out.println("written hello"); thread.sleep(3000); } catch (exception e1) { e1....

Smooth out css transitions in iOS without causing position:fixed elements to malfunction -

Image
while testing website on ios device realized particular transition, used animate changing of div 's background-color , looked jittery on it. @ first thought device's fault, when later tested on few other, newer devices result same. i did research , discovered known problem, , need improve animation quality coax ios enabling hardware acceleration. this answer showed me how: -webkit-transform: translate3d(0, 0, 0); adding style the div smoothed out transition. however, had unintended side-effect making elements had position: fixed stop working properly, , instead behave if had position: absolute instead. here screenshot of page, scrolled down, viewed on ipad without style: and here screenshot of page scrolled down same amount, with style: the nav is, in fact, still there. have scroll see it. no longer fixed viewport. here demo demonstrates bug in action: html, body { width:100%; height:100%; margin:0; padding:0; tran...

Swift Firebase observe with .childAdded retrieving duplicate data -

i have uicollectionviewcontroller acts feed retrieves , displays data firebase database. it's window's root view controller, exists. issue every time controller appears, of children observed node added collection view. fine initially, when leave controller , return, of same data gets appended, creating duplicates. here pseudo-code, representing interaction firebase: class viewcontroller: uiviewcontroller { var children_query: databasequery! override func viewdidload() { super.viewdidload() self.children_query = database.database().reference().child("children").queryordered(bychild: "timestamp").querystarting(atvalue: date().timeintervalsince1970) } override func viewwillappear(_ animated: bool) { super.viewwillappear(animated) self.observeaddedchildren() } override func viewwilldisappear(_ animated: bool) { super.viewwilldisappear(animated) self.children_query.removeallobserve...

c# - Service Fabric Actor Timers Performance Implications -

we thinking of potentially using service fabric actor timers sort of ttl management service. has potential have 100 hundreds of thousands of actor timers @ time. concerned overhead of having many actor timers running @ time there not seem sort of documentation regarding actor timers performance implications or underlying mechanisms. guidance appreciated. from know, actor's timer uses lightweight 'system.threading.timer' under hood, creating along delegate has code dispatch call toward 'wake-up' callback when time comes. , seems dispatch happens other incoming request have, i'd couple classes delegate cost of having sf actor timer. of course, if need perform lot of work within timer's callback lock actor, depends on how many requests blocked , how fast leave callback.

google bigquery - Error when trying to run a query via bq cli -

i'm getting following error when trying execute bq query: fatal flags parsing error: unknown command line flag '-v' the query simple , think problem inside concat function, because i'm trying concat curl command , there have -v flag, query below: select concat('curl -v https://api.com.br/push.json -h \"content-type: application/json\" -h \"x_application: webapp\" -h -x post -d \'{\"pushes\":[\'' ,string_agg(to_json_string(t)),']}\'') json how can escape -v not getting error? thanks try running this: bq query "select concat('curl -v https://api.com.br/push.json -h \"content-type: application/json\" -h \"x_application: webapp\" -h -x post -d \'{\"pushes\":[\'',string_agg(to_json_string(t)),']}\'') json" in order prevent bash interpretation string, maybe reading query file might well. if query like: with data as( s...

javascript - lodash.debounce search in react js -

i'm trying debounce search in react using lodash, debounce. but when ever run i'm receiving type error typeerror: cannot read property 'debounce' of undefined i have tried moving around in code can't understand why isn't working i started off importing import { _, debounce } 'lodash' i have input following <input type="text" value={this.state.query} onchange={(e) => {this.updatequery(e.target.value)}} placeholder="search title or author" /> connected function updatequery = (query) => { _.debounce(() => query(this.setstate({ query }), 500)) this.onbooksearch(query) } does understand why is? i think import problem. want import _ default: import _, {debounce} 'lodash'; also you're not using extracted function: updatequery = (query) => { debounce(() => query(this.setstate({ query }), 500)) this.onbooksearch(query) } since you're extr...

java - tomcat timing out if no activity in 20s? -

if setup tomcat , stream static file it, i've noticed if client "pauses" (stops receiving) socket > 20s tomcat appears "sever" connection arbitrarily (even though require uri line has been received , connection still "connected" [client still alive]). configuration parameter controls this? documentation mentions connectiontimeout in connection initial header parsing , reading request body, not reading server's response [?] there kind of inactivity timeout going on here? it reproducible, stream (large) static file tomcat app, , receive client pauses, ex test.rb: require "socket" host = "localhost" port = 8080 socket = tcpsocket.new host,port url = "/your_webapp/large_static_filename.ext" request = "get #{url} http/1.0\r\nhost:#{host}\r\n\r\n" socket.print request puts "reading" response = socket.sysread 1_000_000 puts response.length puts response[0..300] puts "sleeping 25" #...

sql - Performing an aggregate operation (SUM) with the results of another query -

i have 2 tables: bookings (uid integer, in_date date, paxname text, acnumber integer) and accounts (uid integer, uidbooking integer, acnumber integer, amount_charged double) i sum charges accounts table belong subset of bookings. the first select chooses bookings in perdiod of time... select bookings.uid, bookings.acnumber bookings.status = 'checkedin' , bookings.indate > '2017-07-01' now second select should charges of bookings , sum amounts of accounts belonging selected bookings... select sum(amount_charged) accounts acnumber = bookings.acnumber so, how can results bookings uid, account number , in same row, sum of account charges... ? thnks using join plus group syntax or query follows: select b.uid, b.acnumber,sum(a.amount_charged) bookings b, accounts b.acnumber = a.acnumber , b.status = 'checkedin' , b.indate > '2017-07-01' group b.uid,b.acnumber; in table bookings there no acnumber, maybe have exch...

Using Bitbucket App Password in WebStorm -

Image
i'm working on project in webstorm that's hooked bitbucket version control. every once in while prompt log repository , there link on bottom suggesting use bitbucket app password. have app password on bitbucket, can't find on web how integrate webstorm app password. instead of typing account username , password in dialog, type app password's id in username field , app password's password in password field.

java - HSQLDB, LocalDateTime, JdbcTemplate -

i'm trying use hsqldb, spring jdbc template. works fine, until use java 8's localdatetime class. i have code: import org.hsqldb.jdbc.jdbcdatasource; import org.springframework.core.io.classpathresource; import org.springframework.core.io.resource; import org.springframework.jdbc.core.jdbctemplate; import org.springframework.jdbc.datasource.init.resourcedatabasepopulator; import java.time.localdatetime; public class test { public static void main(string[] args) throws exception { jdbcdatasource datasource = new jdbcdatasource(); datasource.setuser("sa"); datasource.setpassword(""); datasource.seturl("jdbc:hsqldb:mem:db"); resource resource = new classpathresource("/test.sql"); resourcedatabasepopulator databasepopulator = new resourcedatabasepopulator(resource); databasepopulator.execute(datasource); jdbctempl...

javascript - Materialize Collapsible Nav Not Working -

i'm not entirely sure why collapsible dropdown menus not working. have imported materialize , jquery , both working collapsible menu nothing when clicked. <!doctype html> <html> <head> <meta charset="utf-8"> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>create</title> <!-- fonts --> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script> <link href="https://fonts.googleapis.com/css?family=raleway:100,600" rel="stylesheet" type="text/css"> <link rel="stylesheet" type="text/css" href="css/materialize.css"> <script src="js/materialize.js" type="text/javascript"...

c - How to allocate aligned memory only using the standard library? -

i finished test part of job interview, , 1 question stumped me - using google reference. i'd see stackoverflow crew can it: the “memset_16aligned” function requires 16byte aligned pointer passed it, or crash. a) how allocate 1024 bytes of memory, , align 16 byte boundary? b) free memory after memset_16aligned has executed. { void *mem; void *ptr; // answer a) here memset_16aligned(ptr, 0, 1024); // answer b) here } original answer { void *mem = malloc(1024+16); void *ptr = ((char *)mem+16) & ~ 0x0f; memset_16aligned(ptr, 0, 1024); free(mem); } fixed answer { void *mem = malloc(1024+15); void *ptr = ((uintptr_t)mem+15) & ~ (uintptr_t)0x0f; memset_16aligned(ptr, 0, 1024); free(mem); } explanation requested the first step allocate enough spare space, in case. since memory must 16-byte aligned (meaning leading byte address needs multiple of 16), adding 16 bytes guarantees have enough space. som...

SendGrid - How to add recipients to a contacts list using Transactional emails? (PHP API) -

i using sendgrid "verify email address" transactional email when first sign website. using php api , sending of email works great. the problem have want add email address recipients list somewhere. when website goes live , people start signing up, have 1 big list of has signed up. can't see how without doing "marketing campaign", possible? i'm new sendgrid information see on contacts api, recipients, lists etc. marketing stuff don't see why can't have list based on transactional email process now. am missing point here? should able add recipients list somewhere when sending transactional email? thank time.

c# - ORA-06502: PL/SQL: numeric or value error with stored procedure and ASP.NET MVC -

i trying insert data oracle database asp.net mvc application. using stored procedure so, error: ora-06502: pl/sql: numeric or value error: character string buffer small ora-06512: @ "c##aet.kategorija_pkg", line 40 ora-06502: pl/sql: numeric or value error: character string buffer small ora-06512: @ line 1 procedure code is: procedure ins_kategorija ( p_naziv in kategorija.naziv%type, p_kategorija_id out kategorija.kategorija_id%type, p_rezultat out number, p_poruka out varchar2 ) begin p_rezultat := 1; select kategorija_seq.nextval p_kategorija_id dual; insert kategorija values (p_kategorija_id, p_naziv); p_rezultat := 0; p_poruka := 'db: kategorija uspesno uneta.'; exception when others p_rezultat := 1; p_poruka := 'db: ' ||sqlcode|| ' - ' ||sqlerrm; end ins_kategorija; and method calling it: list<oracleparameter> izvrsitransakciju(string nazivpro...

xcode - Leading/Trailing Space to Superview not working for Table View Cell -

my ui in xcode result in xcode simulator constraints left side (navy table view cell): trailing space to: superview width equals: 187.5 bottom space to: superview height equals: 319 leading space to: polltext1 (the other turquoise table view cell) top space to: poll username (username label on top of table view cells)

javascript - Checkout button in game currency in react.js -

so i'm making game in game currency , confused. think i'm making harder should be. have store , users use gold(max variable) buy item. shopping cart works want when press 'checkout' subtracts total amount of gold have. right checkout button nothing. think i'm having brain fart. want new value of gold show when item purchased. here store.js import react, {component} 'react'; import home '../components/home'; import cart '../containers/cart'; import productlist '../containers/productlist'; import checkout '../containers/checkout'; export default class store extends component{ render(){ var home = new home var max = home.getmax() return( <div classname="container"> <div classname="row"> <div classname="col-md-12"> <br /> <h3>armor , weapon store</h3> <h4 classna...

visual studio 2008 - C# NET 3.5 : Property or indexer cannot be assigned to “--” it is read only -

i have readonly property: public collectionview view { get; } and trying initialize class constructor: public myclass() { this.view = ...... } but error described in title appearing. using net 3.5 on visual studio 2008. remember in later versions of .net , visual studio readonly property initialized/assigned constructor. not possible in .net 3.5? if not, how can in .net 3.5? mean, want readonly property , assigned once in constructor. in c# 3.0 didn't add special handling read-only autoproperties must old way: public class myclass { private readonly collectionview _view; public collectionview view { { return _view; } } public myclass() { this._view = ...; } }

autoit - How to run custom function in a specific window and work in background? -

i wrote script using autoit . problem run in background can use desktop other work. i used _imagesearch() works on active window. there way call such function in background? here code: winactivate('window title') $x = 0 $y = 0 if _imagesearch('searchbutton.png', 1, $x, $y, 20) = 1 return 1 elseif _imagesearch('bundle.png', 1, $x, $y, 20) = 1 send('{esc}{lctrl}{lctrl}{lctrl}') sleep(1000) else send('{lctrl}') endif write script runs continuously , call image search hotkey: hotkeyset('+!e', '_endscript') ; terminate script shift+alt+e hotkeyset('+!i', '_searchimage') ; calls image search function shift+alt+i ; main loop while true sleep(50) wend func _endscript() exit endfunc func _searchimage() ; image search stuff endfunc but may other application blocks hotkeys. try it.

xcode - Swift: How to reset simulator by running shell command -

i trying reset simulator after every test. found best way it, execute xcrun simctl erase but don't know how add shell command in swift file execute it. i tried import foundation func shell(_ args: string...) -> int32 { let task = process() task.launchpath = "/usr/bin/env" task.arguments = args task.launch() task.waituntilexit() return task.terminationstatus } but got error, process u\identifier not found please help. trying reset simulators after each test. can uninstall particular application simulator command line? or other way between each test, in teardown() i had similar issue , able resolve sbtuitesttunnel . chose use framework had had communicate between testing application , actual application configure testing states. with sbtuitesttunnel implemented can specify launch options, 1 require sbtuitunneledapplicationlaunchoptionresetfilesystem. app.launchtunnel(withoptions: [sbtuitunneledapplicationlaunchoption...

javascript - Pass outer variable into promise .then without calling it -

i have series of promise functions i'm chaining together. don't need specific result previous function i'm not adding resolve(); need them run sequentially. however, there variable in containing scope want pass first , fourth(last) promise. when add parameter third promise, function runs immediately. how can pass parameter chained promise , not call function/promise @ time? here basics of i'm trying do: const containingfunction = function() { const vartopass = document.queryselector("#id").value.trim(); firstpromise(vartopass) .then(secondpromise) .then(thirdpromise) .then(fourthpromise(vartopass)) .catch(e =>{ console.error(e)); } ); }; fourthpromise: const fourthpromise = function(varpassed) { return new promise(function(resolve, reject) { stuff after thirdpromise has been resolved console.log(varp...

Visual Studio undoes my formatting options -

Image
in visual studio 2015, formatting options not sticking. for example, go tools >> options >> text editor >> javascript >> general , unselect automatic brace completion: i go tools >> options >> text editor >> javascript >> formatting >> new lines , select place open brace on new line functions , classes, , place open brace on new line control blocks. but these keep getting undone. why visual studio insist on undoing settings?

python - Why does unpacking this map object print "must be an iterable, not map"? -

what going on here? >>> list(map(lambda *x: x, *map(none, 'abc'))) traceback (most recent call last): file "<pyshell#52>", line 1, in <module> list(map(lambda *x: x, *map(none, 'abc'))) typeerror: type object argument after * must iterable, not map ignore senselessness of code. error message, "iterable, not map" . maps are iterables, not? and if replace none str , whole thing works fine: >>> list(map(lambda *x: x, *map(str, 'abc'))) [('a', 'b', 'c')] so python doesn't have issue map there after all. this happens in python 3.6.1. python 3.5.2 instead raises expected typeerror: 'nonetype' object not callable . , googling "must iterable, not map" finds no results @ all. apparently introduced recently. is python bug? or there sense this? update: reported bug now, suggested. i'd consider bug. here's source causes exception...

microservices - Is there exists a version in Springcloud Eureka system for each service? -

here have eureka service version 1.0(maven) registered in eureka server in production environment, , version 2.0 developing, published later. how register both version 1.0 , version 2.0 in 1 eureka server, , consumer services decide select right version wants to. is there exists version in springcloud eureka system each service? thanks.

ios - How to perform different segue based on condition from a button click in swift? -

Image
i'm building app in button takes profile registry view if open app first time , if open app other time. how can accomplish programmatically, have seen connects button 1 view. @ibaction func nextviewcontroller(_ sender: uibutton) { if launchedbefore { print("not first launch.") } else { print("first launch, setting userdefault.") userdefaults.standard.set(true, forkey: "launchedbefore") } } i think, trying connect button perform segue multiple viewcontroller right?? not possible instead have connect segue between view controllers adding segue between 2 viewcontrollers: from interface builder, ctrl + drag between 2 viewcontrollers want link. should see: and based on condition should perform segue identifiers below: @ibaction func nextviewcontroller(_ sender: uibutton) { if launchedbefore { /*use identifier given in story board*/ self.performsegue(with...

swift - How to resolve compile error : "AttValue: " or ' expected" in xcode -

i have renamed project , after doing stuff , resolving errors , face following error in " takeeditcell.xib ": line 15: attvalue: " or ' expected line 15: attributes construct error line 15: couldn't find end of start tag tableviewcell here code: <?xml version="1.0" encoding="utf-8"?> <document type="com.apple.interfacebuilder3.cocoatouch.xib" version="3.0" toolsversion="12120" systemversion="16e195" targetruntime="ios.cocoatouch" propertyaccesscontrol="none" useautolayout="yes" usetraitcollections="yes" colormatched="yes"> <device id="ipad9_7" orientation="portrait"> <adaptation id="fullscreen"/> </device> <dependencies> <plugin identifier="com.apple.interfacebuilder.ibcocoatouchplugin" version="12088"/> <capabili...

vb.net - How Do i Extracting the Highest Resolution icon from program -

i'm makeing program mimics desktop, i've got working i'm getting lowest resolution out icons. i need of icons files in set path, these icons need best can (256x256). want icon files .exe .lnk .url .txt .png . jpg shortend verstion have currently.(i remove part don't have affect on icons) public class form1 dim counter integer = 0 dim iconarray(200) picturebox dim titlearray(200) label dim linker(200) string public sub loading(sender object, e eventargs) handles mybase.load apps_on_screen.items.addrange(io.directory.getfiles("c:\users\public\desktop")) 'gets files on desktop , adds them listbox threading.thread.sleep(0) 'waits till file have been got desktop dim icon_position_x = 0, icon_position_y = 5 'sets start x , y icons dim title_position_x = 0, title_position_y = 55 'sets start x , y text under icons integer = 0 apps_on_screen.items.count - 1 'loops every item in listbox dim icon new picturebox ...

Alternative approach to using agrep() for fuzzy matching in R -

i have large file of administrative data, 1 million records. individual people can represented multiple times in dataset. half records have identifying code maps records individuals; half don't, need fuzzy match names flag records potentially belong same person. from looking @ records identifying code, i've created list of differences have occurred in recording of names same individual: inclusion of middle name e.g. jon snow vs jon targaryen snow inclusion of second last name e.g. jon snow vs jon targaryen-snow nickname / shortening of first name e.g. jonathon snow vs jon snow reversal of names e.g. jon snow vs snow jon mispellings/typos/variants: e.g. samual/samuel, monica/monika, rafael/raphael given types of matches i'm after, there better approach using agrep()/levenshtein's distance, implemented in r? edit: agrep() in r doesn't job problem - because of large number of insertions , substitutions need allow account ways names recorded differentl...

Ruby On Rails: How to check if a csv file is downloaded -

i have download button in view form, use "index" action in controller def index respond_to |format| format.html { @some_variables = some_variables.page(params[:page]) } format.csv { render csv: some_variables, headers: somevariable.csv_headers } end end and def self.to_csv method in model somevariable, in generate csv file. is there anyway check if download ok , example set flag. if download went ok else raise error end i thought "begin rescue" in index action, if there other "smarter" implementation sharing more appreciated. send_file can alternative you're planning do. can find more information here how download file send_file? , @ api dock

ide - Show warnings and errors on PhpStorm project tree? -

how show if file has warnings or errors on phpstorm project tree? phpstorm have feature of showing errors in file/tree/code.. make red line error, yellow warnings. , can switch error/warning directly clicking on red/yellow line ctrl (ctrl+click)

mysql - SQL How can I get 0 as output (HAVING COUNT()) -

i having problem sql query. trying list of customer ids orders no (0) orders before 1 looked @ , orders 1 (1) order before 1 looked at. following query gives me expected results third line (count_compl_ord_before_d_1) no results second line (count_compl_ord_before_d_0): select created_at d, customer_id b, (select customer_id orders customer_id = b , created_at < d , status = 'complete' having count(created_at) = 0 ) count_compl_ord_before_d_0, (select customer_id orders customer_id = b , created_at < d , status = 'complete' having count(created_at) = 1 ) count_compl_ord_before_d_1 orders status = 'complete' , created_at >= '2017-06-08' however, when run following, different amounts 0 xxx count_compl_ord_before_d: select created_at d, customer_id b, (select count(created_at) orders customer_id = b , created_at < d , status = 'complete') count_compl_ord_before_d orders status = 'complete' , created_at >= ...

c# - LINQ .FromSQL error InvalidOperationException: Sequence contains more than one matching element -

i have exception being raised when requesting data stored procedure using entity framework , linq. an unhandled exception occurred while processing request. invalidoperationexception: sequence contains more 1 matching element system.linq.enumerable.singleordefault<tsource>(ienumerable<tsource> source, func<tsource, bool> predicate) the relevant part of stack here (apologies on 2 lines stack overflow editor won't let me break without leaving code block formatting): system.linq.enumerable.singleordefault<tsource>(ienumerable<tsource> source, func<tsource, bool> predicate) microsoft.entityframeworkcore.query.sql.internal.fromsqlnoncomposedquerysqlgenerator.createvaluebufferfactory(irelationalvaluebufferfactoryfactory relationalvaluebufferfactoryfactory, dbdatareader datareader) microsoft.entityframeworkcore.internal.noncapturinglazyinitializer.ensureinitialized<tparam, tvalue>(ref tvalue target, tparam param, func<tparam, tvalu...

Debugging app always crashing in android emulator -

i trying debug app using android studio , android emulator. app gets installed successfully, when app comes crashes message: unfortunately test app has stopped below log see adb monitor. have deleted android folder multiple times , reinstalled, not help. 07-27 23:43:40.586 1503-2301/system_process w/inputmethodmanagerservice: window focused, ignoring focus gain of: com.android.internal.view.iinputmethodclient$stub$proxy@20129f4e attribute=null, token = android.os.binderproxy@2c17f0c6 07-27 23:43:41.525 1503-1527/system_process i/choreographer: skipped 45 frames! application may doing work on main thread. 07-27 23:43:45.546 2902-2902/test.com.integratedcoe a/chromium: [fatal:compositor_impl_android.cc(559)] timed out waiting gpu channel. --------- beginning of crash 07-27 23:43:45.546 2902-2902/test.com.integratedcoe a/libc: fatal signal 6 (sigabrt), code -6 in tid 2902 (m.integratedcoe) 07-27 23:43:45.6...

html - Align text with center of text as reference point -

i have text i'm trying align under moving tick on chart. can stick tick doing: <div class="foo">text</div> .foo { width: $tick-location px; text-align: right; } but problem aligns end of text touching tick. want center of text touch tick. don't, however, know size of text ahead of time. how can achieve this? example: ----------|----- xxxxx ----------|----- xxxxx the first get. second want. use transform text centering. better change left instead of changing 'width' .foo { position:relative; display: inline-block; width: auto; left:100px; /* here text's center @ 100px; */ /* left:$tick-location px; */ transform:translatex(-50%); } <div class="foo">text</div>

How to use VBScript to open notepad and paste current date with DDMMYYYY format in it? -

how use vbscript open notepad , paste current date in ddmmyyyy format? when use below code, output in dd/mm/yyyy format. want in ddmmyyyy format. set wshshell = wscript.createobject("wscript.shell") call wshshell.run("%windir%\system32\notepad.exe") dim adate adate = date() wscript.sleep 4000 wshshell.sendkeys adate could guys please me on one? the date format want: ddmmyyyy (without common slashes) this should work you: dim wshshell: set wshshell = wscript.createobject("wscript.shell") wshshell.run("%windir%\system32\notepad.exe") wscript.sleep 4000 dim adate: adate = wscript.createobject("system.text.stringbuilder").appendformat("{0:dd}{0:mm}{0:yyyy}", now).tostring() wshshell.sendkeys adate

c# - ASP.NET Core API authentication using Firebase and Identity -

i have api use firebase jwt token authentication. in startup.cs registered identity : services.addidentity<applicationuser, identityrole>(config => { config.user.requireuniqueemail = true; config.password.requirenonalphanumeric = false; config.cookies.applicationcookie.automaticchallenge = false; }) .addentityframeworkstores<databasecontext>() .adddefaulttokenproviders(); and added jwt token middleware: app.usejwtbearerauthentication(new jwtbeareroptions { automaticauthenticate = true, includeerrordetails = true, authority = "https://securetoken.google.com/[my-project-id]", tokenvalidationparameters = new tokenvalidationparameters { validateissuer = true, validissuer = "https://securetoken.google.com/[my-project-id]", validateaudience = true, ...

javascript - Why Babel compile 'this' keyword as undefined inside a prototype function? -

Image
this question has answer here: when should use arrow functions in ecmascript 6? 6 answers babel replaces undefined 2 answers i started learn es6 used babel compile code, when assign this keyword variable inside prototype method compiled undefined is bug? or problem code? es6 code function prefixer(prefix) { this.prefix = prefix; } prefixer.prototype.prefixarray = arr => { let self = this; return arr.map((x) => { console.log(self.prefix + x); }); } var pre = new prefixer("hello "); pre.prefixarray(['jeeva', 'kumar']); babel compiled code 'use strict'; function prefixer(prefix) { this.prefix = prefix; } prefixer.prototype.prefixarray = function (arr) { var self = undefined; return arr.map...

javascript - how can I store a firebase query object in a variable in angular? -

i trying make query firebase database using ionic. want store the object snapshot.val() in variable objective of displaying content in html code i´m struggling scope of upcomingorders variable. how can update variable inside callback? onfetchmyupcomingorders(){ var upcomingorders = {} const userid = this.authservice.getactiveuser().uid; var ref = firebase.database().ref("orders/confirmed"); ref.orderbychild("client/clientid").equalto(userid).once("value", (snapshot) => { upcomingorders= snapshot.val() console.log(upcomingorders) }); console.log(upcomingorders) // empty object, should contain snapshot.val() } it seems it's updating value. how can update reference? the data loaded firebase asynchronously. while data being loaded, function continues run. when console.log() before end of function executes, data hasn't been loaded yet. when data becomes available, callback function i...

html - insomnia -- Cannot read property 'post' of undefined -

var express = require('express'); var path = require('path'); var app = express(); var mongoose = require('mongoose'); var bodyparser = require('body-parser'); mongoose.promise = require('bluebird'); mongoose.connect("mongodb://makja:q1w2e3r4@ds111123.mlab.com:11123/makja" , { usemongoclient: true }); var db = mongoose.connection; db.once("open", function () { console.log("db on!"); }); db.on("error", function (err) { console.log("db error : " , err); }); var dataschema = mongoose.schema({ name:string, count:number }); var postschema = mongoose.schema({ title : {type:string, required:true}, body : {type:string, required:true}, createdat : {type:date, default:date.now}, updatedat : date }); var post = mongoose.model('post',postschema); app.get('/posts', function(req , res){ post.find({}, function(err,posts){ if (err) return res.json({success:false, mes...