Skip to content

Instantly share code, notes, and snippets.

View tiagojdf's full-sized avatar

Tiago Ferreira tiagojdf

View GitHub Profile
@gvergnaud
gvergnaud / extends-in-typescript.ts
Last active June 27, 2021 15:59
How does the extends keyword work in typescript. Interactive playground: https://bit.ly/2XdCEfn
/**
* # 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 August 27, 2024 00:29
Promises, under the hood.

Promises, under the hood

Everyone knows that to create a new Promise, you need to define it this way:

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

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

@ipbastola
ipbastola / clean-up-boot-partition-ubuntu.md
Last active August 16, 2024 13:39
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

Reference

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

1. Check the current kernel version

$ uname -r 
@gvergnaud
gvergnaud / Observable.ts
Last active September 9, 2022 23:04
Test implementation of the Observable spec.
export type Option<T> =
| { readonly type: 'some'; readonly value: T }
| { readonly type: 'none' };
export const none: Option<never> = { type: 'none' };
export const some = <T>(value: T): Option<T> => ({ type: 'some', value });
const compose =
@bryanrite
bryanrite / safe.md
Last active October 24, 2024 16:27
Safe Postgres Operations on High Volume Tables

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 / embed.html
Last active September 30, 2023 17:10
iframes with constant aspect ratios
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<!-- This iframe will always fill the parent width, but will remain at 16:9 aspect ratio -->
<div class="ratio-16-9">
<iframe class="ratio-inner" src="https://sketchfab.com/models/{{model_id}}/embed"></iframe>
@Chaser324
Chaser324 / GitHub-Forking.md
Last active November 14, 2024 08:32
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

@marchelbling
marchelbling / README.md
Last active February 13, 2020 01:00
git hooks

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 October 12, 2024 17:02
All of the CSS Color names in a big javascript object.
// CSS Color Names
// Compiled by @bobspace.
//
// A javascript object containing all of the color names listed in the CSS Spec.
// This used to be a big array, but the hex values are useful too, so now it's an object.
// If you need the names as an array use Object.keys, but you already knew that!
//
// 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.
@jt
jt / merge.md
Created August 23, 2011 18:47
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.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