Skip to content

Instantly share code, notes, and snippets.

@ChrisLusted
ChrisLusted / wakeup.sh
Created March 26, 2013 10:08
Wakeup script for MiniDrive
#!/bin/sh
diskutil eject disk1; sudo kextunload -b com.apple.driver.AppleUSBCardReader; sudo kextload -b com.apple.driver.AppleUSBCardReader
development:
adapter: mysql2 # must =~ /mysql/
database: adamDb # required
username: your_user
password: keep_secret
live:
ssh_user: # optional, use if live system user differs from your dev user
host: example.com # required, can be IP
adapter: mysql2 # must =~ /mysql/
# First configure your models to use Amazon s3 as storage option and setup the associated S3 config.
# Then add the classes your want to migrate in the klasses array below.
# Then run rake paperclip_migration:migrate_to_s3
# Should work but this is untested and may need some tweaking - but it did the job for me.
namespace :paperclip_migration do
desc "migrate files from filesystem to s3"
task :migrate_to_s3 => :environment do
klasses = [:product] # Replace with your real model names. If anyone wants to this could be picked up from args or from configuration.
klasses.each do |klass_key|
<?php
// Set these dependant on your BB credentials
$username = 'username';
$password = 'password';
// Grab the data from BB's POST service and decode
$json = stripslashes($_POST['payload']);
$data = json_decode($json);
# ----------------
# file_concerns.rb
# ----------------
require 'uri'
module Models
module ComfortableMexicanSofa
module FileConcerns
extend ActiveSupport::Concern
source 'https://rubygems.org'
gem 'rails', '3.2.9'
# Postgres Database
gem 'pg'
# Twitter API
gem 'twitter'

An application I'm working on has two different types of Devise users, but I want both types of users to be able to use the same sign in form. Devise doesn't make this easy.

You could argue that I really should have a single user type with a role attribute, but the app is far enough along that I don't want to change that early design decision. It could be changed later if more pain points are discovered.

You could also argue that I shouldn't use Devise, but it's still the de facto authentication standard for Rails applications.

In this example, you can sign in as either a User or an AdminUser. This application only has two types of user, but this example could be extended to support any number of them more gracefully.

# Example to initialize gridster and handle resizing
# Module grid settings
WIDGET_BASE_DIMENSIONS_X = WIDGET_DESKTOP_X = 140
WIDGET_BASE_DIMENSIONS_Y = 20
WIDGET_CONTAINER_SELECTOR = '.widget-view'
WIDGET_MOBILE_CUTOFF_WIDTH = 768
NUM_WIDGETS = 15
$ ->
@ChrisLusted
ChrisLusted / gist:9440912
Last active August 29, 2015 13:57
Foundation 5 block grids for bootstrap 3 sass
// Adapted from the awesome zurb foundation
// https://github.com/zurb/foundation/blob/v5.2.0/scss/foundation/components/_block-grid.scss
//
// Block Grid Mixins
//
// We use this to control the maximum number of block grid elements per row
$block-grid-elements: 12 !default;
require 'formula'
class Pngout < Formula
url 'http://static.jonof.id.au/dl/kenutils/pngout-20130221-darwin.tar.gz'
homepage 'http://www.jonof.id.au/kenutils'
md5 'ce71ba0648911931e4e822d83ebf128a6c4201c3'
version '20130221'
def install
prefix.install Dir['*']