Skip to content

Instantly share code, notes, and snippets.

config.assume_ssl = true
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
config.force_ssl = true
...
# based on https://github.com/Purple-Devs/health_check/issues/25#issuecomment-432819017
config.ssl_options = { redirect: { exclude: ->(request) { request.path == '/up' } } }
# and/or
@patricksimpson
patricksimpson / Space.jsx
Last active October 18, 2022 23:30
Just an idea
const Space = ({
margin,
marginRight,
marginLeft,
marginTop,
marginBottom,
padding,
bottom,
top,
left,
@patricksimpson
patricksimpson / simple-date.js
Last active January 19, 2022 23:52
date string to local
function dateToLocal(date) {
let localOffset = new Date().getTimezoneOffset() * 60 * 1000;
let d = new Date(Date.parse(date));
return new Date(d.getTime() + localOffset);
}
{
"createdBy": "Redirector v3.5.3",
"createdAt": "2021-10-16T12:28:52.532Z",
"redirects": [
{
"description": "Medium -> Scribe",
"exampleUrl": "https://medium.com/@user/post-123456abcdef",
"exampleResult": "https://scribe.rip/@user/post-123456abcdef",
"error": null,
"includePattern": " *medium.com/(.*)",
@patricksimpson
patricksimpson / static-search.js
Created January 14, 2019 05:02
A little search for static sites, using Lunr.js!
(function() {
if (window.fetch) {
let searchPage = document.querySelector('.search-body');
if (searchPage) {
let addLunr = document.createElement('script');
addLunr.src = '/static/js/lunr.js';
document.body.appendChild(addLunr);
addLunr.onload = function() {
fetch('/lunr.json').then(function(response) {
return response.json();
#!/bin/sh
dir=app
files=*.js
output=dist.js
find $dir/$files -exec cat {} \; > $output
while true; do
watch -d -g ls -lR $dir/$files
@patricksimpson
patricksimpson / module.js
Last active April 16, 2020 14:21
JavaScript Design Patterns
var options = {
username: 'blah',
server: '127.0.0.1'
};
var ConfigObject = (function(params) {
var username = params.username || '',
server = params.server || '',
password = params.password || '';
! undo any meta keys already set
clear Mod1
! keycodes 63 and 71 are the left and right COMMAND buttons adjacent to the spacebar; set them to be control keys
keycode 63 = Control_L
keycode 71 = Control_R
! keycodes 66 and 69 are the option/alt keys; assign them as Meta keys
keycode 66 = Escape NoSymbol Escape
keycode 69 = Meta_R
xev | grep -A2 --line-buffered '^KeyRelease' | sed -n '/keycode /s/^.*keycode \([0-9]*\).* (.*, \(.*\)).*$/\1 \2/p'
xmodmap -e "keycode 133 = Alt_L"
xmodmap -e "keycode 37 = Control_L"
xmodmap -e "keycode 64 = Control_L"