Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am rlmattax on github.
  • I am bobmattax (https://keybase.io/bobmattax) on keybase.
  • I have a public key ASCsq2K6QQDv4NuSTmmG1xwQukQcn5WvzIyn1VCxwmYcewo

To claim this, I am signing this object:

<script src="//code.jquery.com/jquery-latest.min.js" type="text/javascript"></script>
<script src="//code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<script src="//beta.pactsafe.com/assets/pactsafe.js"></script>
<link href="//beta.pactsafe.com/assets/badge.css" media="screen" rel="stylesheet">
import sublime, sublime_plugin, os
class ExpandTabsOnSave(sublime_plugin.EventListener):
# Run ST's 'expand_tabs' command when saving a file
def on_pre_save(self, view):
if view.settings().get('expand_tabs_on_save') == 1:
view.window().run_command('expand_tabs')
@rlmattax
rlmattax / ActiveAdmin + Rolify -- Roles Administration
Created August 10, 2013 00:32
Active Admin + Rolify -- A simple example of modifying roles within active admin on users.
ActiveAdmin.register User do
index do
column "ID" do |user|
link_to user.id, admin_user_path(user)
end
...
column :roles do |user|
user.roles.collect {|c| c.name.capitalize }.to_sentence
end
default_actions
@rlmattax
rlmattax / gist:4628713
Created January 24, 2013 22:25
Sendgrid Listener
class ListenerController < ApplicationController
skip_before_filter :verify_authenticity_token
def receive_email
@params = params
@inbound_email = InboundEmail.new(:text => params["text"],
:html => params["html"],
:to => clean_field(params["to"]),
:from => clean_field(params["from"]),
@rlmattax
rlmattax / gist:3962926
Created October 27, 2012 04:20
Active Admin User Impersonation
ActiveAdmin.register User do
menu :parent => "Users"
member_action :impersonate, :method => :get do
user = User.find(params[:id])
flash[:notice] = "Successfully logged in as : #{user.email} #{view_context.link_to('Be careful!', root_path)}".html_safe
begin
warden.set_user(resource,{:scope=>:user,:run_callbacks=>false})
rescue
flash[:error] = "Unable to log you in. Poop."
@rlmattax
rlmattax / gist:3084374
Created July 10, 2012 16:11
.htaccess
Options -MultiViews
Options +FollowSymlinks
RewriteEngine on
RewriteBase /
# DEFAULT APP
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?req=$1 [L,QSA]
class BadUsernameMailer < ActionMailer::Base
layout 'mailer'
default from: "[email protected]"
def username_changed_email(user,old,new)
@old = old
@new = new
mail(:to => user.email, :subject => "uFlavor - Important Account Information - username changed")
end
end
@rlmattax
rlmattax / gist:1345791
Created November 7, 2011 18:47 — forked from datafatmunger/gist:1345641
Missile command
background-image: -webkit-gradient(linear, 0 0, 0 100%, color-stop(0, rgba(255,255,255,0)), color-stop(0.15, rgba(255,255,255,0.55)), color-stop(0.5, rgba(255,255,255,0))), -webkit-gradient(linear, 0 0, 0 100%, color-stop(0, #204db5), color-stop(0.1, #0251ae), color-stop(0.9, #6fc1ff), color-stop(1, #569ce1));
-webkit-mask-image: -webkit-gradient(linear, 18 0, 0 10, color-stop(0.23, rgba(0,0,0,0)), color-stop(0.3, rgba(0,0,0,0.8)), color-stop(0.4, rgba(0,0,0,1)), color-stop(0.7, rgba(0,0,0,1)), color-stop(0.7, rgba(0,0,0,0.8)), color-stop(0.77, rgba(0,0,0,0)));
-webkit-mask-repeat: repeat-x;
-webkit-mask-size: 20px 15px;
-webkit-mask-position: 0px;
module ApplicationHelper
FLASH_TYPES = [:notice, :error ]
def flash_messages
res = ""
FLASH_TYPES.each do |type|
res += content_tag(:div, flash[type], :class=>[type,"notification", "rounded-corners"]) if flash[type]
end
raw(res)
end
end