Skip to content

Instantly share code, notes, and snippets.


Tiago Ferreira Tiagojdferreira

View GitHub Profile
gvergnaud / extends-in-typescript.ts
Last active Jun 27, 2021
How does the extends keyword work in typescript. Interactive playground:
View extends-in-typescript.ts
* # How does `A extends B` work in TypeScript?
* If you think about types in terms of sets containing possible values,
* the `string` type is the set of all possible strings,
* the `number` type is the set of all possible numbers,
* the `'hello'` type is a set containing only the string 'hello'
* and the `2` type is a set containing only the number 2.
* Then you can think of `A extends B` as asking this question:
gvergnaud /
Last active Jul 18, 2021
Promises, under the hood.

Promises, under the hood

You all know that to create a new Promise you need to define it this way:

  new Promise((resolve, reject) => {

You are passing a callback that defines the specific behavior of your promise.

ipbastola /
Last active Sep 27, 2021
Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64

Safest way to clean up boot partition - Ubuntu 14.04LTS-x64, Ubuntu 16.04LTS-x64


Case I: if /boot is not 100% full and apt is working

1. Check the current kernel version

$ uname -r 
gvergnaud / Observable.js
Last active Sep 6, 2019
Test implementation of the Observable spec.
View Observable.js
// Just an attempt to implement the Observable spec, defined here :
// In addition, some features like map, scan, filter ...
import { compose } from 'ramda'
class Observable {
constructor(f) {
this.f = f
bryanrite /
Last active Sep 25, 2021
Safe Postgres Operations on High Volume Tables

Originally taken from: Braintree Article and expanded on by me.


  • Add a new column
  • Drop a column
  • Rename a column
  • Add an index concurrently (Example), Note: it will still take a long time to run the migration, but it won't write-lock the table.
  • Drop a constraint (for example, non-nullable)
  • Add a default value to an existing column
PadreZippo / css
Last active Mar 28, 2021
iframes with constant aspect ratios
View css
.ratio-square {
display: block;
position: relative;
width: 100%;
height: 0;
.ratio-16-9 {
Chaser324 /
Last active Sep 28, 2021
GitHub Standard Fork & Pull Request Workflow

Whether you're trying to give back to the open source community or collaborating on your own projects, knowing how to properly fork and generate pull requests is essential. Unfortunately, it's quite easy to make mistakes or not know what you should do when you're initially learning the process. I know that I certainly had considerable initial trouble with it, and I found a lot of the information on GitHub and around the internet to be rather piecemeal and incomplete - part of the process described here, another there, common hangups in a different place, and so on.

In an attempt to coallate this information for myself and others, this short tutorial is what I've found to be fairly standard procedure for creating a fork, doing your work, issuing a pull request, and merging that pull request back into the original project.

Creating a Fork

Just head over to the GitHub page and click the "Fork" button. It's just that simple. Once you've done that, you can use your favorite git client to clone your repo or j


Git hooks for better pivotal integration:

  • pre-commit:
    • prevents commiting on a branch that is not suffixed by an issue number. Some special branches (develop, master) and hotfixes are not constrained
    • lints modified python files and exits upon non correctly formatted modules
    • other formats (js, scss) have pending code that is not currently called as the workflow for front code is not clear
  • prepare-commit-msg: prepend issue number to commit message if it's missing and if it is set in the branch name (see pre-commit hook)
  • post-checkout: [optional] automatically update submodules when checkouting a branch (requires to define the AUTO_SUBMODULE_UPDATE environment variable)

For easy setup:

bobspace / css_colors.js
Last active Sep 28, 2021
All of the CSS Color names as an array in javascript.
View css_colors.js
// CSS Color Names
// Compiled by @bobspace.
// A javascript array containing all of the color names listed in the CSS Spec.
// The full list can be found here:
// Use it as you please, 'cuz you can't, like, own a color, man.
jt /
Created Aug 23, 2011
Merge a forked gist

If someone forks a gist and you'd like to merge their changes. Do this:

  1. clone your repo, I use the name of the gist

     git clone git:// gist-1163142
  2. add a remote for the forked gist, I'm using the name of my fellow developer

     git remote add aaron git://