Skip to content

Instantly share code, notes, and snippets.

@polarblau
polarblau / gist:1080242
Created July 13, 2011 12:55
Backbone base collection class
class BaseCollection extends Backbone.Collection
_expiresAfter: 15 # seconds
_lastFetched: null
isStale: ->
now = (new Date()).getTime()
!@_lastFetched? || now - @_lastFetched > (@_expiresAfter * 1000)
refresh: (models, options) ->
@polarblau
polarblau / gist:1175351
Created August 27, 2011 12:49
Cheap translation from (in this case en > fi) from command line
# install @sishen's ruby gem for access to Google's translate API access:
# https://github.com/sishen/rtranslate
$ gem install sishen-rtranslate
# add alias for quick access and reload:
# (adjust/add languages as needed)
$ echo "alias fin='rtranslate -f en -t fi'" >> .profile
$ source .profile
# try it:
@polarblau
polarblau / utilities.rake
Created September 7, 2011 10:57
Find TODOs in your Rails project and create Github issues accordingly
require 'net/http'
require 'json'
# For the lazy like me who find themselves
# frequently adding lines like
# TODO: add documentation
#
# Find all these lines in the current project
# and create Github issues accordingly
# The issue will contain a link to the current branch
@polarblau
polarblau / jquery.easing.eighty-twenty.js
Created September 28, 2011 09:14
jQuery easing extension for 80/20 animations
jQuery.easing['jswing'] = jQuery.easing['swing'];
jQuery.extend(jQuery.easing, {
eightyTwentyLinear: function(x, t, b, c, d) {
return ((b + c) - (b + c) * 0.8) * (t /= d) + (b + c) * 0.8;
},
eightyTwentyQuartOut: function(x, t, b, c, d) {
return -((b + c) - (b + c) * 0.8) * (t /= d) * (t - 2) + (b + c) * 0.8;
}
});
@polarblau
polarblau / deploy.rake
Created October 19, 2011 11:47
Prepare Rails 3.1 app and deploy to Heroku
desc "Compile assets, commit them and deploy to heroku"
task :deploy do
puts legend("Precompiling assets")
%x(rake assets:precompile RAILS_ENV=production)
puts legend("Committing assets")
%x(git add public/assets/*)
%x(git commit -m "Precompiled assets for production.")
$.fn.bounce = function(options) {
var settings = $.extend({
speed: 10
}, options);
return $(this).each(function() {
var $this = $(this),
$parent = $this.parent(),
@polarblau
polarblau / twitter.css
Created February 14, 2012 11:18
Twitter cleanup
#page-container, .global-nav .container {
width: 550px;
}
div[data-component-term="user_recommendations"], div[data-component-term="trends"], div[data-component-term="footer"], .larry-topbar {
display: none;
}
#page-node-home .dashboard, #page-node-home .content-main {
float: none;
@polarblau
polarblau / gist:3865638
Created October 10, 2012 13:25
Copy&paste highlighted code into e.g. Keynote
# I came across this snippet http://gistflow.com/posts/422-highlight-code-for-keynote-presentation
# but it didn’t work until @pietia was so nice to point out that there’s no need for the output file.
# 1. Install highlight
brew install highlight
# 2. Add this to e.g. .bash_profile and reload it
function hl() {
 format=${1-rb};
 pbpaste | highlight --syntax=$format -O rtf | pbcopy;
@polarblau
polarblau / gist:3901179
Created October 16, 2012 18:47
Commit messages / RailsRumble
Fixing bug with message to self.
The actual resetting page.
Reloadin'.
some trick for worker
tricks p2
Fleshy pipi animation.
Things I don't remember I did.
turned off the debugger
let's try to fix order
Things.
@polarblau
polarblau / de.yml
Created October 23, 2012 06:19 — forked from newstler/de.yml
#iOSonRailsConf 2013 web site translations
##############################
##############################
# > this is a name, right? no need to translate?
robot_in_the_cloak: "Robot in the Cloak"
site_title: "#iOSonRailsConf 2013"
site_description: "Eine Konferenz für Ruby on Rails und iOS-Entwickler aus aller Welt, die im Frühjahr 2013 in Aluschta stattfinden wird."
site_description_short: "Ruby on Rails und iOS-Entwickler Konferenz."
site_keywords: "Ruby, Rails, ios, Entwickler, Konferenz, 2013, Web, Handy, iphone, ipad, ipod"