This file contains 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
jQuery.fn.extend({ | |
/** | |
* Smooth scrolling to element | |
* @param interval Scrolling interval | |
* @param offset Offset from an element | |
*/ | |
scrollTo: function (interval, offset) { | |
'use strict'; | |
if (typeof interval === 'undefined') { | |
interval = 1000; |
This file contains 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
/** | |
* A module for calling the BTC-e trading API methods | |
* @author Eugene Maslovich <[email protected]> | |
*/ | |
var https = require('https'), | |
querystring = require('querystring'), | |
crypto = require('crypto'), | |
nonce = Math.round((new Date()).getTime() / 1000); |
This file contains 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
let secret = pm.variables.get('secret-key'), | |
timestamp = Date.now(), | |
query = pm.request.url.query | |
.filter(x => !x.disabled && x.key !== 'signature') | |
.map(x => { | |
if (x.key === 'timestamp') { | |
return `${x.key}=${timestamp}`; | |
} | |
else { | |
return `${x.key}=${x.value}`; |
This file contains 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
root = true | |
[*] | |
indent_style = space | |
indent_size = 2 | |
tab_width = 2 | |
end_of_line = lf | |
charset = utf-8 | |
trim_trailing_whitespace = true | |
insert_final_newline = true |
This file contains 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 readline = require('readline'); | |
const questions = [ | |
['What does the fox say?', 'Yeeeee'], | |
['Will you be coding this weekend?', 'Whaaaatt?!'] | |
]; | |
const cmd = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout |
This file contains 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 readline = require('readline'); | |
const questions = [ | |
['Can the fox be recursive?', 'O_o'], | |
['Can readline be non-recursive?', 'Yep'] | |
]; | |
const cmd = readline.createInterface({ | |
input: process.stdin, | |
output: process.stdout |
This file contains 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
/** | |
* Разные асинхронные паттерны в JS, решающие одну и ту же задачу | |
*/ | |
///////////////// callbacks /////////////////////////////////// | |
function asyncFunction(callback) { | |
setTimeout(callback.bind(this, 42), 100); | |
} | |
asyncFunction(console.log.bind(this, 'asyncFunction:')); |
This file contains 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 heavyFunc() { | |
const limit = Math.pow(10, 8); | |
let res = 0; | |
for (let i = 1; i < limit; i++) { | |
res += Math.atan2(i, i) * Math.random(); | |
} | |
return res; | |
} | |
async function heavyFuncWithAsync() { |
This file contains 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 MongoClient = require('mongodb').MongoClient; | |
const uri = 'mongodb://localhost:27017/'; | |
const mongoClient = new MongoClient(uri, { | |
useNewUrlParser: true, | |
useUnifiedTopology: true, | |
}); | |
(async () => { | |
const connection = await mongoClient.connect(); |
This file contains 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
// Custom promise-based compose | |
const composeWithPromise = (...args) => | |
R.composeWith((f, val) => { | |
if (val && val.then) { | |
return val.then(f); | |
} | |
if (Array.isArray(val) && val.length && val[0] && val[0].then) { | |
return Promise.all(val).then(f); | |
} | |
return f(val); |
OlderNewer