Skip to content

Instantly share code, notes, and snippets.

View taktran's full-sized avatar

Tak Tran taktran

View GitHub Profile
@taktran
taktran / index.js
Created October 25, 2018 12:00
Infinite loop from `unhandledRejection`
// Run this file to cause an `unhandledRejection` infinite loop
// > node index.js
// 2. Catch first unhandled promise rejection
// 4. Catch error inside unhandledRejection, causing an infinite loop
process.on('unhandledRejection', (reason, p) => {
console.log('Unhandled Rejection at:', p, 'reason:', reason);
new Promise(() => {
const b = {};
const GITHUB_TEAM_API_URL_PREFIX = 'https://api.github.com/repos/SOME_TEAM';
const githubArchiveUrl = ({ repoName, branch }) =>
`${GITHUB_TEAM_API_URL_PREFIX}/${repoName}/tarball/${branch}`;
const getGithubArchiveRedirectUrl = ({ repoName, branch, githubToken }) => {
const url = githubArchiveUrl({ repoName, branch });
return fetch(url, {
headers: {
Authorization: `token ${githubToken}`
@taktran
taktran / gmail-filters.txt
Last active October 4, 2018 20:33
Gmail filters for Github
Matches: from:(github.com) subject:(ORG_NAME)
Do this: Skip Inbox, Apply label "github"
Matches: from:(notifications@github.com) to:(EMAIL)
Do this: Apply label "github/me", Categorise as Personal
where,
ORG_NAME = Github organisation name
EMAIL = Github email address
@taktran
taktran / Api.js
Last active August 26, 2018 13:00
Unstated Api example
import React from "react";
import { Provider, Subscribe, Container } from "unstated";
import ApiService from './utils/api-service';
const DEFAULT_STATE = {
loggedIn: false,
user: {},
errors: []
};
@taktran
taktran / css-animations.md
Last active August 6, 2018 21:44
CSS Animations

Syntax

Transition property

div {
  transition: [property] [duration] [timing-function] [delay];
}
@taktran
taktran / custom-fonts.md
Last active April 27, 2023 17:15
Custom fonts

How to add custom fonts to a webpage:

  1. Generate web fonts for every browser eg, use https://www.fontsquirrel.com/tools/webfont-generator or https://transfonter.org/

  2. Add fonts to css/fonts folder or equivalent

  3. Look inside downloaded font files for a stylesheet.css or equivalent and copy the @font-face, while adjusting the file paths to match the location of the font folder

    @font-face {
      font-family: "Some font";
      src: url("css/fonts/some-font.eot");
    

src: url("css/fonts/some-font.woff") format("woff"),

@taktran
taktran / flexbox.md
Last active August 7, 2018 07:49
Flexbox cheatsheet

A quick cheatsheet for flexbox.

For a more detailed cheatsheet see something like: https://yoksel.github.io/flex-cheatsheet/.

.parent {
  display: [flex|inline-flex];
  
  /* Change direction */
  flex-direction: [row|row-reverse|column|column-reverse];
@taktran
taktran / update-indent.sh
Created May 10, 2018 13:58
Update indent of files from 4 to 2 spaces
#!/bin/bash
#
# Usage:
#
# Find all files
#
# ls -1 $PWD/*.js > files.txt
#
# Run script
#
@taktran
taktran / vba_cheatsheet.md
Last active May 9, 2018 20:24
VBA cheatsheet

Debugging

Console log

Debug.Print "Hello"

Message box

MsgBox "Hello
@taktran
taktran / snippets.cson
Created October 27, 2016 15:55
Atom snippets
# Your snippets
#
# Atom snippets allow you to enter a simple prefix in the editor and hit tab to
# expand the prefix into a larger code block with templated values.
#
# You can create a new snippet in this file by typing "snip" and then hitting
# tab.
#
# An example CoffeeScript snippet to expand log to console.log:
#