Skip to content

Instantly share code, notes, and snippets.

View jamiehs's full-sized avatar

Jamie Hamel‑Smith jamiehs

View GitHub Profile
@jamiehs
jamiehs / youtube-regex.js
Created October 6, 2012 14:42
YouTube JavaScript Regex
var youTubeRegex = /(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|[a-zA-Z0-9_\-]+\?v=)([^#\&\?\n<>\'\"]*)/gi;
@jamiehs
jamiehs / dactyl.clj
Created July 14, 2019 20:40
Dactyl Manuform with 5x6/5x7 and aviator connections
(ns dactyl-keyboard.dactyl
(:refer-clojure :exclude [use import])
(:require [clojure.core.matrix :refer [array matrix mmul]]
[scad-clj.scad :refer :all]
[scad-clj.model :refer :all]
[unicode-math.core :refer :all]))
(defn deg2rad [degrees]
(* (/ degrees 180) pi))
@jamiehs
jamiehs / mq.css
Created October 4, 2012 16:00 — forked from chriscoyier/mq.css
Media Query Breakpoints for Retina Displays
@media only screen and (min-width: 320px) {
/* Small screen, non-retina */
}
@media
only screen and (-webkit-min-device-pixel-ratio: 2) and (min-width: 320px),
only screen and ( min--moz-device-pixel-ratio: 2) and (min-width: 320px),
only screen and ( -o-min-device-pixel-ratio: 2/1) and (min-width: 320px),
@jamiehs
jamiehs / find.sh
Created August 8, 2019 20:47
Find mtime quirks
find . -mtime +0 # find files modified greater than 24 hours ago
find . -mtime 0 # find files modified between now and 1 day ago
# (i.e., in the past 24 hours only)
find . -mtime -1 # find files modified less than 1 day ago (SAME AS -mtime 0)
find . -mtime 1 # find files modified between 24 and 48 hours ago
find . -mtime +1 # find files modified more than 48 hours ago
@jamiehs
jamiehs / gist:9824788
Created March 28, 2014 03:37
ISO 8601 Parser for PHP
<?php
/**
* Parse an ISO 8601 duration string
* @return array
* @param string $str
**/
function parseDuration($str)
{
$result = array();
preg_match('/^(?:P)([^T]*)(?:T)?(.*)?$/', trim($str), $sections);
@jamiehs
jamiehs / rename-prefix.sh
Created July 12, 2019 18:48
Finds files in the current directory based on a file name pattern and then executes a move command while finding and replacing a component of the file name.
# remove echo to execute the actual mv command
find . -type f -name "prefix-*.json" -exec bash -c 'echo mv "$1" "${1/find/replace}"' -- {} \;
@jamiehs
jamiehs / proto-pasta-ppu-htpla.ini
Created June 29, 2019 23:53
Proto-Pasta Powder Puff Unicorn Settings for PrusaSlicer
# generated by PrusaSlicer 2.0.0 on 2019-06-29 at 16:47:15
[filament:Proto-Pasta PPU jamiehs]
filament_colour = #5EDBE8
filament_max_volumetric_speed = 4
filament_type = PLA
first_layer_bed_temperature = 60
first_layer_temperature = 230
inherits = Generic PLA
max_fan_speed = 80
@jamiehs
jamiehs / package.json
Created September 14, 2018 21:04
When Node is installing dependancies, there is a variable we can use to conditionally run something in production/!production
{
"scripts": {
"postinstall": "if [ -n \"$npm_config_production\" ]; then npm run build; fi"
}
}
@jamiehs
jamiehs / gist:3364281
Created August 15, 2012 22:25
jQuery Array Intersect One Liner
// Find the common intersection between the arrays
a1=[1,2,3]
a2=[2,3,4,5]
$.map(a1,function(a){return $.inArray(a, a2) < 0 ? null : a;})
// http://stackoverflow.com/a/9401775/24559
@jamiehs
jamiehs / in_this_language.md
Last active April 21, 2017 15:45
In This Language (add your comments or suggestions)

Input

foo bar baz qux

Required Output

Hello Foo
Hello Bar
Hello Baz
Hello Qux