Skip to content

Instantly share code, notes, and snippets.

Avatar

Tiago Ferreira Tiagojdferreira

View GitHub Profile
@gvergnaud
gvergnaud / extends-in-typescript.ts
Last active Jun 27, 2021
How does the extends keyword work in typescript. Interactive playground: https://bit.ly/2XdCEfn
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
gvergnaud / Promises-under-the-hood.md
Last active Jul 18, 2021
Promises, under the hood.
View Promises-under-the-hood.md

Promises, under the hood

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

  new Promise((resolve, reject) => {
    ...
    resolve(someValue)
  })

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

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

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

Reference

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

1. Check the current kernel version

$ uname -r 
@gvergnaud
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 : https://github.com/zenparsing/es-observable
// In addition, some features like map, scan, filter ...
import { compose } from 'ramda'
class Observable {
constructor(f) {
this.f = f
}
@bryanrite
bryanrite / safe.md
Last active Sep 25, 2021
Safe Postgres Operations on High Volume Tables
View safe.md

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

Safe

  • 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
PadreZippo / css
Last active Mar 28, 2021
iframes with constant aspect ratios
View css
.ratio-16-9,
.ratio-16-10,
.ratio-square {
display: block;
position: relative;
width: 100%;
height: 0;
}
.ratio-16-9 {
@Chaser324
Chaser324 / GitHub-Forking.md
Last active Sep 28, 2021
GitHub Standard Fork & Pull Request Workflow
View GitHub-Forking.md

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

View README.md

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
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: https://www.w3schools.com/cssref/css_colors.asp
// Use it as you please, 'cuz you can't, like, own a color, man.
const CSS_COLOR_NAMES = [
"AliceBlue",
"AntiqueWhite",
@jt
jt / merge.md
Created Aug 23, 2011
Merge a forked gist
View merge.md

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.github.com/1163142.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://gist.github.com/1164196.git