Skip to content

Instantly share code, notes, and snippets.

View m3talsmith's full-sized avatar

Michael Christenson II m3talsmith

View GitHub Profile
@m3talsmith
m3talsmith / tile.haml
Created May 2, 2013 21:38
Link_to block with metro UI tile
= link_to '/manage/#/inventory/items', class: 'tile icon bg-color-green' do
.tile-content
%h1.icon-large.icon-box
.brand Items
@m3talsmith
m3talsmith / help-section.haml
Last active December 16, 2015 15:38
block level 'a'
.help-section
%h4 Getting Started
%ul
%li
= link_to "/help/account_settings", class: 'menu-item' do
%span Account Registration
.next-arrow
@m3talsmith
m3talsmith / CFLAGS="-03"
Created April 5, 2013 20:54
cpuminer compiling issues.
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
It was created by cpuminer configure 2.2.3, which was
generated by GNU Autoconf 2.69. Invocation command line was
$ ./configure CFLAGS=-03
## --------- ##
## Platform. ##
@m3talsmith
m3talsmith / asset.rb
Created March 25, 2013 21:36
conditional paperclip
class Asset
if Rails.environment.production?
has_mongoid_attached_file :image, styles: {}, storage: :s3, s3_credentials: 'blah' # etc...
else
has_mongoid_attached_file :image, styles: {}
end
end
@m3talsmith
m3talsmith / field-style-1.js
Created March 6, 2013 20:36
Two separate styles of instantiating a user with attributes. The first way allows us to have attributes to validate against; only adding only the attributes that were passed in initially. The second way does no validation, and just accepts the hash passed in.
var User = RestfulModel.generate('User', ['name', 'age']);
var user = new User({name: 'Michael', age: '34', dob: '06/03/1978'});
class ProtectedController << ApplicationController
before_filter :force_user
def index
end
private
def force_user
unless session[:user_id]
session[:redirect_url] = request.fullpath
redirect_to new_sessions_path
@m3talsmith
m3talsmith / fileUploader.coffee
Last active December 13, 2015 18:38
A drag and drop file uploader
class @FileUploader
constructor: (@dropAreaSelector, @resultAreaSelector, @ajaxUrl) ->
dropArea = document.querySelectorAll(@dropAreaSelector)[0]
dropArea.addEventListener 'dragenter', @noop, false
dropArea.addEventListener 'dragexit', @noop, false
dropArea.addEventListener 'dragover', @noop, false
dropArea.addEventListener 'drop', @dropFiles, false
selectArea = document.getElementById('file-input')
@m3talsmith
m3talsmith / node-and-npm-in-30-seconds.sh
Last active December 12, 2015 12:19 — forked from twilson63/mac-osx.sh
Edited for zshell
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.zshrc
. ~/.zshrc
mkdir ~/local
mkdir ~/node-latest-install
cd ~/node-latest-install
curl http://nodejs.org/dist/node-v0.2.3.tar.gz | tar xz --strip-components=1
./configure --prefix=~/local
make install
wget http://npmjs.org/install.sh | sh
@m3talsmith
m3talsmith / sales_controller.rb
Last active December 11, 2015 23:08
Make sure a sale has a user
class Manage::SalesController << ManageController
before_filter :find_sale, except: [:new, :complete]
before_filter :force_order_has_user, except: [:new, :create]
# ...
private
def force_order_has_user
unless @order.user
redirect_to [:manage, @order, :user]
end
end
Spine = require('spine')
class Clicky extends Spine.Controller
className: 'clicky'
events:
'click .clicky': 'clickity'
constructor: ->
super