Skip to content

Instantly share code, notes, and snippets.

View subfuzion's full-sized avatar

Tony Pujals subfuzion

View GitHub Profile
@subfuzion
subfuzion / node-assessement.md
Last active March 19, 2021 10:03
Node.js Assessment

A few questions for quickly assessing candidate's Node.js skill level

  1. Write a function that simulates an asynchronous I/O function call. The function should be called ping. It should accept one argument called delay that will determine how many seconds before the function will call back with a response (pong). If no argument is provided, it should call back immediately. If the argument is greater than 3, it should call back with an error.
function ping(delay, callback) {
 // if delay is not provided, it should default to 0
 if (typeof delay === 'function') {
   callback = delay;
   delay = 0;
@subfuzion
subfuzion / printmap.go
Created May 31, 2016 23:15
Go print map
for key, val := range env {
s := fmt.Sprintf("%s=%s\n", key, val)
w.Write([]byte(s))
}
@subfuzion
subfuzion / tryerror.js
Created May 17, 2016 17:10
Await with error
/* eslint-disable no-constant-condition, no-console, babel/no-await-in-loop */
import 'babel-polyfill'
import 'source-map-support/register'
function echo(i, badModulus = 3) {
return new Promise((resolve, reject) => {
setTimeout(() => {
if (i % badModulus === 0) {
return reject(new Error('boom'))
}
@subfuzion
subfuzion / install-go.md
Last active June 11, 2023 17:44
Installing go

Download

$ wget https://storage.googleapis.com/golang/go1.6.2.linux-amd64.tar.gz

Unarchive it

$ VERSION=1.6.2
$ OS=linux
$ ARCH=amd64
@subfuzion
subfuzion / addr.sh
Last active May 5, 2016 06:45
Get container address
addr() {
service=$1
containerport=$2
file=${3:-"docker-compose.yml"}
echo $(docker-machine ip $(docker-machine active)):$(docker-compose -f $file port $service $containerport | cut -d ':' -f 2)
}
@subfuzion
subfuzion / ubuntu-setup-checklist.md
Last active May 4, 2023 13:03
Ubuntu set up checklist
@subfuzion
subfuzion / .bashrc
Created March 25, 2016 15:18
Docker Machine & Compose: Get IP and PORT
function addr {
service=$1
containerport=$2
file=${3:-"docker-compose.yml"}
echo $(docker-machine ip $(docker-machine active)):$(docker-compose -f $file port $service $containerport | cut -d ':' -f 2
}
@subfuzion
subfuzion / .tmux.conf
Last active August 22, 2023 15:33
My .tmux.conf for tmux 2.1 (with fixes for mouse breakage)
# Inspirations:
# http://mutelight.org/practical-tmux
# http://zanshin.net/2013/09/05/my-tmux-configuration/
# http://files.floriancrouzat.net/dotfiles/.tmux.conf
# http://stackoverflow.com/questions/9628435/tmux-status-bar-configuration
# https://github.com/Lokaltog/powerline
# https://github.com/remiprev/teamocil
# http://superuser.com/questions/74492/whats-the-best-prefix-escape-sequence-for-screen-or-tmux
# http://blog.hawkhost.com/2010/07/02/tmux-%E2%80%93-the-terminal-multiplexer-part-2/
#
@subfuzion
subfuzion / readfile1.js
Created March 20, 2016 00:22
promisified fs.readFile
'use strict';
var promisify = require('promisify-lite');
var fs = require('fs');
fs = promisify(fs);
let f = require('path').join(__dirname, './file.txt');
fs.readFileAsync(f, 'utf8')
@subfuzion
subfuzion / config.yml
Last active March 17, 2016 00:47
Config
version: "2"
services:
voting-app:
image: docker/example-voting-app-voting-app
ports:
- "80:80"
result-app:
image: docker/example-voting-app-result-app
ports: