Skip to content

Instantly share code, notes, and snippets.

mislav / gh-rename-master
Last active Feb 3, 2021
Rename the default branch of a repository using GitHub CLI
View gh-rename-master
# Usage: gh-rename-master <newbranch> [<remote>]
# Renames the "master" branch of the current repository both locally and on GitHub.
# dependencies: GitHub CLI v0.10
set -e
View little-vdom.js
export const h=(t,p,...c)=>({t,p,c,k:p&&p.key})
export const render=(e,d,t=d.t||(d.t={}),p,r,c,m,y)=>
// arrays,p)=>render(e,d,t.o&&t.o[p])):
// components{children:e.c},e.p),e.s=t.s||{},t=>
// create notes
m=t.d||(e.t?document.createElement(e.t):new Text(e.p)),
// diff props
LeeBergstrand / Linuxbrew_Config.yml
Last active Jul 13, 2019
CircleCi config for homebrew
View Linuxbrew_Config.yml
version: 2
working_directory: ~/repo
machine: true
- checkout
jherax / is-private-mode.js
Last active Apr 20, 2021
Detect if the browser is running in Private mode (Promise based)
View is-private-mode.js
* Lightweight script to detect whether the browser is running in Private mode.
* @returns {Promise<boolean>}
* Live demo:
* @see
* This snippet uses Promises. If you want to run it in old browsers, polyfill it:
* @see
petemcw /
Last active Oct 22, 2020
Mac OS X Docker Instructions using Dinghy

Docker Installation

A great way to get Docker running smoothly on OS X is to use the awesome project Dinghy. It is basically:

Docker on OS X with batteries included, aimed at making a more pleasant local development experience. Runs on top of docker-machine.

Some of the benefits are:

  • Faster volume sharing using NFS rather than built-in virtualbox/vmware file shares
  • Filesystem events work on mounted volumes
Tusko / functions.php
Last active Dec 15, 2020
WP Ajax search (ACF included)
View functions.php
/* Wordpress Custom Search by title, ACF, post_meta */
// Wordpress ?s= redirect to /search/
function wpa_search_redirect() {
global $wp_rewrite;
if (!isset($wp_rewrite) || !is_object($wp_rewrite) || !$wp_rewrite->using_permalinks()) { return; }
$search_base = $wp_rewrite->search_base;
if (is_search() && !is_admin() && strpos($_SERVER['REQUEST_URI'], "/{$search_base}/") === false) {
wp_redirect(home_url("/{$search_base}/" . urlencode(get_query_var('s'))));
iest /
Last active Apr 29, 2021
Setting up environment variables with various shells

What the hell are environment variables?

They're just variables you set on your system that various programs/processes can read. A fairly standard example in javascript circles would be setting your NODE_ENV variable to "production" or "development", altering how node code is executed on your system (for example showing more debug messaging when in development).

With most shells there's a way to set them for the current session, and a way to set them for all sessions. The following is meant to be a guide on how to set env vars in the various shells.

Bash (The default shell on OSX)

Setting for the session:

patik /
Last active Apr 23, 2021
How to squash commits in git

Squashing Git Commits

The easy and flexible way

This method avoids merge conflicts if you have periodically pulled master into your branch. It also gives you the opportunity to squash into more than 1 commit, or to re-arrange your code into completely different commits (e.g. if you ended up working on three different features but the commits were not consecutive).

Note: You cannot use this method if you intend to open a pull request to merge your feature branch. This method requires committing directly to master.

Switch to the master branch and make sure you are up to date:

hlecuanda /
Last active May 1, 2021
Git Squash alias, from amazingly clean explanation on stackoverflow

From This other answer on the same thread

Based on Chris Johnsen's answer:

I added this line to the [alias] section of my git config file (~/.gitconfig):

squash = "!f(){ git reset --soft HEAD~${1} && git commit --edit -m\"$(git log --format=%B --reverse HEAD..HEAD@{1})\"; };f"

domenic /
Last active Apr 26, 2021
Auto-deploying built products to gh-pages with Travis

Auto-deploying built products to gh-pages with GitHub Actions

This is a set up for projects which want to check in only their source files, but have their gh-pages branch automatically updated with some compiled output every time they push.

A file below this one contains the steps for doing this with Travis CI. However, these days I recommend GitHub Actions, for the following reasons:

  • It is much easier and requires less steps, because you are already authenticated with GitHub, so you don't need to share secret keys across services like you do when coordinate Travis CI and GitHub.
  • It is free, with no quotas.
  • Anecdotally, builds are much faster with GitHub Actions than with Travis CI, especially in terms of time spent waiting for a builder.