Skip to content

Instantly share code, notes, and snippets.

View mferrier's full-sized avatar

Mike Ferrier mferrier

View GitHub Profile

Keybase proof

I hereby claim:

  • I am mferrier on github.
  • I am mef (https://keybase.io/mef) on keybase.
  • I have a public key ASB9e_IpYPfyAs1mMSPlTHMLk8qLm8aG_96sxeOmJr5lugo

To claim this, I am signing this object:

@mferrier
mferrier / about.md
Last active August 29, 2015 14:06 — forked from antichris/about.md

Fork your own Gist

This is a bookmarklet that adds a fully functional Fork button to your own Gist.

If a Fork button is already present in the page, this bookmarklet will set focus to it instead of adding another one.

The change is temporary and the button will disappear as soon as you navigate away from that Gist (clicking the Fork button does this for you as well).


@mferrier
mferrier / dotted_hash.rb
Created July 19, 2013 15:33
hash value by dotted string key
# hash = {'a' => {'b' => {'c' => 1}}}
# path = "a.b.c"
# hash_value_by_dotted_notation(hash, path)
# => 1
# invalid path returns nil
def hash_value_by_dotted_notation(hash, dotted_path)
val = hash
dotted_path.to_s.split(".").each do |k|
val = (val.is_a?(Hash) && val.has_key?(k)) ? val[k] : nil
end
@mferrier
mferrier / debugjs.js
Created August 21, 2012 16:41
debugjs.js
var LOG_FN = function(name) {
window.fn_counts = window.fn_counts || {};
if (window.fn_counts[name] === undefined) {
window.fn_counts[name] = [1,1];
} else {
window.fn_counts[name][0] += 1;
window.fn_counts[name][1] += 1;
}
console.log("calling " + name + " (" + window.fn_counts[name][0] + " recent, " + window.fn_counts[name][1] + " all time)");
def add1(arr, val, n)
limit = (n == 0 ? arr.length : n.abs)
enumerator = (n < 0 ? (arr.length-1).downto(0) : (0).upto(arr.length-1))
enumerator.each do |i|
if arr[i] == val
arr[i] += 1
limit -= 1
end
@mferrier
mferrier / raw_redis_response.txt
Created July 3, 2012 14:48
lua-redis-parser bug
$96078
<!DOCTYPE html>
<!-- Marketing 2 -->
<html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript">
var _kmq = _kmq || [];
function _kms(u){
setTimeout(function(){
var s = document.createElement('script'); var f = document.getElementsByTagName('script')[0]; s.type = 'text/javascript'; s.async = true;
@mferrier
mferrier / gist:1690318
Created January 27, 2012 18:55
disabling engineyard asset pipeline precompilation
13:04 < mferrier> Hey guys, on the rails 3.1 stack, anyone know how I would prevent the asset pipeline precompile from running?
13:06 < emachnic> mferrier: http://docs.engineyard.com/asset-pipeline.html
13:08 < mferrier> so I read, but I still want to be able to use the asset pipeline.
13:08 < mferrier> I just don't want the precompile step during deployments.
13:10 < emachnic> mferrier: Should be able to set config.assets.precompile to false IIRC
13:15 < mferrier> ah, I'm not explaining properly. I'm precompiling locally and committing the result into the repo. So I still want to be able to rake assets:precompile locally, but just not have that task happen in the engineyard stack.
13:15 < mferrier> changing the rails asset pipeline setup will prevent the local precompilation.
13:15 < emachnic> mferrier: Ahh. Let me check real quick
13:20 < adamholt> emachnic: mferrier: if you add your assets to public/assets we skip compiling them on the server - https://github.com/engineyard/engineyard-serverside/blob/maste
in /engineyard/bin/passenger_monitor change:
if [[ $app_real -gt $limit ]]; then
kill -6 $app_pid
logger -t passenger_monitor -s "Killing PID $app_pid (app $app_name) - memory $app_real MB exceeds $limit MB"
fi
to
/* Copyright (c) 2011 Dirk-Willem van Gulik, All Rights Reserved.
* <dirkx(at)webweaving(dot)org>
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
dyld: lazy symbol binding failed: Symbol not found: _png_sig_cmp
Referenced from: /usr/local/rvm/gems/ruby-1.8.7-p330@default/gems/phashion-1.0.3/lib/phashion_ext.bundle
Expected in: flat namespace
dyld: Symbol not found: _png_sig_cmp
Referenced from: /usr/local/rvm/gems/ruby-1.8.7-p330@default/gems/phashion-1.0.3/lib/phashion_ext.bundle
Expected in: flat namespace