Skip to content

Instantly share code, notes, and snippets.

/*
* BPGeometry.h
*
* Created by Jon Olson on 11/30/09.
* Copyright 2009 Ballistic Pigeon, LLC. All rights reserved.
*
*/
#import <Foundation/Foundation.h>
@seivan
seivan / assets.rake
Created March 15, 2013 01:39 — forked from sj26/assets.rake
# Stick this in lib/tasks/assets.rake or similar
#
# A bug was introduced in rails in 7f1a666d causing the whole application cache
# to be cleared everytime a precompile is run, but it is not neccesary and just
# slows down precompiling.
#
# Secondary consequences are the clearing of the whole cache, which if using
# the default file cache could cause an application level performance hit.
#
# This is already fixed in sprockets-rails for rails 4, but we patch here for
@seivan
seivan / invalidate-cf-path.rb
Created December 3, 2012 03:05 — forked from rbm/invalidate-cf-path.rb
Invalidate CloudFront path using fog
#!/usr/bin/env ruby -w
require 'rubygems'
require 'fog'
require 'pp'
AWS_ACCESS_KEY = ENV['AWS_ACCESS_KEY_ID']
AWS_SECRET_KEY = ENV['AWS_SECRET_ACCESS_KEY']
def get_cf_connection()
@seivan
seivan / 1 Readme.md
Created December 2, 2012 12:11 — forked from toolmantim/1 Readme.md
Minification with newlines using the Rails 3 asset pipeline

Retaining line numbers with the Rails asset pipeline

By default the Rails 3 asset pipeline uses the Uglifier gem to optimize and minify your Javascript. One of its many optimisations is to remove all whitespace, turning your Javascript into one very long line of code.

Whist removing all the newlines helps to reduce the file size, it has the disadvantage of making your Javascript harder to debug. If you've tried to track down Javascript errors in minified Javascript files you'll know the lack of whitespace does make life harder.

Luckily there is a simple solution: to configure Uglifier to add newlines back into the code after it performs its optimisations. And if you're serving your files correctly gzip'd, the newlines add only a small increase to the final file size.

You can configure Uglifier to add the newlines by setting the following in your Rails 3 config/production.rb file:

@seivan
seivan / readysetfight.markdown
Created July 3, 2011 10:50 — forked from jeffkreeftmeijer/readysetfight.markdown
Finding something like `if ( ready? && set? ) { fight! };` in Ruby

Right now, the tagline-code-snippet thing on Codebrawl is if ( ready? && set? ) { fight! };. While this looks nice, this is not valid Ruby code.

So, I'm looking for something better. It should be Ruby, and it should look cool. If you have an idea, please fork the Gist and add it to the list below. Thanks! :)

ready? && set? && fight! 
if ( ready? && set? ) then fight! end
( ready? && set? ) ? fight! : nil

ready! #(raise if not ready)

@implementation Game
@synthesize st;
- (id)initWithWidth:(float)width height:(float)height {
if (self = [super initWithWidth:width height:height]) {
// this is where the code of your game will start.
// in this sample, we add just a simple quad to see if it works.
st = [[SPSprite alloc] init];
st.rotation = SP_D2R(90);
st.x = 320;
// views/reviews/create.js.erb
$("#new_review").before('<div id="flash_notice"><%= escape_javascript(flash.delete(:notice)) %></div>');
$("#reviews_count").html("<%= pluralize(@review.product.reviews.count, 'Review') %>");
$("#reviews").append("<%= escape_javascript(render(:partial => @review)) %>");
$("#new_review")[0].reset();
// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
$(document).ready(function() {
$("#comment_form").submit(function() {
$.post($(this).attr("action"), $(this).serialize(), null, "script");
return false;
})
})
# @settings and anything in it could be nil or blank at any time
def get_backlog_issues(exclude_ids=[])
return [[]] unless @settings.present? &&
@settings['panes'].present? &&
@settings['panes']['backlog'].present? &&
@settings['panes']['backlog']['status'].present? &&
@settings['panes']['backlog']['status'].present?
# ...
class Ability
include CanCan::Ability
# alias_action :index, :show, :to => :read
# alias_action :new, :to => :create
# alias_action :edit, :to => :update
def initialize(user)
if user.role? :admin
can :manage, :all