Skip to content

Instantly share code, notes, and snippets.

@seivan
seivan / meta-tags.md
Created May 29, 2020 13:42 — forked from kevinSuttle/meta-tags.md
List of Usable HTML Meta and Link Tags
@seivan
seivan / .bashrc
Created May 27, 2020 11:36 — forked from zaps166/.bashrc
Display Git commit hash and branch name and enable git completions
getGitInfo()
{
checksum=$(git rev-parse --short HEAD 2> /dev/null)
branch=$(git symbolic-ref --short HEAD 2> /dev/null)
if [ ! -z $branch ] && [ ! -z $checksum ]; then
echo -e " ($branch $checksum)"
elif [ ! -z $checksum ]; then
echo -e " ($checksum)"
elif [ ! -z $branch ]; then
echo -e " ($branch)"
@seivan
seivan / _readme.md
Created April 30, 2020 07:42 — forked from andywer/_readme.md
React - Functional error boundaries

React - Functional error boundaries

Thanks to React hooks you have now happily turned all your classes into functional components.

Wait, all your components? Not quite. There is one thing that can still only be implemented using classes: Error boundaries.

There is just no functional equivalent for componentDidCatch and deriveStateFromError yet.

Proposed solution

@seivan
seivan / foo.tsx
Created April 16, 2020 07:26 — forked from OliverJAsh/foo.tsx
TypeScript React HOC using `forwardRef`
import * as React from 'react';
import { Component, ComponentClass, createRef, forwardRef, Ref } from 'react';
const myHoc = <ComposedComponentProps extends {}>(
ComposedComponent: ComponentClass<ComposedComponentProps>,
) => {
type ComposedComponentInstance = InstanceType<typeof ComposedComponent>;
type WrapperComponentProps = ComposedComponentProps & {
wrapperComponentProp: number;
@seivan
seivan / task1.exs
Created May 11, 2017 08:51 — forked from moklett/task1.exs
Elixir Task - Crash Handling
# This demonstrates that, when using async/await, a crash in the task will crash the caller
defmodule Tasker do
def good(message) do
IO.puts message
end
def bad(message) do
IO.puts message
raise "I'm BAD!"
end
@seivan
seivan / bb.js
Created December 26, 2016 01:43 — forked from stephantabor/bb.js
Bluebird .each vs .mapSeries vs .map
var Promise = require('bluebird');
var funcs = Promise.resolve([500, 100, 400, 200].map((n) => makeWait(n)));
funcs
.each(iterator) // logs: 500, 100, 400, 200
.then(console.log) // logs: [ [Function], [Function], [Function], [Function] ]
funcs
.mapSeries(iterator) // logs: 500, 100, 400, 200
/*:
## Phone Words
Generate a collection of words that can be represented by a given phone number. If a phone number contains the digits `1` or `0` then split up the phone number and find the words for each of the substrings as long as each substring has more than one digit. Non-keypad characters can be ignored. Optionally, filter out words so that only dictionary words are present in the result.
╔═════╦═════╦═════╗
║ 1 ║ 2 ║ 3 ║
║ ║ abc ║ def ║
╠═════╬═════╬═════╣
║ 4 ║ 5 ║ 6 ║
@seivan
seivan / A_Promise.swift
Created September 25, 2016 18:28 — forked from ChristianKienle/A_Promise.swift
simplest Promise framework possible?
public struct Promise<T> {
typealias Fulfiller = (T) -> (Void)
typealias Rejecter = (Void) -> (Void)
typealias Resolver = (_ fulfill: @escaping Fulfiller, _ reject: @escaping Rejecter) -> (Void)
let resolver: Resolver
init(_ resolver: @escaping Resolver){
self.resolver = resolver
}
func then<U>(_ execute: @escaping ((T) -> U)) -> Promise<U> {
return Promise<U>({(fulfill, reject) in
@seivan
seivan / gitflow-breakdown.md
Created August 5, 2016 12:27 — forked from JamesMGreene/gitflow-breakdown.md
A comparison of using `git flow` commands versus raw `git` commands.

Initialize

gitflow git
git flow init git init
git commit --allow-empty -m "Initial commit"
git checkout -b develop master

Connect to the remote repository

@seivan
seivan / version.sh
Created July 20, 2016 12:56 — forked from osteslag/version.sh
Script for managing build and version numbers using git and agvtool. See link in comments below.
#!/bin/sh
# Script for managing build and version numbers using git and agvtool.
# Change log:
# v1.0 18-Jul-11 First public release.
# v1.1 29-Sep-12 Launch git, agvtool via xcrun.
version() {