This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async function f() { | |
| let promise = new Promise((resolve, reject) => { | |
| setTimeout(() => resolve("done!"), 1000) | |
| }); | |
| let result = await promise; // wait till the promise resolves (*) | |
| alert(result); // "done!" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| loadScript('first.js', function(err,script){ | |
| if(err){ | |
| //error handling | |
| //fail to load 1st script | |
| }else{ | |
| loadScript('second.js', function(err,script){ | |
| if(err){ | |
| //error handling | |
| //fail to load 2nd script | |
| }else{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function loadScript(src) { | |
| let script = document.createElement('script'); | |
| script.src = src; | |
| document.head.append(script); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getData() { | |
| var data; | |
| $.get("example.php", function(response) { | |
| data = response; | |
| }); | |
| return data; | |
| } | |
| var data = getData() | |
| console.log("the data is"+data) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Say "Hello." | |
| console.log("Hello."); | |
| // Say "Goodbye" two seconds from now. | |
| setTimeout(function() { | |
| console.log("Goodbye!"); | |
| }, 2000); | |
| // Say "Hello again!" | |
| console.log("Hello again!"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Math.round(new Date().getTime()/1000)+60 // 1548319864 == 2019.01.24 pm5:50 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/python | |
| import datetime | |
| import sys | |
| print datetime.datetime.fromtimestamp(float(sys.argv[1])/1000).strftime('%Y-%m-%d %H:%M:%S.%f') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Go to home directory | |
| cd ~ | |
| # You can change what anaconda version you want at | |
| # https://repo.continuum.io/archive/ | |
| curl -Ok https://repo.continuum.io/archive/Anaconda3-4.1.1-MacOSX-x86_64.sh | |
| bash Anaconda3-4.1.1-MacOSX-x86_64.sh -b -p ~/anaconda | |
| rm Anaconda3-4.1.1-MacOSX-x86_64.sh | |
| echo 'export PATH="~/anaconda/bin:$PATH"' >> ~/.bash_profile |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const app = require('express')(); | |
| const server = require('http').Server(app); | |
| const request = require('request'); | |
| const io = require('socket.io-client'); | |
| server.listen(3005); | |
| app.get('/', function (req, res, err) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const app = require('express')(); | |
| const server = require('http').Server(app); | |
| const request = require('request'); | |
| const Websocket = require('ws'); | |
| function getPairs(){ | |
| return new Promise((resolve, reject)=>{ | |
| request('https://cex.io/api/currency_limits', function(error, res, body){ | |
| if (res.statusCode == 200 && !error){ |