Skip to content

Instantly share code, notes, and snippets.

View alessioalex's full-sized avatar

Alexandru Vlăduţu alessioalex

View GitHub Profile
@alessioalex
alessioalex / domtokenlist.js
Created October 22, 2021 19:17 — forked from ShirtlessKirk/domtokenlist.js
DOMTokenList polyfill for IE < 9; implements element.classList
/**
* Polyfill of DOMTokenList for IE < 9
* Monkey patch of .add, .remove for IE 10 / 11, Firefox < 26 to support multiple arguments
* Monkey patch of .toggle for IE 10 / 11, Firefox < 24 to support second argument
*/
/*global define: false, module: false */
/*jslint nomen: true */
(function domTokenListModule(global, definition) { // non-exporting module magic dance
'use strict';
@alessioalex
alessioalex / htmldiff.js
Created January 31, 2021 16:11 — forked from bcks/htmldiff.js
htmldiff
(function() {
var Match, calculate_operations, consecutive_where, create_index, diff, find_match, find_matching_blocks, html_to_tokens, is_end_of_tag, is_start_of_tag, is_tag, is_whitespace, isnt_tag, op_map, recursively_find_matching_blocks, render_operations, wrap;
is_end_of_tag = function(char) {
return char === '>';
};
is_start_of_tag = function(char) {
return char === '<';
};
@alessioalex
alessioalex / sjcl-example.js
Created July 11, 2018 12:52 — forked from yetanotherchris/sjcl-example.js
Stanford Javascript Crypto Library basic AES example
// Basic AES example using the defaults.
// https://github.com/bitwiseshiftleft/sjcl
var password = "password";
var text = "my secret text";
var parameters = { "iter" : 1000 };
var rp = {};
var cipherTextJson = {};
sjcl.misc.cachedPbkdf2(password, parameters);
@alessioalex
alessioalex / server.js
Last active May 27, 2016 07:06 — forked from koistya/server.js
Async node-postgres sample code
/*
import express from 'express';
import db from './core/db';
const app = express();
const port = process.env.PORT || 3000;
app.get('/visits', (req, res, next) => {
db.connect(async ({ query } => {
await query('INSERT INTO visit (date) VALUES ($1)', new Date());
@alessioalex
alessioalex / System Design.md
Created April 18, 2016 07:12 — forked from vasanthk/System Design.md
System Design Cheatsheet

#System Design Cheatsheet

Picking the right architecture = Picking the right battles + Managing trade-offs

##Basic Steps

  1. Clarify and agree on the scope of the system
  • User cases (description of sequences of events that, taken together, lead to a system doing something useful)
    • Who is going to use it?
    • How are they going to use it?
$ cat test.js
function foo () { while (true) { } }
function bar () { return foo(); }
bar();
$ node test.js &
$ gdb attach $(pidof node)
0x00000bf778c63d5f in ?? ()
(gdb) b v8::internal::Runtime_StackGuard
Breakpoint 1 at 0x84a1f0
(gdb) print 'v8::V8::TerminateExecution'(0)
@alessioalex
alessioalex / convert.js
Last active August 29, 2015 14:10 — forked from rf/convert.js
var fs = require('fs');
var infile = process.argv[2];
if (!infile) return console.log("need infile");
var data = fs.readFileSync(infile, 'utf8').split('\n');
var outlines = [];
data.forEach(function(item) {
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2014
Copyright (C) 2014 Addy Osmani @addyosmani
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@alessioalex
alessioalex / rwd.css
Created July 31, 2014 15:15 — forked from trey/rwd.css
/* http://twitter.github.com/bootstrap/scaffolding.html#responsive */
/* Landscape phones and down */
@media (max-width: 480px) { ... }
/* Landscape phone to portrait tablet */
@media (max-width: 768px) { ... }
/* Portrait tablet to landscape and desktop */
@media (min-width: 768px) and (max-width: 940px) { ... }
var fs = require('fs');
var lame = require('lame');
var Speaker = require('speaker');
fs.createReadStream(process.argv[2])
.pipe(new lame.Decoder())
.on('format', function (format) {
this.pipe(new Speaker(format));
});