Skip to content

Instantly share code, notes, and snippets.

View Narnach's full-sized avatar

Wes Oldenbeuving Narnach

View GitHub Profile
@Narnach
Narnach / application.rb
Created July 16, 2014 09:57
Simple memory usage counter which diffs vs the last call. Built for rails, but can work anywhere.
# Add this to the very TOP of config/application.rb, before the first statement
require 'pp'
module OSCount
def self.count(msg, force_count: false)
return if ENV['RAILS_ENV'] == 'test'
count = ObjectSpace.count_objects
last_count = Thread.current['OSCount.last_count']
Thread.current['OSCount.last_count'] = count
show_count = last_count.nil?
show_count = true if force_count
@Narnach
Narnach / gist:10017973
Created April 7, 2014 10:32
Spotify console log
07/04/14 12:28:14,229 Spotify Helper[3900]: Internals of CFAllocator not known; out-of-memory failures via CFAllocator will not result in termination. http://crbug.com/45650
07/04/14 12:28:14,353 Spotify Helper[3900]: The function `CGFontSetShouldUseMulticache' is obsolete and will be removed in an upcoming update. Unfortunately, this application, or a library it uses, is using this obsolete function, and is thereby contributing to an overall degradation of system performance.
07/04/14 12:28:44,031 Spotify Helper[3903]: Internals of CFAllocator not known; out-of-memory failures via CFAllocator will not result in termination. http://crbug.com/45650
07/04/14 12:28:44,293 Spotify Helper[3903]: The function `CGFontSetShouldUseMulticache' is obsolete and will be removed in an upcoming update. Unfortunately, this application, or a library it uses, is using this obsolete function, and is thereby contributing to an overall degradation of system performance.
@Narnach
Narnach / session.rb
Last active August 29, 2015 13:57
A more efficient way to store data in the DB than the default approach of doing a raw Base64 on the Marshal-ed version of a session hash.
# Add this to your Gemfile:
#
# # Session store built on top of ActiveRecord
# gem 'activerecord-session_store', github: 'rails/activerecord-session_store'
# # C-based parser backend for multi_json
# gem 'oj'
# # Unified API for parsing JSON
# gem 'multi_json'
#
class Session < ActiveRecord::SessionStore::Session

Keybase proof

I hereby claim:

  • I am Narnach on github.
  • I am narnach (https://keybase.io/narnach) on keybase.
  • I have a public key whose fingerprint is 7655 6328 F92B 8BAC 788C DB71 AF8B 92CD AB84 DCD1

To claim this, I am signing this object:

@Narnach
Narnach / appsignal.cap
Created March 7, 2014 13:05
Appsignal capistrano 3 recipe
# lib/capistrano/tasks/appsignal.cap
require 'appsignal'
require 'appsignal/marker'
namespace :appsignal do
task :deploy do
env = fetch(:rails_env, fetch(:rack_env, 'production'))
user = ENV['USER'] || ENV['USERNAME']
@Narnach
Narnach / deploy.rb
Last active December 20, 2015 03:19
deploy.rb replacement for semaphore continuous deployment
# The *real* deploy.rb is located in config/deploy_semaphore.rb
#
# http://semaphoreapp.com performs continuous deployment for us, so we should not perform manual deployments.
# This disables cap deploy, cap deploy:migrations and cap deploy:upload, our most frequently used tasks.
#
# On the semaphore side, use this as the deployment commands to make this work:
#
# mv config/deploy_semaphore.rb config/deploy.rb
# bundle install --path vendor/bundle
# bundle exec cap -S revision=$REVISION deploy:migrations
@Narnach
Narnach / deploy.rb
Created December 13, 2012 16:20 — forked from anonymous/deploy.rb
desc "precompile assets (only if needed)"
task :precompile_assets do
puts "Diffing assets to check if we need to precompile"
precompile = true
# Only do this if we have a previous release
# Do a normal precompile on a force precompile
if previous_release && latest_release && !ENV['FORCE_PRECOMPILE']
puts "Comparing asset sources of #{previous_release} and #{latest_release}."
diff --git a/ext/common/ApplicationPool2/Pool.h b/ext/common/ApplicationPool2/Pool.h
index e5cd3a8..82ca754 100644
--- a/ext/common/ApplicationPool2/Pool.h
+++ b/ext/common/ApplicationPool2/Pool.h
@@ -482,6 +482,14 @@ public:
typedef shared_ptr<ProcessAnalyticsLogEntry> ProcessAnalyticsLogEntryPtr;
void collectAnalytics(ev::timer &timer, int revents) {
+ try {
+ realCollectAnalytics(timer);
# Require this from spec/spec_helper.rb or include it there to make Factory.create!(:model) work
require 'factory_girl'
module FactoryCreateBang
def create!(*args,&block)
object = self.build(*args, &block)
object.save!
object
end
end
# Created by RailsBoost.com
# Generated at Sat Dec 05 00:52:39 -0800 2009
# Generator by Hampton Catlin
# Modified by Wes Oldenbeuving
############## gem commands #################
# environment.rb
gem 'haml'
gem 'mysql'