Skip to content

Instantly share code, notes, and snippets.

@aslam
aslam / .vimrc
Created November 2, 2021 18:08 — forked from millermedeiros/.vimrc
My VIM settings (.vimrc)
" =============================================================================
" Miller Medeiros .vimrc file
" -----------------------------------------------------------------------------
" heavily inspired by: @factorylabs, @scrooloose, @nvie, @gf3, @bit-theory, ...
" =============================================================================
" -----------------------------------------------------------------------------
" BEHAVIOR
@aslam
aslam / generate-pushid.js
Created June 21, 2017 19:40 — forked from mikelehen/generate-pushid.js
JavaScript code for generating Firebase Push IDs
/**
* Fancy ID generator that creates 20-character string identifiers with the following properties:
*
* 1. They're based on timestamp so that they sort *after* any existing ids.
* 2. They contain 72-bits of random data after the timestamp so that IDs won't collide with other clients' IDs.
* 3. They sort *lexicographically* (so the timestamp is converted to characters that will sort properly).
* 4. They're monotonically increasing. Even if you generate more than one in the same timestamp, the
* latter ones will sort after the former ones. We do this by using the previous random bits
* but "incrementing" them by 1 (only in the case of a timestamp collision).
*/
@aslam
aslam / varnish3.rb
Last active September 6, 2017 04:39 — forked from wearethefoos/varnish3.rb
Install Varnish-3.0.2 on OSX with homebrew
##
# Install Varnish 3.0.2 on OSX with the following Brew command:
# $> brew install https://gist.githubusercontent.com/aslam/022ec19fb9b1b1b96c99c09b2f43d9c3/raw/d731e4bb44830a352397e3cb79f1aea47bed6483/varnish3.rb
#
# You also might have to run:
# $> sudo brew link varnish3
# To symlink the install.
##
require 'formula'
@aslam
aslam / gist:f27929409f5ee6a2a8e2
Last active October 7, 2015 14:23 — forked from nateberkopec/gist:dbc942f18359891fbc0b
Script to turn videos in to GIFs
#/usr/bin/env bash
rm -rf ./.pngs
rm -rf ./.gifs
mkdir .pngs
mkdir .gifs
ffmpeg -i $1 -r 10 ./.pngs/out%04d.png
sips -s format gif ./.pngs/*.png --out ./.gifs
gifsicle ./.gifs/*.gif --optimize=3 --delay=3 --loopcount --resize 720x405 --colors=255 > $1.gif
gifsicle --unoptimize $1.gif | gifsicle --dither --colors 48 --resize-fit-width 512 -O2 `seq -f "#%g" 0 2 213` -o $1.optimized.gif
rm -rf $1.gif
@aslam
aslam / deploy.rake
Created September 10, 2012 13:56 — forked from shreyas-satish/deploy.rake
Rake task for deployment
require 'jammit'
namespace :deploy do
def run(*cmd)
system(*cmd)
raise "Command #{cmd.inspect} failed!" unless $?.success?
end
task :prod do
@aslam
aslam / Gemfile
Created March 21, 2012 11:13 — forked from Epictetus/Gemfile
Rails 3.2.1 Gemfile for Heroku with haml, rspec and backbone.js
source 'https://rubygems.org'
gem 'rails', '3.2.1'
gem 'haml-rails'
gem 'rails-backbone'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
group :development, :test do
@aslam
aslam / sti_helpers.rb
Created November 22, 2011 12:15 — forked from shakerlxxv/sti_helpers.rb
To smooth out the use of STI for Rails models
#-------------------------------------------------------------------------------
# This module is meant to be included in the Base class of an STI model
# hierarchy.
#
# Heavily inspired by a couple key blog posts
# http://code.alexreisner.com/articles/single-table-inheritance-in-rails.html
# http://coderrr.wordpress.com/2008/04/22/building-the-right-class-with-sti-in-rails/#comment-1826
#
# Thanks to Alex and coderrr!
#-------------------------------------------------------------------------------
@aslam
aslam / rails_3_1_rc4_changes.md
Created November 4, 2011 07:47 — forked from ryanb/rails_3_1_rc4_changes.md
The Changelogs for Rails 3.1 Beta 1

Railties 3.1 RC4

  • The new rake task assets:clean removes precompiled assets. [fxn]

  • Application and plugin generation run bundle install unless --skip-gemfile or --skip-bundle. [fxn]

  • Fixed database tasks for jdbc* adapters #jruby [Rashmi Yadav]

  • Template generation for jdbcpostgresql #jruby [Vishnu Atrai]

@aslam
aslam / gist:1241785
Created September 26, 2011 07:28 — forked from padolsey/gist:527683
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@aslam
aslam / _form.html.erb
Created September 18, 2011 09:36 — forked from vjm/_form.html.erb
CRUD Devise Example
<%= form_for(@user) do |f| %>
<% if @user.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@user.errors.count, "error") %> prohibited this user from being saved:</h2>
<ul>
<% @user.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>