Skip to content

Instantly share code, notes, and snippets.

@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);
}
});
@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 / 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 / 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 / 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: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 / Gemfile
Created January 7, 2012 23:07
Sprockets compilation of assets
source 'http://rubygems.org'
gem 'sass'
gem 'coffee-script'
gem 'yui-compressor'
gem 'handlebars_assets'
gem 'sprockets'
gem 'rb-fsevent'
@Arwid
Arwid / HideMobileAddressBar.js
Created March 19, 2012 04:10 — forked from mhammonds/HideMobileAddressBar.js
Hide Browser Address Bar - Android + iPhone
function hideAddressBar()
{
if(!window.location.hash)
{
if(document.height < window.outerHeight)
{
document.body.style.height = (window.outerHeight + 50) + 'px';
}
setTimeout( function(){ window.scrollTo(0, 1); }, 50 );
How to setup Heroku Hostname SSL with GoDaddy SSL Certificate and Zerigo DNS
Heroku recently added an exciting new 'Hostname SSL' option. This option offers the broad compatibility of IP-based SSL, but at 1/5 the price ($20 / month at the time of this writing).
The following tutorial explains how to use Heroku's new 'Hostname SSL' option on your Heroku project. Before we begin, let's list what we're using here:
* Heroku Hostname SSL
* GoDaddy Standard SSL Certificate
* Zerigo DNS
@Arwid
Arwid / evaluateExpressions.js
Last active August 29, 2015 14:27
lodash extension to evaluate expressions
// lodash extension to evaluate expressions
_.eval = function(expression, scope) {
return _.template("<%= " + expression + " %>")(scope);
}
_.eval = function(expression) {
return _.template("<%= " + expression + " %>");
}