Skip to content

Instantly share code, notes, and snippets.

@Arwid
Arwid / gist:1453830
Created December 9, 2011 23:38
Bash compile script for assets: Coffee JS, Libs, CSS
#!/bin/bash
COMPRESS=true
YUI_COMPRESSOR_PATH="../../tools/YUI_Compressor/build/yuicompressor-2.4.6.jar"
### JS FILES ###
# CONFIG
MAIN_FILE_NAME="app"
MAIN_FILE_PATH="../assets/$MAIN_FILE_NAME.js"
@Arwid
Arwid / gist:1453823
Created December 9, 2011 23:34
Compile and Compress a "<fileName>.html.mustache.php" file
<?
function compress($buffer) {
/* remove comments */
$buffer = preg_replace('!/\*[^*]*\*+([^/][^*]*\*+)*/!', '', $buffer);
/* remove tabs, spaces, newlines, etc. */
$buffer = str_replace(array("\r\n", "\r", "\n", "\t", ' ', ' ', ' '), '', $buffer);
return $buffer;
}
function getTemplate($filename) {
@Arwid
Arwid / gist:1185661
Created September 1, 2011 07:47
Nifty way of creating an array of objects
config = _.map [
[1, "Important", "Urgent"]
[2, "Important", "Not Urgent"]
[3, "Not Important", "Not Urgent"]
[4, "Not Important", "Not Urgent"]
], (x) -> {id:x[0], vtitle:x[1], htitle:x[2]}
@Arwid
Arwid / SubViews.html
Created May 6, 2011 05:43 — forked from johnreilly/SubViews.html
My attempt at using Backbone.js views to render other "sub-views"
<!DOCTYPE html>
<html>
<head>
<title>Test</title>
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/underscore.js" type="text/javascript"></script>
<script src="js/backbone.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8">
$(function(){
@Arwid
Arwid / all_the_toys.rb
Created May 6, 2011 01:35 — forked from quinn/all_the_toys.rb
all the fun stuff i use in my default stack!
# gems
gem 'resque'
# the data
gem 'devise'
gem 'carrierwave'
gem 'fog'
gem 'rmagick'
# controllers and views
@Arwid
Arwid / include csrf-token in ajax requests.js
Created April 19, 2011 23:39
include csrf-token in ajax requests
var csrf_token = $("meta[name='csrf-token']").attr("content");
$("body").bind("ajaxSend", function(elm, xhr, s){
if (s.type == "POST" || s.type == "PUT" || s.type == "DELETE") {
xhr.setRequestHeader('X-CSRF-Token', csrf_token);
}
});