Skip to content

Instantly share code, notes, and snippets.

View lee-dohm's full-sized avatar
😴
Taking some well-deserved naps

Lee Dohm lee-dohm

😴
Taking some well-deserved naps
View GitHub Profile
@lee-dohm
lee-dohm / esm-package.md
Created July 12, 2021 20:59 — forked from sindresorhus/esm-package.md
Pure ESM package

Pure ESM package

The package linked to from here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.
@lee-dohm
lee-dohm / sliding_session_timeout.ex
Created June 4, 2017 23:01 — forked from qertoip/sliding_session_timeout.ex
Elixir / Phoenix Sliding Session Timeout Plug
# How to use it:
#
# Plug it at the end of your :browser pipeline in your Phoenix app router.ex
# Make sure it is plugged before your session-based authentication and authorization Plugs.
#
# pipeline :browser do
# plug :accepts, ["html"]
# plug :fetch_session
# plug :fetch_flash
# plug :put_secure_browser_headers
@lee-dohm
lee-dohm / README.md
Created April 21, 2017 20:37 — forked from raysegantii/README.md
Use bootstrap-sass npm package with Phoenix's brunch
  1. install npm packages
  2. update brunch-config.js
  3. rename web/static/css/app.css to web/static/css/app.scss
  4. update web/static/css/app.scss
@lee-dohm
lee-dohm / uri.js
Created January 1, 2017 20:10 — forked from jlong/uri.js
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@lee-dohm
lee-dohm / debug.md
Created December 18, 2016 20:46
Atom-Beautify debugging information
@lee-dohm
lee-dohm / example.md
Last active October 27, 2016 06:56 — forked from ericclemmons/example.md
HTML5 <details> in GitHub

Using <details> in GitHub

Suppose you're opening an issue and there's a lot of noisy logs that may be useful.

Rather than wrecking readability, wrap it in a <details> tag!

<details>
 <summary>Summary Goes Here</summary>
#!/usr/bin/perl
# This filter changes all words to Title Caps, and attempts to be clever
# about *un*capitalizing small words like a/an/the in the input.
#
# The list of "small words" which are not capped comes from
# the New York Times Manual of Style, plus 'vs' and 'v'.
#
# 10 May 2008
# Original version by John Gruber:
@lee-dohm
lee-dohm / frame.el
Last active December 28, 2015 11:08 — forked from ieure/tiling
;; Functions to work with frames
(provide 'ime-frame)
(defun screen-usable-height (&optional display)
"Return the usable height of the display.
Some window-systems have portions of the screen which Emacs
cannot address. This function should return the height of the
screen, minus anything which is not usable."

Capybara Cheat Sheet

Navigating

visit('/projects')
visit(post_comments_path(post))

Clicking Links and Buttons

@lee-dohm
lee-dohm / push_db_to_s3
Last active December 22, 2015 20:39 — forked from david-vo/push_db_to_s3
#!/usr/bin/env ruby
# Script to backup the Discourse postgres db and upload it to Amazon S3
require 'rubygems'
require 'yaml'
require 'fog'
require 'time'
require 'date'
require 'fileutils'