Skip to content

Instantly share code, notes, and snippets.

View pboling's full-sized avatar
🏓
Ping me if you need me!

Peter Boling pboling

🏓
Ping me if you need me!
View GitHub Profile

Keybase proof

I hereby claim:

  • I am tpitale on github.
  • I am tpitale (https://keybase.io/tpitale) on keybase.
  • I have a public key whose fingerprint is 6C17 F481 4889 B9AD 61EC 7719 A2EA 6E3E FD48 2FE3

To claim this, I am signing this object:

@emorikawa
emorikawa / gist:a091dfded1643ef86299
Created July 30, 2014 18:37
Convert RSpec `should` syntax to newer `expect` syntax
command! ShouldToExpect %s/\(^\s\+\)\(.\+\)\.should \(.\+\)/\1expect(\2).to \3/
@teamon
teamon / Gemfile
Created April 17, 2014 08:39
Mount Grape API at rails root
source "http://rubygems.org"
gem "railties", '4.0.3', require: %w(action_controller rails)
gem "grape"
@cjbottaro
cjbottaro / gist:9163450
Last active November 18, 2016 19:18
Memoizing in Ruby 2 with prepend
module Memoizable
def self.extended(mod)
mod.module_eval{ prepend(@memoizer = Module.new) }
end
def memoize(name)
@memoizer.module_eval do
define_method(name) do |*args, &block|
raise(ArgumentError, "cannot memoize method called with block") if block
@rietta
rietta / plpgsql.rake
Last active August 8, 2020 15:05
Are you using PostgreSQL and don't want to make your app run as PostgreSQL super user, then add this custom rake task to your `lib/tasks` folder and be happy.
#
# PostgreSQL writes two optional commands to the database schema
# file, called db/structure.sql, that can only be run as a root
# database user. These are not needed actually, so comment them
# out automatically
#
# CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
# COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
#
namespace :db do
module ActiveSupport::Concern
def append_features(base)
if base.instance_variable_defined?("@_dependencies")
base.instance_variable_get("@_dependencies") << { :module => self, :method => :include }
return false
else
return false if base < self
@_dependencies.each { |dep| base.send(dep[:method], dep[:module]) }
super
base.extend const_get("ClassMethods") if const_defined?("ClassMethods")
@jtdp
jtdp / gist:5443498
Last active January 24, 2024 08:59
Revert file permission changes in local git repository.. Very useful when you change permissions due to working on a samba share. Lifted from: http://stackoverflow.com/questions/2517339/git-how-to-recover-the-file-permissions-git-thinks-the-file-should-be
git diff -p \
| grep -E '^(diff|old mode|new mode)' \
| sed -e 's/^old/NEW/;s/^new/old/;s/^NEW/new/' \
| git apply
@ches
ches / follow_observer_spec.rb
Last active November 29, 2018 01:34
Example of testing Rails observers in isolation for cross-cutting concerns
require 'spec_helper'
# Bustle is a pubsub system used for activity streams:
# https://github.com/fredwu/bustle
#
# Here when a person follows another (or a discussion, for instance), the observer wires
# up pubsub between them for future activity notifications. The Follow model knows nothing
# about the implementation choices for the pubsub system.
describe FollowObserver do
subject { FollowObserver.instance }
bva@bva-X51L:~/work/performance_tests/sinatra-test$ ab -n 1000 -c 10 -t 8 0.0.0.0:3000/tests
This is ApacheBench, Version 2.3 <$Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 0.0.0.0 (be patient)
Finished 171 requests
Server Software: thin
@radiosilence
radiosilence / gist:4040553
Created November 8, 2012 18:19
RequireJS with Zurb Foundation
requirejs.config({
shim: {
'foundation/jquery.foundation.topbar': {
deps: ['jquery'],
},
'foundation/jquery.cookie': {
deps: ['jquery']
},
'foundation/jquery.event.move': {
deps: ['jquery']