Skip to content

Instantly share code, notes, and snippets.

View teddyhwang's full-sized avatar

Teddy Hwang teddyhwang

  • Shopify
  • Toronto, ON
View GitHub Profile
@teddyhwang
teddyhwang / remotepaste.md
Created June 30, 2021 16:30 — forked from burke/remotepaste.md
This sets up keybindings in tmux that allow you to copy/paste to/from your OS X clipboard from tmux running inside an SSH connection to a remote host. Partially borrowed from http://seancoates.com/blogs/remote-pbcopy

Local (OS X) Side

~/Library/LaunchAgents/pbcopy.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
     <key>Label</key>
     <string>localhost.pbcopy</string>
@teddyhwang
teddyhwang / gist:7184053
Created October 27, 2013 15:47
Back to my Mac via SSH
# Find out your iCloud BTMM domain
dns-sd -E
# List Computers
dns-sd -B _ssh <12345678>.members.btmm.icloud.com
# Connect
ssh <username>@<computer-name>.<12345678>.members.btmm.icloud.com
@teddyhwang
teddyhwang / compile-screen-gnu.md
Last active June 5, 2016 23:50
I always seem to forget this.

brew install homebrew/dupes/screen

@teddyhwang
teddyhwang / scrollto.js
Last active December 15, 2015 03:39
Easiest way to scroll to an element.
$('html, body').animate({'scrollTop': element.offset().top}, 'slow', 'swing');
<!doctype html>
<html>
<head>
<title>CSS Media Check</title>
<style type="text/css">
#mediaquery{
-webkit-transition: width .001s;
-moz-transition: width .001s;
@teddyhwang
teddyhwang / browser.detection.js
Created December 28, 2012 07:32
Browser detection via feature detection
var isOpera = !!(window.opera && window.opera.version); // Opera 8.0+
var isFirefox = testCSS('MozBoxSizing'); // FF 0.8+
var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0; // At least Safari 3+: "[object HTMLElementConstructor]"
var isChrome = !isSafari && testCSS('WebkitTransform'); // Chrome 1+
var isIE = /*@cc_on!@*/false || testCSS('msTransform'); // At least IE6
function testCSS(prop) {
return prop in document.documentElement.style;
}
@teddyhwang
teddyhwang / gist:4286118
Created December 14, 2012 15:09
129 bytes to enable HTML5 on old browsers
<script>
;("header footer section aside nav article figure figcaption hgroup time").replace(/\w+/g,function(a){document.createElement(a)})
</script>
@teddyhwang
teddyhwang / uri.js
Created November 6, 2012 02:21 — 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"