Skip to content

Instantly share code, notes, and snippets.

@beck
beck / hello.ts
Last active May 11, 2020 17:02
VS Code import woe - Cannot find module (2307)
export const msg = "hello";
@beck
beck / git-filter-folder.sh
Created April 26, 2019 19:00
git filter folder
#!/bin/bash
set -eux
# Use this script to prune away everything but `foo/bar/somedir`, resulting with only `somedir`
# in the root. Using `--subdirectory-filter` is undesireable because it hoists all the contents
# of `somedir` into the root.
mkdir -p __github-migrate__
mvplz="if [ -d $1 ]; then mv $1 __github-migrate__/; fi;"
git filter-branch -f --tree-filter "$mvplz" HEAD
@beck
beck / search-button.jsx
Created May 7, 2018 15:47
React (+react router) relative url button
import React from 'react';
import styled from 'react-emotion';
import { Link, withRouter } from 'react-router-dom';
import searchIcon from './search.svg';
const StyledLink = styled(Link)`
align-items: center;
background-color: #00A2E1;
background-image: url(${searchIcon});
@beck
beck / urlstr.js
Last active March 29, 2018 16:16
urlstr
/*
Why is this needed?
> is `url.format` broken or am I?
> https://github.com/nodejs/help/issues/1176
Would like to:
- extract this as a standalone lib
- support all spaces as options:
https://nodejs.org/api/url.html#url_url_strings_and_url_objects
@beck
beck / managing-python.md
Last active July 24, 2018 06:04
Managing Python

Managing Python

Getting Started

is everything borked?

What is the output of which python?

If /usr/bin/python then using the system python that comes with OSX. 😬

@beck
beck / recursive-char-generator.js
Created November 21, 2017 01:14
Can you nest generators?
// This is an excessively over-engneered solution for when you forget
// `node.textContent` strips all child html :)
// to run:
// node --version # v9.2.0
// npm install jsdom
// node recursive-char-generator.js
const jsdom = require("jsdom");
const { JSDOM } = jsdom;
@beck
beck / png-crush.sh
Created September 5, 2017 19:46
Crush the pngs
#!/bin/sh
# Cause stefano said: You can get them even smaller with
# http://www.advancemame.it/comp-readme.html after crushing
# it operates on the deflate compression, not the PNG image data
git ls-files | grep \.png$ | while read img
do
echo -n "$img..."
size_old=$(stat -f%z "$img")
@beck
beck / git-fixup
Created March 30, 2017 17:34
A git bin to auto fixup
#!/bin/sh
#
# git fixup - squash current changes into the last commit
#
# Stores the current the current head in 'doug/fixup'.
#
git branch -f doug/backup
git add -A
@beck
beck / fixed-bg-ios.html
Created February 17, 2017 23:36
Simulating background-attachment fixed for iOS
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
html {
background: url(http://i.imgur.com/vu9P5mN.jpg);
background-size: cover;
background-position: center;
@beck
beck / git-fixup
Last active December 2, 2016 03:26
git fixup
#!/bin/bash
#
# git fixup - squash current changes into the last commit
#
# Stores the current head in branch 'doug/fixup'.
#
git branch -f doug/fixup
git add -A