Skip to content

Instantly share code, notes, and snippets.

# shortform git commands
alias g='git'
# generate file list modified since last commit and export to tar file
git diff-tree -z -r --no-commit-id --name-only --diff-filter=ACMRT COMMID_HASH | xargs -0 tar -rf list.tar
# export unpushed files list
git log -z origin/master..master --name-only --pretty="format:" | sort -zu | xargs -0 tar -rf list.tar
# Count the lines of each file extenion in a list of files
@lushone
lushone / Rakefile
Created March 6, 2014 11:29 — forked from stammy/Rakefile
# ignore the "bit" stuff.. only relevant to my custom jekyll fork
desc 'create new post or bit. args: type (post, bit), title, future (# of days)'
# rake new type=(bit|post) future=0 title="New post title goes here" slug="slug-override-title"
task :new do
require 'rubygems'
require 'chronic'
type = ENV["type"] || "bit"
title = ENV["title"] || "New Title"

Friendly URLs

By default, Rails applications build URLs based on the primary key -- the id column from the database. Imagine we have a Person model and associated controller. We have a person record for Bob Martin that has id number 6. The URL for his show page would be:

/people/6

But, for aesthetic or SEO purposes, we want Bob's name in the URL. The last segment, the 6 here, is called the "slug". Let's look at a few ways to implement better slugs.

#!/bin/bash
OPENSSL_VERSION="1.0.0e"
curl -O http://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz
tar -xvzf openssl-$OPENSSL_VERSION.tar.gz
mv openssl-$OPENSSL_VERSION openssl_i386
tar -xvzf openssl-$OPENSSL_VERSION.tar.gz
mv openssl-$OPENSSL_VERSION openssl_x86_64
cd openssl_i386
./Configure darwin-i386-cc -shared
@lushone
lushone / tall_box.css
Last active December 13, 2015 23:19 — forked from anonymous/tall_box.css
Specify a height on line 104.
#ad {
position:relative;
float:left;
margin: 0 1% 0 0;
top: 200px;
width:200px;
}
#main {
top: 15px;
.visible-desktop {
display: inherit;
}
.visible-tablet {
display: none !important;
}
.visible-mobile {
display: none !important;
@lushone
lushone / Responsive
Created December 14, 2012 17:14 — forked from anonymous/Responsive
.visible-desktop {
display: inherit;
}
.visible-tablet {
display: none !important;
}
.visible-mobile {
display: none !important;
@lushone
lushone / robot.js
Created December 3, 2012 20:35 — forked from cezarsa/robot.js
Simple Wall Robot
var Robot = function(robot){
robot.turnLeft(robot.angle % 90);
robot.turnGunRight(90);
robot.clone();
this.direction = 1;
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.ahead(1);
if (robot.parentId) {
@lushone
lushone / robot.js
Created December 3, 2012 20:34
W00t #1 YEAH!!!! (Zolmesiter)
var Robot = function(robot){
robot.turnLeft(robot.angle % 90);
//robot.turnGunRight(90);
robot.clone();
this.direction = 1;
};
Robot.prototype.onIdle = function(ev) {
var robot = ev.robot;
robot.ahead(1);
if (robot.parentId) {
@lushone
lushone / robot.js
Created December 3, 2012 20:34 — forked from samshull/robot.js
destroyer of worlds
//FightCode can only understand your robot
//if its class is called Robot
var Robot = function(robot) {
};
Robot.prototype.onIdle = function(ev) {
var robot;
robot = ev.robot;