Skip to content

Instantly share code, notes, and snippets.

View mjc-gh's full-sized avatar
🎯
Open Sourcing

Michael Coyne mjc-gh

🎯
Open Sourcing
View GitHub Profile
@mjc-gh
mjc-gh / Gemfile
Created August 18, 2016 16:27
Devise::Async::Stretch
gem 'devise-async-stretch'
@mjc-gh
mjc-gh / application_controller.rb
Last active August 17, 2016 17:41
Simon Says Authorizer
class ApplicationController < ActionController::Base
include SimonSays::Authorizer
self.default_authorization_scope = :current_user
end
@mjc-gh
mjc-gh / admin.rb
Last active August 17, 2016 17:37
Simon Says Roleable
class Admin < ActiveRecord::Base
include SimonSays::Roleable
has_roles :design, :support, :moderator, as: :access
end
# > Admin.new.access
# => []
# > Admin.new(access: :support).access
@mjc-gh
mjc-gh / reporters_controller.rb
Created August 17, 2016 17:09
Simon Says Example
class ReportsController < ApplicationController
authorize_resource :admin, :support
find_resource :report, from: :current_admin, except: [:index, :new, :create]
end
# http://www.barkingiguana.com/2010/04/11/a-one-line-web-server-in-ruby/
ruby -rwebrick -e'WEBrick::HTTPServer.new(port: ARGV.pop.to_i, BindAddress: ARGV.pop.to_s, DocumentRoot: Dir.pwd).start'
st# status bar
set-option -g status-utf8 on
# https://github.com/seebi/tmux-colors-solarized/blob/master/tmuxcolors-256.conf
set-option -g status-bg colour235 #base02
set-option -g status-fg colour136 #yellow
set-option -g status-attr default
# default window title colors
set-window-option -g window-status-fg colour244 #base0
@mjc-gh
mjc-gh / example_1.js
Last active June 1, 2016 14:11
JavaScript Code Examples
// Sample A
var x = y;
function y(){};
// Sample B
var a = b;
var b = function(){};
// Sample C
i = j;
@mjc-gh
mjc-gh / the_national_fetcher.rb
Last active August 29, 2015 14:02
Fetch all The National song lyrics from wikia
require 'fileutils'
require 'nokogiri'
require 'open-uri'
doc = Nokogiri::HTML(open('http://lyrics.wikia.com/The_National'))
doc.css('h2').each do |header|
img = header.next_element
list = img.next_element if img
if list && list.name == 'ol'
### Keybase proof
I hereby claim:
* I am mikeycgto on github.
* I am mikeycgto (https://keybase.io/mikeycgto) on keybase.
* I have the public key with fingerprint 3339&nbsp;7AF8&nbsp;1078&nbsp;43C9&nbsp;B661&nbsp;&nbsp;B3AE&nbsp;9EB4&nbsp;65BB&nbsp;A866&nbsp;703F
To claim this, I am signing this object:
@mjc-gh
mjc-gh / page_visibility.js
Created November 6, 2013 21:43
Page visibility jQuery API
(function($){
var prop = 'VisibilityState';
var evt = 'visibilitychange';
var vendors = ['webkit', 'ms'];
var vendor;
function set_state(state){
$(window).trigger('visibilitychange', state);