Skip to content

Instantly share code, notes, and snippets.

odewahn /
Last active Sep 9, 2021
Processing errors with Fetch API

I really liked @tjvantoll article Handling Failed HTTP Responses With fetch(). The one thing I found annoying with it, though, is that response.statusText always returns the generic error message associated with the error code. Most APIs, however, will generally return some kind of useful, more human friendly message in the body.

Here's a modification that will capture this message. The key is that rather than throwing an error, you just throw the response and then process it in the catch block to extract the message in the body:

  .then( response => {
    if (!response.ok) { throw response }
    return response.json()  //we only get here if there is no error
Darep / no-comments.js
Created May 30, 2016
Remove all comments from GitHub Pull Request
View no-comments.js
// Sometimes it's necessary to do a bit of clean-up'.js-comment-delete button'), function(el, i) {
NathanGiesbrecht / noip2.service
Last active Oct 10, 2021
Systemd Service file for dynamic ip updater
View noip2.service
# Simple Dynamic DNS Updater
# By Nathan Giesbrecht (
# 1) Install binary as described in's source file (assuming results in /usr/local/bin)
# 2) Run sudo /usr/local/bin/noip2 -C to generate configuration file
# 3) Copy this file noip2.service to /etc/systemd/system/
# 4) Execute `sudo systemctl daemon-reload`
# 5) Execute `sudo systemctl enable noip2`
# 6) Execute `sudo systemctl start noip2`
thomasklemm / active_record_sqlite_in_memory_db.rb
Created Apr 27, 2015
Awesome ActiveRecord bug report script. How to use ActiveRecord and SQLite in a Ruby script.
View active_record_sqlite_in_memory_db.rb
# Based on
# Run this script with `$ ruby my_script.rb`
require 'sqlite3'
require 'active_record'
# Use `binding.pry` anywhere in this script for easy debugging
require 'pry'
# Connect to an in-memory sqlite3 database
mads-hartmann / toggle-maximize-buffer.el
Created Aug 20, 2012
An Emacs function to temporarily make one buffer fullscreen. You can quickly restore the old window setup.
View toggle-maximize-buffer.el
(defun toggle-maximize-buffer () "Maximize buffer"
(if (= 1 (length (window-list)))
(jump-to-register '_)
(set-register '_ (list (current-window-configuration)))
;; Bind it to a key.
View tmux-cheatsheet.markdown

tmux shortcuts & cheatsheet

start new:


start new with session name:

tmux new -s myname

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

# remap prefix to Control + a
saetia / gist:1623487
Last active Oct 24, 2021
Clean Install – OS X 10.11 El Capitan
View gist:1623487

OS X Preferences

most of these require logout/restart to take effect

# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false

# Set a shorter Delay until key repeat
the-kenny / .emacs
Created Jan 1, 2010
pbcopy & pbpaste for Emacs
View .emacs
(defun copy-from-osx ()
(shell-command-to-string "pbpaste"))
(defun paste-to-osx (text &optional push)
(let ((process-connection-type nil))
(let ((proc (start-process "pbcopy" "*Messages*" "pbcopy")))
(process-send-string proc text)
(process-send-eof proc))))
(setq interprogram-cut-function 'paste-to-osx)