Skip to content

Instantly share code, notes, and snippets.

View reergymerej's full-sized avatar
💭
[object Object]

ᴙɘɘᴙgYmɘᴙɘj reergymerej

💭
[object Object]
View GitHub Profile
@reergymerej
reergymerej / bfs-dfs.js
Last active February 15, 2020 22:26
simple bfs/dfs comparison
const search = nextNode => (root, visit) => {
let list = [root]
while (list.length) {
const node = nextNode(list)
visit(node)
list = list.concat(node.children)
}
}
const bfs = search(list => list.shift())
function Andy(animal) {
switch (animal.type) {
case 'meerkat':
Bob(animal);
break;
case 'ostrich':
Carol(animal);
break;
case 'snake':
Donald(animal);
function Andy() {
while (1) {
var animal = catchAnAnimal();
switch (animal.type) {
case 'meerkat':
Bob(animal);
break;
case 'ostrich':
Carol(animal);
@reergymerej
reergymerej / reboot.md
Last active November 29, 2015 02:38
ubuntu 15.10 reboot

Starting Over with Ubuntu 15.10

Here's a TODO list to help you get back up and running.

  1. setup software center source, select best server

     sudo apt-get update
    
  2. download chrome, uname -a to see architecture

var a = [{ foo: 'bar' }];
var method = function (arr) {
var local = arr.slice();
console.log(local === arr);
local.forEach(function (obj) {
console.log(coll === arr);
@reergymerej
reergymerej / github-md
Last active August 29, 2015 14:06
Github-flavored Markdown CSS
body code,body tt
{
background-color:#f8f8f8;
border:1px solid #ddd;
border-radius:3px;
margin:0 2px;
padding:0 5px;
}
body code
@reergymerej
reergymerej / module-pattern-whoopsie
Created April 30, 2014 19:30
This example shows that private variables created with module pattern may not be as private as you think.
var foo = (function () {
// create a private variable
var priv = [];
// expose getter/setter
return {
getPriv: function () {
return priv;
},
@reergymerej
reergymerej / gist:9284488
Last active August 29, 2015 13:56
bitwise not vs. traditional indexOf
for (var i = 5; i >= -5; i--) {
console.log('~' + i + ' === '
+ ~i + ' == ' + (~i ? true : false));
}
// ~5 === -6 == true
// ~4 === -5 == true
// ~3 === -4 == true
// ~2 === -3 == true
// ~1 === -2 == true
// import the http module
var http = require('http');
// create a server
var server = http.createServer();
// define a handler for the 'request' event, triggered
// when a client makes a request of the server -
// request and response objects will be passed to the handler
server.on('request', function(req, res){