Skip to content

Instantly share code, notes, and snippets.

View jhbabon's full-sized avatar
🦊

Juan Hernández jhbabon

🦊
View GitHub Profile
@jhbabon
jhbabon / option.ts
Created February 11, 2022 12:58
Result and Option types in TypeScript
/**
* Type Option represents an optional value: every option is either Some and contains a value,
* or None, and does not.
*
* The main idea behind Option is to prevent the abuse of null|undefined through the code
* and to enforce safe value checking through the type system. The absence of something is
* explicit thanks to None.
*
* @example Using basic is* methods
*
@jhbabon
jhbabon / Autoloader.php
Created February 22, 2011 17:00
Very simple autoloader class
<?php
/**
* Very simple autoloader class
*
* This class loads another classes following the Zend naming convention:
* - Class name: Foo_Bar
* - File name: Foo/Bar.php
*
* Example of use:
@jhbabon
jhbabon / env-vars.ts
Created September 18, 2020 08:08
A small environment variables parser in TypeScript
import { env } from 'process'
function isNumber(n: unknown): n is number {
if (typeof n !== 'number' || Number.isNaN(n)) {
return false
}
return true
}
@jhbabon
jhbabon / scout-history.zsh
Created June 3, 2020 08:53
Filter ZSH history with scout
setopt hist_ignore_all_dups
# based on: https://gist.github.com/dohq/9b97e07c865bb608108dd254b5e32fea
function scout-history() {
BUFFER=$(history -n -r 1 | scout --inline --lines=10 --search="$LBUFFER")
CURSOR=$#BUFFER
zle clear-screen
}
zle -N scout-history
bindkey '^r' scout-history
@jhbabon
jhbabon / vscout.vim
Last active December 12, 2018 10:10
scout.vim visual selection
" see: http://vimcasts.org/episodes/search-for-the-selected-text/
function! s:VScoutSearch(cmdtype)
let temp = @s
norm! gv"sy
let s:selection = @s
let @s = temp
if a:cmdtype == 'files'
call scout#files#run({ 'search': s:selection })
endif
@jhbabon
jhbabon / git_tar.sh
Created June 13, 2012 09:12
archive a git repo
# link: http://linssen.me/entry/archive-your-git-repo-easily/
git archive HEAD | gzip > $PWD\.tar\.gz

Keybase proof

I hereby claim:

  • I am jhbabon on github.
  • I am jhbabon (https://keybase.io/jhbabon) on keybase.
  • I have a public key ASAjX5xO3GLE4GUqMipG9mhji5tjhMfAFM9MVfe1ZdTyiAo

To claim this, I am signing this object:

@jhbabon
jhbabon / 2.1.2-railsexpress
Last active June 27, 2017 11:04
ruby-build recipe for 2.1.2-railsexpress
build_package_reconfigure() {
test -f configure || autoconf
}
build_package_patch_ruby_railsexpress() {
fetch_git rvm-patchsets git://github.com/skaes/rvm-patchsets.git master
patch -p1 < rvm-patchsets/patches/ruby/2.1.2/railsexpress/01-zero-broken-tests.patch
patch -p1 < rvm-patchsets/patches/ruby/2.1.2/railsexpress/02-improve-gc-stats.patch
patch -p1 < rvm-patchsets/patches/ruby/2.1.2/railsexpress/03-display-more-detailed-stack-trace.patch
@jhbabon
jhbabon / 1.9.3-p484-railsexpress
Created November 25, 2013 07:58
rbenv recipe to install 1.9.3-p484 with railsexpress patch
build_package_patch_ruby_railsexpress() {
fetch_git rvm-patchsets git://github.com/skaes/rvm-patchsets.git master
for p in rvm-patchsets/patches/ruby/1.9.3/p484/railsexpress/* ; do
patch -p1 < $p
done
}
install_package "yaml-0.1.4" "http://pyyaml.org/download/libyaml/yaml-0.1.4.tar.gz#36c852831d02cf90508c29852361d01b"
install_package "ruby-1.9.3-p484" "http://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p484.tar.gz#8ac0dee72fe12d75c8b2d0ef5d0c2968" patch_ruby_railsexpress autoconf standard
@jhbabon
jhbabon / 2.1.0-railsexpress
Last active January 2, 2016 02:48
rbenv recipe to install 2.1.0 with railsexpress patch
build_package_reconfigure() {
test -f configure || autoconf
}
build_package_patch_ruby_railsexpress() {
fetch_git rvm-patchsets git://github.com/skaes/rvm-patchsets.git master
patch -p1 < rvm-patchsets/patches/ruby/2.1.0/railsexpress/01-current-2.1.1-fixes.patch
patch -p1 < rvm-patchsets/patches/ruby/2.1.0/railsexpress/02-zero-broken-tests.patch
patch -p1 < rvm-patchsets/patches/ruby/2.1.0/railsexpress/03-improve-gc-stats.patch