Skip to content

Instantly share code, notes, and snippets.

View oskosk's full-sized avatar

Osk oskosk

  • Automattic
  • Buenos Aires, Argentina
View GitHub Profile
@oskosk
oskosk / gist:7d96cf6cad8ccf1bb72a8fdba5d78b71
Created March 27, 2017 11:45
Build Jetpack Admin Page (React based) with docker
docker run --rm -it -v $(pwd):/jetpack -w /jetpack --name jetpack node:6 /bin/bash -c "rm /usr/local/bin/yarn && apt-get update && apt-get -y install php5-cli && curl -s -o- -L https://yarnpkg.com/install.sh | bash -s -- --version 0.17.9 && PATH=/root/.yarn/bin:$PATH bash -c 'yarn distclean && yarn build'"
#!/bin/bash
if [ -z "$1" ]
then
echo "Please provide a filename/dirname from calypso as first parameter"
exit
fi
if [ -z "$2" ]
then
echo "Please provide a destination directory"
@oskosk
oskosk / .eslintrc
Created March 18, 2017 15:07
.eslintrc
{
"parser": "babel-eslint",
"env": {
"browser": true,
"es6": true,
"mocha": true,
"node": true
},
"ecmaFeatures": {
"jsx": true,
@oskosk
oskosk / index.js
Created September 17, 2015 22:28
babel no funcionando
require("babel/register");
setTimeout(()=> {
console.log("hola");
});
@oskosk
oskosk / gist:ff6d75e423a554701e44
Created June 7, 2015 18:47
Shell - Three-Fingered Claw technique
# include these first in your scripts
yell() { echo "$0: $*" >&2; }
die() { yell "$*"; exit 111; }
try() { "$@" || die "cannot $*"; }
// $ npm install shelljs
//
require("shelljs/global");
var scripts = [ "./script1.sh", "./script2.sh", "./script3.sh" ];
scripts.forEach(function(s) {
// Este exec es exportado en el scope global por shelljs
// Es sincrónico.
if (exec(s).code !== 0) {

Whether you use 2 spaces or 4 spaces, there are a few simple things that can make your node.js code easier to read. We've been using them in all the hapi modules for over 4 years now to great results. This list is by no means complete but it highlights the most useful elements that will give you immediate value in reducing bugs.

Required modules

JavaScript makes is harder than most languages to know where variables are coming from. Variables assigned required modules are particularly important because they represent a singleton object shared with the entire application. There are also globals and module globals, along with function variables and arguments.

Traditionally, variables starting with an uppercase letter represent a class that must be instantiated using new. This was an important semantic in the early days of JavaScript but at this point, if you don't know Date requires new Date() you are probably very new. We have adopted CamelCase variable names for all module global variables which a

@oskosk
oskosk / gist:d43966f78ca3a3ffed53
Created January 26, 2015 14:36
.bash_aliases. Bash prompt with git support
# PUTH THIS IN ~/.bash_aliases
# Customize BASH PS1 prompt to show current GIT repository and branch.
# by Mike Stewart - http://MediaDoneRight.com
# SETUP CONSTANTS
# Bunch-o-predefined colors. Makes reading code easier than escape sequences.
# I don't remember where I found this. o_O
# Reset
Color_Off="\[\033[0m\]" # Text Reset
var irc = require('irc');
var client = new irc.Client('chat.freenode.net', 'osk-bot2', {
channels: ['#taringa'],
});
client.addListener('message', function (from, to, message) {
console.log("From %s: %s", from, message);
if (message === "osk-bot go!" && from === "osk") {
client.say("#taringa", "Roger that !");
@oskosk
oskosk / gist:fb18207b2f878ef05e7a
Last active August 29, 2015 14:13
Git extras how-to

#Git extras how-to

Transcript from http://vimeo.com/45506445

Installation on Ubuntu

sudo apt-get install git-extras

Git setup Overview