Skip to content

Instantly share code, notes, and snippets.

Avatar

Jamie Hamel‑Smith jamiehs

View GitHub Profile
@jamiehs
jamiehs / mq.css
Created Oct 4, 2012 — forked from chriscoyier/mq.css
Media Query Breakpoints for Retina Displays
View mq.css
@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 Aug 8, 2019
Find mtime quirks
View find.sh
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 Mar 28, 2014
ISO 8601 Parser for PHP
View gist:9824788
<?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 / dactyl.clj
Created Jul 14, 2019
Dactyl Manuform with 5x6/5x7 and aviator connections
View dactyl.clj
(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 / rename-prefix.sh
Created Jul 12, 2019
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.
View rename-prefix.sh
# 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 Jun 29, 2019
Proto-Pasta Powder Puff Unicorn Settings for PrusaSlicer
View proto-pasta-ppu-htpla.ini
# 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 Sep 14, 2018
When Node is installing dependancies, there is a variable we can use to conditionally run something in production/!production
View package.json
{
"scripts": {
"postinstall": "if [ -n \"$npm_config_production\" ]; then npm run build; fi"
}
}
@jamiehs
jamiehs / gist:3364281
Created Aug 15, 2012
jQuery Array Intersect One Liner
View gist:3364281
// 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 Apr 21, 2017
In This Language (add your comments or suggestions)
View in_this_language.md

Input

foo bar baz qux

Required Output

Hello Foo
Hello Bar
Hello Baz
Hello Qux
@jamiehs
jamiehs / .my.cnf
Created Dec 8, 2016
Place this file in your home directory (OS X) and you will not need to specify a MySQL password for your local client.
View .my.cnf
[client]
user='root'
password='123'