Skip to content

Instantly share code, notes, and snippets.

View zmcartor's full-sized avatar

Zach zmcartor

View GitHub Profile
@zmcartor
zmcartor / gist:1022420
Created June 13, 2011 07:24
svg-edit config
svgEditor.setConfig({
dimensions: [400, 300],
canvas_expansion: 1,
show_outside_canvas:false,
iconsize: 'l',
//load the background here to start.
bkgd_url:"http://www.babble.com/CS/blogs/strollerderby/2008/11/01-07/coffee.jpg",
});
@zmcartor
zmcartor / gist:1022421
Created June 13, 2011 07:25
svg-edit config
svgEditor.setConfig({
dimensions: [400, 300],
canvas_expansion: 1,
show_outside_canvas:false,
iconsize: 'l',
//load the background here to start.
bkgd_url:"http://some-url.png",
});
@zmcartor
zmcartor / gist:1022424
Created June 13, 2011 07:38
svg-edit hide
/*remove un-used features here and clean up the UI */
#copyright, #tool_wireframe, li#tool_clear, li#tool_open, li#tool_export, #tool_docprops, li#tool_import,
#tool_image, #tool_path{
display:none;
@zmcartor
zmcartor / blocky start
Created June 25, 2011 02:15
Blocky start
new Blocky('http://hackazach.net' ,'funfun', {cell_size:11, scriptheme:'watermelon'})
@zmcartor
zmcartor / underscorejs templating
Created December 5, 2011 01:46
underscorejs templating
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.2.2/underscore-min.js" type="text/javascript"></script>
<script type="text/javascript">
album1 = {artist:"Sonic Youth" , album:'Dirty'}
album2 = {artist:"Cher" , album: 'blah'}
album3 = {artist:"Silverchair", album:'Frog Stomp'}
albums = [album1 , album2, album3]
@zmcartor
zmcartor / gist:1670138
Created January 24, 2012 13:19
JS Mixin
var RoundButton = function(radius, label, action) {
this.radius = radius;
this.label = label;
this.action = action;
this.StuffSp = 'hoho';
};
var someStuff = function(){
if(this.hasOwnProperty('StuffSpace')){
@zmcartor
zmcartor / gist:1670154
Created January 24, 2012 13:22
Tumblr Gist
<!-- Add the following lines to theme's html code right before </head> -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script src="http://static.tumblr.com/fpifyru/VCxlv9xwi/writecapture.js"></script>
<script src="http://static.tumblr.com/fpifyru/AKFlv9zdu/embedgist.js"></script>
<!--
Usage: just add <div class="gist">[gist URL]</div>
Example: <div class="gist">https://gist.github.com/1395926</div>
-->
@zmcartor
zmcartor / Backbone Namespacing
Created April 16, 2012 20:23
Backbone Namespacing
//Make sure to namespace stuff :)
window.Poc = window.Poc || {};
window.Poc.Models = window.Poc.Models || {};
window.Poc.Collections = window.Poc.Collections || {};
window.Poc.Views = window.Poc.Views || {};
window.Poc.Dispatcher = {};
/******************************
****** Backbone Objects ******
@zmcartor
zmcartor / gist:2431522
Created April 20, 2012 20:14
Backbone View Attributes to Model
BBView = Backbone.View.extend({
el: '#some-selector',
attributes: function () {
return {
name: this.nameField.val(),
email: this.emailField.val(),
password: this.passwordField.val(),
password_confirmation: this.passwordConfirmationField.val()
};
},
@zmcartor
zmcartor / gist:2495033
Created April 26, 2012 01:27
GettysBurg Estimate
lines = File.new('gettys').gets
lineno = 0
short = {0=>[]}
lines.split(' ').each do |word|
#count up the present line and include spaces. Take into account the current space count
#and the impact of adding the new word + 1 space.
if ( ( (short[lineno].inject(0){|sum, ele| sum+=ele.size} ) + (word.size+1 + (short[lineno].count-1)) ) <= 13)
short[lineno] = short[lineno].push word
else
lineno+=1