Skip to content

Instantly share code, notes, and snippets.

View lsocrate's full-sized avatar

Luiz Socrate lsocrate

  • Stockholm, Sweden
  • 15:27 (UTC +02:00)
View GitHub Profile
@lsocrate
lsocrate / tag.ts
Created August 3, 2019 08:26 — forked from krisselden/tag.ts
// requires strict mode
// set false to minimize out runtime checks
const DEBUG = true;
export const enum TagTypes {
A,
B,
// C
/* adding this will cause Tag and unreachable to Error
@lsocrate
lsocrate / The Technical Interview Cheat Sheet.md
Last active August 29, 2015 14:28 — forked from tsiege/The Technical Interview Cheat Sheet.md
This is my technical interview cheat sheet. Feel free to fork it or do whatever you want with it. PLEASE let me know if there are any errors or if anything crucial is missing. I will add more links soon.

Studying for a Tech Interview Sucks, so Here's a Cheat Sheet to Help

This list is meant to be a both a quick guide and reference for further research into these topics. It's basically a summary of that comp sci course you never took or forgot about, so there's no way it can cover everything in depth. It also will be available as a gist on Github for everyone to edit and add to.

Data Structure Basics

###Array ####Definition:

  • Stores data elements based on an sequential, most commonly 0 based, index.
  • Based on tuples from set theory.
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install # ok, fine, this step probably takes more than 30 seconds...
curl https://www.npmjs.org/install.sh | sh
@lsocrate
lsocrate / Bitmask.js
Last active August 29, 2015 14:08
Simple bitmasking
/**
* Bitmask class
* @param {string[]} values - Array of names of masked properties
*/
function Bitmask (values) {
this.mask = 0;
this.map = values.reduce(function (map, name, idx) {
map[name] = Math.pow(2, idx);
return map;
}, {});

Keybase proof

I hereby claim:

  • I am lsocrate on github.
  • I am lsocrate (https://keybase.io/lsocrate) on keybase.
  • I have a public key whose fingerprint is B638 0837 810E DC94 9202 227C F326 094F 0041 9C7E

To claim this, I am signing this object:

:+1:
:-1:
:airplane:
:art:
:bear:
:beer:
:bike:
:bomb:
:book:
:bulb:
@lsocrate
lsocrate / Array.js
Created May 29, 2012 17:22
Extending javascript Global Objects
Array.prototype.popRandom = function() {
return this.splice(Math.ceil(Math.random() * (this.length - 1)), 1)[0];
};