Skip to content

Instantly share code, notes, and snippets.

View rafaelbeckel's full-sized avatar
🦀

Rafael Beckel rafaelbeckel

🦀
View GitHub Profile

Launch Sublime Text 2 from the Mac OS X Terminal

Sublime Text 2 ships with a CLI called subl (why not "sublime", go figure). This utility is hidden in the following folder (assuming you installed Sublime in /Applications like normal folk. If this following line opens Sublime Text for you, then bingo, you're ready.

open /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl

You can find more (official) details about subl here: http://www.sublimetext.com/docs/2/osx_command_line.html

Installation

@rafaelbeckel
rafaelbeckel / readvar.sh
Created March 17, 2018 20:11
Bash Script - Read variable from .env file
#!/bin/bash
read_var() {
VAR=$(grep $1 $2 | xargs)
IFS="=" read -ra VAR <<< "$VAR"
echo ${VAR[1]}
}
MY_VAR=$(read_var MY_VAR .env)
@rafaelbeckel
rafaelbeckel / Eng-manager.md
Created May 3, 2019 02:43
Engineering Manager Role Description

From JimDabell's comment on Hacker News: https://news.ycombinator.com/item?id=18355568

Off the top of my head, these are the kinds of things engineering managers often have to deal with:

Hiring:

  • Writing job specs.
  • Dealing with recruiters
  • Reading CVs/résumés
  • Interviews
@rafaelbeckel
rafaelbeckel / LICENSE
Created May 3, 2019 15:43 — forked from kjlubick/LICENSE
Exports a THREE.js scene mesh to STL, making it suitable for 3d printing
The MIT License
Copyright © 2010-2016 three.js authors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@rafaelbeckel
rafaelbeckel / GLSL_contrast
Created May 22, 2019 19:06 — forked from yiwenl/GLSL_contrast
Greyscale in glsl
float contrast(float mValue, float mScale, float mMidPoint) {
return clamp( (mValue - mMidPoint) * mScale + mMidPoint, 0.0, 1.0);
}
float contrast(float mValue, float mScale) {
return contrast(mValue, mScale, .5);
}
vec3 contrast(vec3 mValue, float mScale, float mMidPoint) {
return vec3( contrast(mValue.r, mScale, mMidPoint), contrast(mValue.g, mScale, mMidPoint), contrast(mValue.b, mScale, mMidPoint) );
@rafaelbeckel
rafaelbeckel / gist:67a55b28961df538ce4cdc515482f058
Created September 19, 2019 23:14
JS Number between function
Number.prototype.between = (min, max) => this >= min && this <= max;
/*
The MIT License (MIT)
Copyright (c) 2014 Ismael Celis
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
@rafaelbeckel
rafaelbeckel / golang_new_project.sh
Created January 30, 2020 03:03
Create new Golang project and Github repository with one single command
# put that in your .bash_profile
function ng() {
mkdir $GOPATH/src/github.com/rafaelbeckel/$1 &&
cd $GOPATH/src/github.com/rafaelbeckel/$1 &&
git init &&
curl -u 'rafaelbeckel' https://api.github.com/user/repos -d "{\"name\":\"$1\", \"private\":true, \"gitignore_template\": \"Go\" }" &&
git remote add origin https://github.com/rafaelbeckel/$1
&& git pull origin master
&& touch main.go
@rafaelbeckel
rafaelbeckel / tail_recursion.py
Last active February 25, 2020 10:02
A simple tail recursive class to overcome Python's recursion limit
"""
Implements tail recursion decorator to overcome Python's recursive limit.
This is a simple version that supports single-loop recursion functions like
fibonacci or factorial. There is also a more complex decorator with support
for branching published here:
https://gist.github.com/rafaelbeckel/9849184c5a8e7832b659e3c0e3ee7d3e
Usage:
------
@rafaelbeckel
rafaelbeckel / tail_recursion_with_branching.py
Created February 25, 2020 09:58
A more powerful version of the tail recursion decorator with branching support
from functools import wraps
from collections import deque
"""
Implements tail recursion decorator to overcome Python's recursive limit.
This is similar to my previous, simpler one:
https://gist.github.com/rafaelbeckel/4ed8d7822d22cf6fe4103cc08b19621b
The difference of this version is that it now adds support for stacking up