Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
[object Object]

ᴙɘɘᴙgYmɘᴙɘj reergymerej

💭
[object Object]
View GitHub Profile
@reergymerej
reergymerej / bfs-dfs.js
Last active Feb 15, 2020
simple bfs/dfs comparison
View bfs-dfs.js
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())
View farm2.js
function Andy(animal) {
switch (animal.type) {
case 'meerkat':
Bob(animal);
break;
case 'ostrich':
Carol(animal);
break;
case 'snake':
Donald(animal);
View farm.js
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 Nov 29, 2015
ubuntu 15.10 reboot
View reboot.md

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

View brain teaser
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 Aug 29, 2015
Github-flavored Markdown CSS
View github-md
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 Apr 30, 2014
This example shows that private variables created with module pattern may not be as private as you think.
View module-pattern-whoopsie
var foo = (function () {
// create a private variable
var priv = [];
// expose getter/setter
return {
getPriv: function () {
return priv;
},
@reergymerej
reergymerej / gist:9284488
Last active Aug 29, 2015
bitwise not vs. traditional indexOf
View gist:9284488
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
View gist:5131118
// 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){
You can’t perform that action at this time.