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
read = IO.read(ARGV.first) | |
puts 'hello' if a == nil | |
read.chomp | |
one_str = read.split("\n") | |
name = "Time" | |
one_str.each {|x| a = x.split("|") | |
if a[1].include?(name) | |
d = a[7].to_i | |
e = a[7].to_f - d | |
puts a[1] |
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
var matrixExample = [ | |
[1, 2, 3, 4], | |
[4, 5, 6, 5], | |
[7, 8, 9, 7], | |
[7, 8, 9, 7] | |
] | |
function sumMatrix(matrix) { | |
var arr = [] | |
var arr2 = [] |
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 values = ['sadasdasd', 'sdfsdfsdf', 'sdfsdf']; | |
const obj = [{ id: 1, transaction: 'sdfsdf' }]; | |
const sorted = values.filter(value => obj.map(item => item.transaction).includes(value)); | |
console.log(sorted); |
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 values = ['sadasdasd', 'sdfsdfsdf', 'sdfsdf']; | |
const obj = [{ id: 1, transaction: 'sadasdasd' }]; | |
const sorted = obj.filter(item => item.transaction.indexOf(values.transaction) !== -1); | |
console.log(sorted); |
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 for rinding min index of elemtnt in array | |
function smallest(arr) { | |
let smallest[0]; | |
let smallestIndex = 0; | |
for (let i = 0; i < arr.length; i ++) { | |
if (arr[i] < smallest) { | |
smallest = arr[i] | |
smallestIndex = i |
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 times10 = n => n * 10; | |
const cache = {}; | |
const memoTimes10 = n => { | |
if (n in cache) { | |
return cache[n]; | |
} | |
else { | |
let res = times10(n); | |
cache[n] = res; |
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 memoizationClosuresTimes10 = n => { | |
let cache = {}; | |
return n => { | |
if (n in cache) { | |
return cache[n] | |
} else { | |
let res = n * 10; | |
cache[n] = res; | |
return res; | |
} |
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* RequestData() { | |
try { | |
yield put(requestData()); | |
while (true) { | |
yield call(delay, 60000); | |
const data = yield call(fetchDataStatus); | |
if (data.res) { | |
yield put(requestDataSuccess(data.resp)); | |
} |
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 chain(prev = null) { | |
const cur = () => { | |
if (cur.prev) { | |
cur.prev.next = cur; | |
cur.prev(); | |
} else { | |
cur.forward(); | |
} | |
} | |
cur.prev = prev; |
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 timeout(ms, fn) { | |
let timer = setTimeout(() => { | |
if (timer) console.log('Function timedout'); | |
timer = null; | |
}, ms); | |
return (...args) => { | |
if (timer) { | |
timer = null; | |
fn(...args); | |
} |
OlderNewer