Skip to content

Instantly share code, notes, and snippets.

View defmech's full-sized avatar

David Lochhead defmech

View GitHub Profile
@defmech
defmech / Open with Sublime Text 2
Created July 17, 2013 22:47
Automator script to open files and folders in a new window in Sublime Text 2. In Automator add "Run Shell Script". Add the following code and make sure "Pass input" is set to "as arguments". Can be used as a service or app.
/Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl -n "$@"
@defmech
defmech / Restart A Node Script In Forever After Reboot.txt
Last active August 29, 2015 14:04
How to restart a node script in forever after reboot
First create a shell script like this one (I called mine start-APPNAME.sh):
#!/bin/sh
if [ $(ps aux | grep $USER | grep APPNAME.js | grep -v grep | wc -l | tr -s "\n") -eq 0 ]
then
export NODE_ENV=production
export PATH=/usr/local/bin:$PATH
forever start ~/example/APPNAME.js > /dev/null
fi

Keybase proof

I hereby claim:

  • I am defmech on github.
  • I am defmech (https://keybase.io/defmech) on keybase.
  • I have a public key whose fingerprint is 7902 6DCF 7AAC 4E01 1145 2FA5 C2A8 E991 E64F 3994

To claim this, I am signing this object:

function iPhoneVersion() {
var iHeight = window.screen.height;
var iWidth = window.screen.width;
if (iWidth === 320 && iHeight === 480) {
return "4";
}
else if (iWidth === 375 && iHeight === 667) {
return "6";
}
else if (iWidth === 414 && iHeight === 736) {
@defmech
defmech / Dawesome Design Contract.md
Created April 3, 2018 09:00 — forked from brendandawes/Dawesome Design Contract.md
A contract for general design services.

This contract for general design sevices is a hybrid of this one on Docracy and the AIGA one also found on Docracy. I wanted something that was simple yet covered the important bits such as payment schedule, kill fee, liability, rights etc. Change the parts in square brackets to suit. I've had this checked by a lawyer but I recommend if you decide to use it you also get it looked at by a lawyer too. Never do work without a contract in place. The majority of clients are good, decent and want to create great work with you — having a solid contract in place will strengthen that relationship and provide you with protection should things go awry.

Agreement for commission of work between [Designer Name] (Designer)

and [Client Name] (Client)

on [Date]

@defmech
defmech / reset.scss
Last active September 17, 2018 20:04 — forked from HamptonMakes/reset.scss
Reset SCSS
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
@defmech
defmech / copy_dir_listing_to_pasteboard.scpt
Last active October 9, 2018 11:45
AppleScript to copy current folder directory listing to pasteboard
tell application "Finder"
set currentDirPath to (target of front Finder window) as text
set folderName to name of folder currentDirPath
end tell
tell application "Terminal"
do shell script "cd " & (quoted form of POSIX path of currentDirPath) & "; ls | pbcopy"
end tell
@defmech
defmech / SassMeister-input.scss
Last active May 13, 2019 19:11
Generated by SassMeister.com.
$home: #6C98C6;
$about: #98B7D7;
$contact: #F3F3F3;
$portfolio: #EF7239⁣;
$blog: #fdbc40;
$colors-list:(
home: $home,
about: $about,
@defmech
defmech / applescript.txt
Created August 14, 2019 12:02
Automator Application to copy a directory list to clipboard.
tell application "Finder"
if exists Finder window 1 then
set currentDir to target of Finder window 1 as alias
else
set currentDir to desktop as alias
end if
end tell
@defmech
defmech / map.glsl
Created October 24, 2019 14:29 — forked from companje/map.glsl
map() function for GLSL known from Processing & openFrameworks
float map(float value, float min1, float max1, float min2, float max2) {
return min2 + (value - min1) * (max2 - min2) / (max1 - min1);
}