Skip to content

Instantly share code, notes, and snippets.

# Ability Class
class AdminAbility
include CanCan::Ability
def initialize(user)
if user && user.admin?
can :access, :rails_admin
can :manage, :all
end
@TigerWolf
TigerWolf / inspiration.java
Last active August 29, 2015 14:05
Inspiration
.
@TigerWolf
TigerWolf / gist:8d4b7201809a510be5f5
Created October 6, 2014 22:23
Fix audio after sleep OSX
sudo kextunload /System/Library/Extensions/AppleHDA.kext
sudo kextload /System/Library/Extensions/AppleHDA.kext
sudo killall coreaudiod
keys = json.keys # org.json.JSONObject
array = []
hash = {}
while keys.hasNext
array << keys.next
end
for i in array
class MyPostRequest < Com::Android::Volley::Request
def parseNetworkResponse(response)
p "parseNetworkResponse"
jsonString = response.data
p jsonString.toString
return Com::Android::Volley::Response.success(jsonString, Com::Android::Volley::Toolbox::HttpHeaderParser.parseCacheHeaders(response))
end
def deliverResponse(response)
class AlertHelper
def initialize(activity, listener = nil)
@activity = activity
@listener = listener
@listener = self if listener.nil?
@ok = false
end
def dialog(title, message)
r_string_yes = 17039379
@TigerWolf
TigerWolf / e24payment.php
Created October 9, 2012 11:48
adding debug statement
<?php
/*
* e24PaymentPipe
*
*
* e24payment-php is an implementation in PHP of E24PaymentPipe
* java classes. It allows to connect to online credit card payment
* from http://www.aciworldwide.com/.
*

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

class PerformanceWorker
include Wisper
def perform
publish(:start_download, self)
PerformanceDownloader.new(url, attributes)
publish(:finish_download, self)
Transaction.start
publish(:import_start, self)
PerformancePurger.new(dbtable)