Skip to content

Instantly share code, notes, and snippets.

View foca's full-sized avatar

Nicolás Sanguinetti foca

View GitHub Profile
@foca
foca / gist:3148204
Created July 20, 2012 02:03
Git hook to detect if a file changed after a checkout/merge/rebase and show the diff.
#!/usr/bin/env bash
#
# Install into:
# - .git/hooks/post-merge
# - .git/hooks/post-rewrite
# - .git/hooks/post-checkout
#
# And make sure all are executable.
#
# Then change the $file appropriately. Enjoy.
@foca
foca / 0_README.md
Last active May 10, 2023 20:55
A Makefile for developing a ruby gem

A Makefile for building ruby gems

This Makefile aids in developing a ruby gem. It's pretty opinionated to my workflow, but it might be useful to you, so here it goes.

  1. Assumes you use of [gs][gs] (or [gst][gst]) for managing gemsets.
  2. Assumes you use [dep][dep] for installing dependencies. Because fuck Bundler.
  3. Assumes the directory in which the source code is located is named after the gem. So basename $(dirname $(pwd)) would return foo
@foca
foca / release
Last active March 31, 2023 14:15
Small shell script to create GitHub releases from the command line
#!/usr/bin/env bash
set -e
[ -z "$DEBUG" ] || set -x;
usage() {
echo "$0 <repo> <tag> [<release name>] [-- <asset>...]" >&2;
}
if [ "$1" = "-h" -o "$1" = "--help" ]; then
@foca
foca / itau.rb
Created March 16, 2012 18:14
Scraper to get transactions out of my bank accounts
# encoding: UTF-8
require 'mechanize'
require 'money'
require 'ostruct'
module Itau
class Session < Struct.new(:ci, :pass)
def login
login_page = agent.get(itaurl)
@foca
foca / stateful.js
Created August 25, 2012 08:23
Stateful is a simple implementation of the State Pattern for JavaScript.
// Stateful is a simple implementation of the state pattern for javascript.
//
// Read more on this design pattern here:
// -> http://sourcemaking.com/design_patterns/state
//
// Initialize Stateful by passing it an object, the name of the initial state
// (defaults to "default"), and an optional hash of interfaces that will be
// applied for each state. If these interfaces are not passed, they default to
// the object's constructor's States property. So, for example:
//

Keybase proof

I hereby claim:

  • I am foca on github.
  • I am foca (https://keybase.io/foca) on keybase.
  • I have a public key whose fingerprint is 96C6 54DB 13EA 4B40 A061 0BC5 5BC4 04A2 96AD ABC8

To claim this, I am signing this object:

@foca
foca / asset-makedepend
Created July 6, 2018 23:26
Tiny script to build GNU Make dependency files for JS `import` rules or CSS `@import` rules.
#!/usr/bin/env ruby
# Generate make dependencies by parsing a tree of JS / CSS files.
#
# Usage
# -----
#
# Add this to your Makefile:
#
# ```
@foca
foca / granola_with_root_keys.rb
Last active April 17, 2017 05:22
Use root keys and nested serializers with Granola
require "granola"
class BaseSerializer < Granola::Serializer
def to_json(**opts, &block)
root_serializer = RootSerializer.new(self)
Granola.renderer(:json).render(root_serializer, **opts, &block)
end
end
class RootSerializer < Granola::Serializer
@foca
foca / codetree-user-styles.css
Created January 5, 2017 06:45
Make CodeTree less terrible on the eyes.
/**
* CodeTree default styles are pretty terrible, and the task board
* is pretty cluttered with lots of useless things.
*
* This is a user stylesheet that makes the board pretty clean by
* removing the sidebar and top navigation.
*
* You should apply it to URLs matching `/projects/\w+/board`
*
*
@foca
foca / its-fine.md
Last active July 27, 2016 13:38
It's Fine • A Tale of Terrible Misfortune

This is a talk I gave for the Hacker Paradise Summer '16 crew at Porto, Portugal. You can find the slides at SpeakerDeck. Photo Credits at the bottom.

It's Fine • A Tale of Terrible Misfortune

I'm gonna tell you the story of a little startup. It started with an idea, as startups often do. Two passionate people saw that certain people on the internet had a problem, and they could solve it for them. For a small fee, of course.

They wanted to avoid venture capital and investors, so from the get-go they were fully bootstrapped, which meant working during their free time. But they were to be their own bosses, and finally be free and financially independent. They were excited! It was a time of joy.

They started small and lean. One of them a designer, the other a developer. They figured out the best way to get it done was to crank away, so they jumped into creating a prototype straight away.