Skip to content

Instantly share code, notes, and snippets.

View famasya's full-sized avatar
🎯
Focusing

Abid Famasya famasya

🎯
Focusing
  • Indonesia
View GitHub Profile
function largestOfFour(arr) {
arr = arr.map(function(val){
return val.sort(function(a,b){
return b-a;
})[0];
});
return arr;
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
@famasya
famasya / composer.md
Created November 3, 2015 18:17
Composer configuration behind proxy

Not messing up with current setting

https_proxy="proxy2.domain.com:443" composer diag

@famasya
famasya / promise.js
Last active January 10, 2016 05:24
[How to] Using promise ES 6
new Promise(function(resolve,reject){
[1,2,3,4].forEach(function(v){
console.log(v);
resolve();
});
}).then(function(){
console.log("done");
});
@famasya
famasya / using-async.js
Created January 10, 2016 04:05
[How to] using async.js
var obj = {dev: "/dev.json", test: "/test.json", prod: "/prod.json"};
var configs = {};
async.forEachOf(obj, function (value, key, callback) {
fs.readFile(__dirname + value, "utf8", function (err, data) {
if (err) return callback(err);
try {
configs[key] = JSON.parse(data);
} catch (e) {
return callback(e);
@famasya
famasya / discoveraddress.C
Last active July 1, 2016 22:52
Discover intel galileo address
void setup(){
system("telnetd -l /bin/sh");
}
void loop(){
system("ifconfig > /dev/ttyGS0 > 2>&1");
sleep(10);
}
@famasya
famasya / task.js
Created April 17, 2017 13:48
Periodically checking token validity by web worker
self.addEventListener('message', function(e){
setInterval(function(){
self.postMessage("Checking token "+e.data);
// Do AUTH checking here...
}, 1000);
}, false);
import websocket, requests
def main():
url = "http://localhost:9222/json"
# Get DebuggerURL
connection = requests.get(url)
# Initiate websocket connection via debugger URL
ws = websocket.create_connection(connection.json()[0]['webSocketDebuggerUrl'])
ws.send(
date C F X B L D
2019-06-21 0.476 0.147 0.327 0.013 0.014 0.015
2019-06-22 0.468 0.167 0.329 0.012 0.013 0.013
2019-06-23 0.454 0.16 0.348 0.011 0.012 0.014
2019-06-24 0.466 0.157 0.347 0.012 0.007 0.014
2019-06-25 0.455 0.158 0.348 0.01 0.007 0.018
2019-06-26 0.445 0.167 0.347 0.012 0.007 0.021
2019-06-27 0.471 0.158 0.331 0.013 0.007 0.016
2019-06-28 0.469 0.166 0.324 0.014 0.013 0.015
2019-06-29 0.458 0.172 0.333 0.013 0.012 0.014
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 37 columns, instead of 24. in line 1.
0.841498715000000 1.00936652600000 0.993816009000000 8.46980516700000 10.2787266700000 10.0377595000000 8.50136466700000 8.58172616700000 10.2477633300000 10.0588216700000 8.63136616700000 1485.52850000000 1485.45400000000 1485.43750000000 1485.35416700000 1485.46816700000 1485.45066700000 1484.92816700000 1485.50866700000 1485.39122900000 34.5703133300000 33.5058600000000 36.7024750000000 37.1305366700000 35.3238950000000 35.5940783300000 34.3750000000000 32.4511733300000 34.5686850000000 33.0826833300000 36.7220050000000 36.9694033300000 36.0758466700000 36.0514316700000 35.1741550000000 32.7294900000000 1
0.842250216000000 1.00658369400000 0.996605206000000 7.53189100000000 9.13992450000000 8.95161783300000 7.61221283300000 7.62332516700000 9.10634516700000 8.94514250000000 7.67404583300000 1486.04233300000 1485.99283300000 1485.97333300000 1485.86783300000 1485.99033300000 1485.99216700000 1485.46666700000 1486.03366700000 1485.91989600000 34.3180333300000 33.4293600000000 36.6829416700000 37.080076670000
We can make this file beautiful and searchable if this error is corrected: It looks like row 2 should actually have 52 columns, instead of 16. in line 1.
1.18508888900000 1.02812777800000 1.01647777800000 0.150000000000000 2.19574444400000 2.54094444400000 2.51196111100000 2.08788888900000 2.39443888900000 1483.86983300000 1486.38216700000 1485.37205600000 1484.98900000000 1485.15322200000 5260.65555600000 5067.58888900000 4977.82222200000 4984.07777800000 5170.31111100000 5200.20555600000 4111.52777800000 4291.85000000000 9.03894444400000 4.42683333300000 4.50455555600000 9.24122222200000 100 100 100 100 100 100 100 100 100 52.5000000000000 52.5000000000000 52.9000000000000 52.9000000000000 50.7000000000000 50.7000000000000 49.8000000000000 49.8000000000000 84.1070672200000 84.0030977800000 120.338783300000 120.144244400000 120.371772200000 120.179077800000 84.0190533300000 83.9199711100000 1
1.19180555600000 1.03375000000000 1.01941111100000 0.217000000000000 2.19246666700000 2.54659444400000 2.51674444400000 2.07570555600000 2.39608888900000 1483.74738900000 1486.25922200000 1485.25033300000 1484.86705600000 1485.03072200000 5256.22777800000 5065.4000000000