Skip to content

Instantly share code, notes, and snippets.

View aks-'s full-sized avatar
๐Ÿ˜€

Ashok aks-

๐Ÿ˜€
  • Hamburg, Germany
View GitHub Profile
class Hash
def to_csv
# Process :header, if provided
# Process :body
# Return a CSV
end
end
# Usage:
# {header: ["One", "Two", "Three"], body: [["A", "B", "C"], [1, 2, 3]]}.to_csv
var net = require('net');
var client = net.connect({host:'facebook.com', port: 80},
function() { //'connect' listener
console.log('connected to server!');
client.write('GET / HTTP/1.0\r\nhost: www.facebook.com\r\naccept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8\r\naccept-encoding:gzip, deflate, sdch\r\naccept-language:en-GB,en-US;q=0.8,en;q=0.6\r\nuser-agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36\r\n\r\n');
});
client.on('data', function(data) {
console.log('server response');
console.log(data.toString());
client.end();
@aks-
aks- / gist:3d9f9b8f7f6203dbfb41
Created October 25, 2015 15:58 — forked from chenglou/gist:40b75d820123a9ed53d8
Thoughts on Animation

Interesting part (unmounting & API) is at the end if you're not interested in the rest =).

Stress Tests

This animation proposal is just an attempt. In case it doesn't work out, I've gathered a few examples that can test the power of a future animation system.

  1. Parent is an infinitely spinning ball, and has a child ball that is also spinning. Clicking on the parent causes child to reverse spinning direction. This tests the ability of the animation system to compose animation, not in the sense of applying multiple interpolations to one or more variables passed onto the child (this should be trivial), but in the sense that the parent's constantly updating at the same time as the child, and has to ensure that it passes the animation commands correctly to it. This also tests that we can still intercept these animations (the clicking) and immediately change their configuration instead of queueing them.

  2. Typing letters and let them fly in concurrently. This tests concurrency, coordination of an array of ch

@aks-
aks- / error-handling1.js
Last active January 10, 2023 17:25
Simple Node Error Handling Part 1
// BAD
async function fn1 (req, res) {
// does bunch of stuff here
...
// I died, I can't tell you why :(
const resultFn2 = await fn2(d)
}
async function fn2 (d) {
@aks-
aks- / error-handling2.js
Created January 10, 2023 17:24
Simple Node Error Handling Part 2
// BAD
async function fn1 (req, res) {
const res = await fn2(req);
}
async function fn2 (req) {
try {
await foobar();
} catch (e) {
// sent req to this function because we wanted to log it
@aks-
aks- / create-uuid-from-firebase-id.cjs
Last active February 24, 2024 10:21
Firebase ID to UUID and vice versa; Quick hack to help a friend
import { stringify, parse } from "uuid";
import assert from 'node:assert';
function createUUID(base64String) {
const buf = Buffer.from(base64String, 'base64');
const uint8Array = new Uint8Array(16);
buf.copy(uint8Array, 0, 0, 6);