Skip to content

Instantly share code, notes, and snippets.

View nskeip's full-sized avatar
🕶️

Nikita Hismatov nskeip

🕶️
View GitHub Profile
@stympy
stympy / deploy.rb
Created December 12, 2011 21:27
Skip asset pre-compilation when deploying if the assets didn't change
namespace :deploy do
namespace :assets do
task :precompile, :roles => :web, :except => { :no_release => true } do
from = source.next_revision(current_revision)
if capture("cd #{latest_release} && #{source.local.log(from)} vendor/assets/ app/assets/ | wc -l").to_i > 0
run %Q{cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile}
else
logger.info "Skipping asset pre-compilation because there were no asset changes"
end
end
@cspanring
cspanring / pagination.html
Created November 8, 2011 02:53
linaro django pagination template for Bootstrap framework
{# use in combination with https://github.com/zyga/django-pagination #}
{# and http://twitter.github.com/bootstrap/ #}
{# project-dir/templates/pagination/pagination.html #}
{% if is_paginated %}
{% load i18n %}
<div class="pagination">
<ul>
{% block previouslink %}
{% if page_obj.has_previous %}
@MacMaru
MacMaru / wrap_view.py
Created July 31, 2011 16:59
Override Tastypie wrap_view() to return custom (JSON) response
class YourResource(ModelResource):
def wrap_view(self, view):
"""
Wraps views to return custom error codes instead of generic 500's
"""
@csrf_exempt
def wrapper(request, *args, **kwargs):
try:
@mrjjwright
mrjjwright / backbone.history.html5.coffee
Created March 1, 2011 16:55
Add pretty html5 history support to Backbone
#
# Replaces Backbone.History with support for HTML5 history API if browser supports it.
# To use, setup your controllers as usual and try it with a browser that supports the HTML5 history API.
# For browsers that don't support the HTML5 API, this will fall back to using the default Backbone hash routing.
#
# I have only tested this on my project in Firefox, Safari and Chrome so let me know.
#
pushSupport = window.history? and window.history.pushState?
if pushSupport and Backbone? and Backbone.History?
rootUrl = document.location.protocol+'//'+(document.location.host or document.location.hostname)
@matthuhiggins
matthuhiggins / cache.rake
Created November 9, 2010 05:24
clear memcache
namespace :cache do
desc 'Clear memcache'
task :clear => :environment do
Rails.cache.clear
end
end