Skip to content

Instantly share code, notes, and snippets.

Avatar

Calvin Tennant calvintennant

View GitHub Profile
@calvintennant
calvintennant / spriteMapper.js
Created Mar 9, 2012
Simple function that abstracts sprite mapping in Three.js
View spriteMapper.js
/**
* @param paramaters as object
*
* Prepare the object in
* the following format:
*
* material = spriteMapper({
* image: 'sprite.png',
* imageSize: 256, // size of image in px (must be square)
* spriteSize: 16, // size of sprite in px (must be square)
@calvintennant
calvintennant / gist:2226700
Created Mar 28, 2012 — forked from anonymous/gist:2221975
Licensing discussion with the creators of SASS
View gist:2226700
From: Calvin Tennant
Date: Tuesday, March 27, 2012
Subject: phpSass licensing
To: Nathan Weizenbaum <nex342@gmail.com>
Cc: Hampton <hcatlin@gmail.com>, Chris Eppstein <chris@eppsteins.net>
Awesome, I'm going to make a pastebin of this email just for records sake. Thanks for getting back to me so quickly.
:)
View gist:2255254
Notes on my current setup:
Adobe Production Premium CS5.5
Xcode 4
iTerm 2
# Homebrew
Homebrew
gettext
glib
View .rtorrent.rc
# Maximum and minimum number of peers to connect to per torrent.
#min_peers = 40
#max_peers = 100
# Same as above but for seeding completed torrents (-1 = same as downloading)
#min_peers_seed = 10
#max_peers_seed = 50
# Maximum number of simultanious uploads per torrent.
#max_uploads = 15
@calvintennant
calvintennant / htaccess.patch
Created Apr 25, 2012
Patch for Drupal 7 .htaccess that enables Rewrite for url (http://www.example.com/... will be redirected to http://example.com/...)
View htaccess.patch
diff --git a/.htaccess b/.htaccess
index e59cd99..e24dd49 100644
--- a/.htaccess
+++ b/.htaccess
@@ -84,8 +84,8 @@ DirectoryIndex index.php index.html index.htm
# To redirect all users to access the site WITHOUT the 'www.' prefix,
# (http://www.example.com/... will be redirected to http://example.com/...)
# uncomment the following:
- # RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
- # RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301]
@calvintennant
calvintennant / getDistance.md
Created Apr 29, 2012
Function returns distance between two points in three dimensional space.
View getDistance.md
=> getDistance(Array(0,4,3), Array(0,0,0));
5
/**
 * Function returns distance between two points in three dimensional space
 * 
 * @param a as Array(x, y, z)
@calvintennant
calvintennant / fieldpermissionslocale.patch
Created May 5, 2012
patched locale so it plays nice with field_permissions (drupal)
View fieldpermissionslocale.patch
diff --git a/modules/locale/locale.module b/modules/locale/locale.module
index e0981b2..6877d8f 100644
--- a/modules/locale/locale.module
+++ b/modules/locale/locale.module
@@ -406,7 +406,7 @@ function locale_field_node_form_submit($form, &$form_state) {
// Handle a possible language change: new language values are inserted,
// previous ones are deleted.
- if ($field['translatable'] && $previous_language != $node->language) {
+ if ($field['translatable'] && $previous_language != $node->language && isset($form_state['values'][$field_name])) {
@calvintennant
calvintennant / fivestarminecraftwidget.patch
Created May 5, 2012
fivestar minecraft widget patch (drupal)
View fivestarminecraftwidget.patch
diff --git a/widgets/mcraft/mcraft-01.png b/widgets/mcraft/mcraft-01.png
new file mode 100644
index 0000000000000000000000000000000000000000..02f798407def0f3633ceb0b4c08eb88f4472a2c2
GIT binary patch
literal 3665
zcmYjTc{mha7rxWj_kBq;vdg|^AI83h5klFAq@k28%w$(T`@a29*-4hM*Vsiy$iDAU
zC=z9vPv0Nk^PT&=&$-LF_dWML|D4#Hrh2qgm#F{%v<CXx78f3Nfffof03c16FujWf
zrH{VtBLJwG{{jNCb2$K@GV??rZr=1j`=K9spnYHl2n5XMA==&Zz8e4mGkKOMq~#Wy
z+R?&KEu$Drsu9|Pl>%m=^&G>JBq+*D$zT}6TR6>X-odD&L&DWx5Ce^m$Gl)Q7o&-z
znj&B0Es76+851{fvK;)<YohIFW9YnLQhl@XAg^wi98W=$t}kmYkD)2k;$d70@9XYe
View .zshrc
# Path to your oh-my-zsh configuration.
ZSH=$HOME/.oh-my-zsh
# Set name of the theme to load.
# Look in ~/.oh-my-zsh/themes/
# Optionally, if you set this to "random", it'll load a random theme each
# time that oh-my-zsh is loaded.
ZSH_THEME="robbyrussell"
# Example aliases
@calvintennant
calvintennant / gist:4050040
Created Nov 10, 2012
jQuery dosen't like SVG css properties like 'fill' and 'stop-opacity' so, I wrote this to piggyback it with my own. @todo make this into a proper jQuery library.
View gist:4050040
/**
* Function takes the style attribute and generates an object that
* represents it's CSS properties.
* @param styleAttr as String
* @return style as Object
*/
getStyle = function(styleAttr) {
var style = {};
styleAttr = styleAttr.split(';');
for (var i = 0; i < styleAttr.length; i++) {