Skip to content

Instantly share code, notes, and snippets.

View dplummer's full-sized avatar
🚘
robot cars!

Donald Plummer dplummer

🚘
robot cars!
View GitHub Profile
@dplummer
dplummer / application.rb
Last active August 26, 2015 21:06
log silencer
# config/application.rb
class Application < Rails::Application
require 'log_silencer'
config.middleware.insert_before Rails::Rack::Logger,
LogSilencer,
silenced: /^\/options/
end
@dplummer
dplummer / sinewave_button.css
Created April 18, 2014 22:29
Sinewave button CSS
.sinewave-button {
-webkit-background-clip: border-box;
-webkit-background-origin: padding-box;
-webkit-background-size: auto;
-webkit-box-shadow: rgba(0, 0, 0, 0.2) 0px 1px 0px 0px;
background-attachment: scroll;
background-clip: border-box;
background-color: transparent;
background-origin: padding-box;
background-size: auto;
@dplummer
dplummer / defer_touching.rb
Created May 14, 2014 05:11
Delay and prevent multiple touches
module DeferTouching
def self.defer_touching(*klasses, &block)
to_touch = Set.new
old_methods = klasses.inject({}) do |acc, klass|
acc[klass] = klass.instance_method(:touch)
acc
end
klasses.each do |klass|
@dplummer
dplummer / bloggo.conf
Created August 4, 2014 03:55
running go binary as service on ubuntu
# donaldplummer.com bloggo
description "donaldplummer.com blog"
start on (local-filesystems and net-device-up IFACE=lo and runlevel [2345])
stop on runlevel [!2345]
respawn
respawn limit 3 30
@dplummer
dplummer / alley.md
Last active August 29, 2015 14:23
calculate what players get free hand-me-down tanks from Armageddon

A total of 133 players will receive a free tank outside of what the top 30 clans get Created at 2015-06-20 08:53:49 -0700

Position Clan Licenses Used Unused
1 OTTER 100 72 28
2 ESPRT 100 62 38
3 PBKAC 100 60 40
4 BULBA 85 72 13
5 CHAI 60 60 0
@dplummer
dplummer / extend_response_time_logging.rb
Created January 5, 2011 23:35
Include in ApplicationController to bench calls and log them (like Rails does with View and DB)
module ExtendResponseTimeLogging
def self.included(base)
base.class_eval do
alias_method_chain :perform_action, :extra_benchmark
end
end
def bench(name, &block)
@additional_response_times[name] ||= 0.0
@additional_response_times[name] += Benchmark.ms {yield}
@dplummer
dplummer / table engine snippets
Created March 20, 2011 19:32
checking and altering table engines in mysql
# Find out what table engine your tables are using
select table_name, engine from information_schema.TABLES WHERE TABLE_SCHEMA = 'DATABASENAME';
# From bash, set the engine on all tables in a database to InnoDB
# Where /etc/mysql/debian.cnf has the root password for your mysql box
# Taken from http://kevin.vanzonneveld.net/techblog/article/convert_all_tables_to_innodb_in_one_go/
DATABASENAME="test"
for t in `echo "show tables" | mysql --defaults-file=/etc/mysql/debian.cnf --batch --skip-column-names $DATABASENAME`; do mysql --defaults-file=/etc/mysql/debian.cnf $DATABASENAME -e "ALTER TABLE $t ENGINE = InnoDB;"; done
@dplummer
dplummer / gist:1057203
Created June 30, 2011 20:48
Fix for rvm install 1.8.7 with glibc 2.14
glibc 2.14 breaks the install process for ruby 1.8.7 and ree 1.8.7.
Fix for ruby 1.8.7 install with rvm:
1. Run `rvm install ruby-1.8.7-p334`
2. Wait for it to fail.
3. Fix the broken files with:
cd ~/.rvm/src/ree-1.8.7-2011.03/source/ext/dl
rm callback.func
touch callback.func
ruby mkcallback.rb >> callback.func
@dplummer
dplummer / tcmalloc.patch
Created June 30, 2011 20:50
ree tcmalloc patch fix for glibc 2.14
diff -urB a/distro/google-perftools-1.7/src/tcmalloc.cc b/distro/google-perftools-1.7/src/tcmalloc.cc
--- a/distro/google-perftools-1.7/src/tcmalloc.cc
+++ b/distro/google-perftools-1.7/src/tcmalloc.cc
@@ -137,6 +137,13 @@
# define WIN32_DO_PATCHING 1
#endif
+// GLibc 2.14+ requires the hook functions be declared volatile, based on the value of the
+// define __MALLOC_HOOK_VOLATILE. For compatibility with older/non-GLibc implementations,
+// provide an empty definition.
@dplummer
dplummer / frontend.conf.patch
Created July 15, 2011 16:51
Patch for frontend.conf dev site rewrite
--- frontend.conf.original 2011-07-15 09:49:50.468952712 -0700
+++ frontend.conf 2011-07-15 09:55:06.948947048 -0700
@@ -39,6 +39,10 @@
if ($host ~* (.*)\.crystalcommerce\.com) {
set $client $1;
}
+ # get the client name if it matches client.crystalcommerce.com
+ if ($host ~* (.*)\.dev\.crystalcommerce\.com) {
+ set $client $1/dev;
+ }