Skip to content

Instantly share code, notes, and snippets.

foreach($post_params as $key => $value) {
$sanitized_value = sanitize($value);
$regex = '/\<\$' . $key . '\>/';
$template_content = preg_replace($regex, $sanitized_value, $template_content);
}
// lol
def has_permission(name)
(p = permissions.detect{|p| p[:name] == name } ) ? p[:active] : false
end
def has_one_of_permissions(ps)
ps = [ps].flatten
ps.each do |p|
return true if has_permission(p)
end
false
@nikz
nikz / keybase.md
Created April 14, 2015 13:40
Keybase Verification thingee

Keybase proof

I hereby claim:

  • I am nikz on github.
  • I am nikz (https://keybase.io/nikz) on keybase.
  • I have a public key whose fingerprint is B845 DD4A 4A04 B17C 2C23 D7A6 D981 C76C FDC3 482F

To claim this, I am signing this object:

// ...
countries: {
nz: "Awesome",
au: "Boo"
}
// ...
require 'rubygems'
require 'httparty'
require 'active_support/all'
class TogglClient
USER_AGENT = "TogglToInvoicedGuide"
include HTTParty
base_uri "https://toggl.com/reports/api/v2/"
alias push="rake test && git push" # Cheapskate's CI
>> HashWithIndifferentAccess.new.is_a? Hash
=> true
require 'mechanize'
# scrapes Xero for our bank balances and stuff
class XeroScraper
XERO_USERNAME = "xero username"
XERO_PASSWORD = "xero password"
class Account
class Time
cattr_accessor :frozen_to
class << self
def now_with_freezing
if @@frozen_to
@@frozen_to
else
class String
def jammize
gsub(/\s/, '').underscore
end
end
"My Whatevers".jammize #=> "my_whatevers"