Skip to content

Instantly share code, notes, and snippets.

@hobberwickey
hobberwickey / Creating Migrations and Models
Created February 26, 2015 16:58
Bash scripts for creating activerecord models and migrations (for Sinatra and such)
#create_migration.sh - example: create_migration.sh create_my_migration
#!/bin/sh
seporator="_"
IFS=$seporator read -ra ADDR <<< "$1"
className=""
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
for i in "${ADDR[@]}"; do
cap=$"$(tr '[:lower:]' '[:upper:]' <<< ${i:0:1})${i:1}"
@hobberwickey
hobberwickey / Pagination
Created February 18, 2015 01:50
Example of a Pagination mixin for smartMixins
<script>
var Pagination = {
change_page: function(){
this.paged_data = this.data.slice((this.page - 1) * this.per_page, this.page * this.per_page);
},
next_page: function(){
if (this.page < this.total_pages){
this.page++;
}