Skip to content

Instantly share code, notes, and snippets.

View endtwist's full-sized avatar

Joshua Gross endtwist

View GitHub Profile
@endtwist
endtwist / gist:1630921
Created January 18, 2012 04:17
Paste event in Safari
// Safe to say...textarea is a good idea: <textarea id="pasteField"></textarea>
$( '#pasteField' ).on( 'paste', function( evt ) {
// Safari has a weird "types" list that we need to loop through and no "items" array.
var i = 0, items = [], item, key = 'text/plain', kind = 'string';
while (i < evt.originalEvent.clipboardData.types.length) {
var key = evt.originalEvent.clipboardData.types[i];
if( !key.match( /(text\/)|(plain-text)/i ) ) {
kind = 'file';
}
@endtwist
endtwist / gist:1630899
Created January 18, 2012 04:12
Paste event in Internet Explorer
// We need a textarea for IE, too: <textarea id="pasteField"></textarea>
$( '#pasteField' ).bind( 'paste', function( evt ) {
// In true Microsoft form, the type to get plain text is Text with a captial T.
console.log( window.clipboardData.getData( 'Text' ) );
} );
@endtwist
endtwist / firefox_paste.html
Created January 18, 2012 04:04
Paste event in Firefox
<textarea id="pasteField"></textarea>
@endtwist
endtwist / gist:1630834
Created January 18, 2012 03:57
Paste event in Google Chrome
$( 'body' ).bind( 'paste', function( evt ) {
var items = evt.originalEvent.clipboardData.items
, paste;
// Items have a "kind" (string, file) and a MIME type
console.log( 'First item "kind":', items[0].kind );
console.log( 'First item MIME type:', items[0].type );
// If a user pastes image data, there are 2 items: the file name (at index 0) and the file (at index 1)
// but if the user pastes plain text or HTML, index 0 is the data with markup and index 1 is the plain, unadorned text.
#!/bin/bash
# <UDF name="ssh_key" Label="Paste in your public SSH key" default="" example="" optional="false" />
# root ssh keys
mkdir /root/.ssh
echo $SSH_KEY >> /root/.ssh/authorized_keys
chmod 0700 /root/.ssh
# update to latest
@endtwist
endtwist / lazy.js
Created November 17, 2011 19:22
Javascript asset lazy loading
/**
* Lazy load assets, call callback fn after all assets have loaded.
*
* Requires: jQuery or Zepto
*
* Usage:
* Lazy.load({"js": ["js/file.js"],
* "tpl": [{"src": "tpl/event.tpl", "id": "event-view"}],
* "css": ["css/file.css"]
* });
@endtwist
endtwist / .bashrc
Created November 4, 2011 20:07
Bash config
PS1="\[\e[0:32m\]\w \[\e[0;39m\]\$ "
if [ -f ~/.git-completion.bash ]; then
source ~/.git-completion.bash
PS1="\[\e[0:32m\]\w"'$(__git_ps1 " \[\e[1;30m\](%s)")'"\[\e[0;39m\]\$ "
fi
export CLICOLOR=1
export ll='ls -al'
@endtwist
endtwist / .gitconfig
Created November 4, 2011 20:05
.gitconfig
[user]
name =
email =
[core]
editor = /usr/bin/nano
excludesfile = /Users/username/.gitignore
[merge]
conflictstyle = diff3
[color]
branch = auto
@endtwist
endtwist / gist:1292731
Created October 17, 2011 14:36 — forked from tvandervossen/gist:1231476
Mobile Safari viewport sizes on iOS 4.3 and 5
iPad
1024 × 690 In landscape on iOS 4.3
1024 × 672 In landscape on iOS 5
768 × 946 In portrait on iOS 4.3
768 × 928 In portrait on iOS 5
1024 × 660 Always showing bookmarks bar in landscape on iOS 4.3
1024 × 644 Always showing bookmarks bar in landscape on iOS 5
768 × 916 Always showing bookmarks bar in portrait on iOS 4.3
@endtwist
endtwist / Compass Watch
Created October 4, 2011 23:10 — forked from techyak/Compass Watch
the alias that I'm using to watch node.js/coffeescript/compass at the same time
function nodewatch() {
find . | grep coffee$ | xargs coffee -cwl &
if [ $1 ]
then
nodemon $1.js &
else
nodemon app.js &
fi