Skip to content

Instantly share code, notes, and snippets.

View c2k's full-sized avatar

Christopher Kobayashi c2k

  • Ikayzo, Inc.
  • Honolulu, Hawaii
View GitHub Profile
@c2k
c2k / index.html
Created July 26, 2013 00:06
Example of AngularJS Directive for Google Maps http://jsfiddle.net/dineshcooper/FLHET/
<script src="https://maps.googleapis.com/maps/api/js?sensor=false" type="text/javascript"></script>
<div ng-app="googleMap">
<div ng-controller="MapCtrl">
<map id="map_canvas1" zoom="12" center="{lat:-26.0833,lon:28.2500}" maptype="roadmap" scrollwheel="false"></map>
<map id="map_canvas2" zoom="8" center="{lat:-26.0833,lon:28.2500}" maptype="satellite" scrollwheel="true"></map>
</div>
</div>
When starting a project that includes refinerycms-blog:
$ rake refinery:override view=refinery/pages/*
$ rake refinery:override view=layouts/*
$ rake refinery:override view=refinery/blog/shared/*
$ rake refinery:override view=refinery/blog/posts/*
$ rake refinery:override view=refinery/*
$ rake refinery:override controller=refinery/blog/*
$ rake refinery:override controller=refinery/*
@c2k
c2k / inject_jquery.js
Created November 16, 2013 00:23
Inject jQuery into Google's search result page
// Run on Google search result page
(function() {
var jq = document.createElement('script'); jq.type = 'text/javascript'; jq.async = true;
jq.src = ('https:' == document.location.protocol ? 'https://' : 'http://') + 'code.jquery.com/jquery-latest.min.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(jq, s);
})();
@c2k
c2k / puma.md
Created June 11, 2014 21:14
Puma on Heroku

Notes from https://discussion.heroku.com/t/using-puma-on-heroku/150/11?u=ckobayashi

(Number of Puma workers per dyno * * max number of threads per worker * number of dynos) + headroom = number of required connections.

So in your case: 7 * 16(?) * 4(?) = 448 db connections

The max of 16 threads per worker is Puma's default and can be overridden to something more inline with your needs. In reality, you probably won't need all 448 connections since it's unlikely, but not impossible, that all threads will grab a connection from the pool at the same time.

To see what your actual connection usage is like, I would suggest taking a look at the Postgres metrics in your log stream to see how many connections are open at any one time (this is only available on production tier dbs):

@c2k
c2k / new_relic.md
Last active March 7, 2016 10:38
New Relic Agent in Rails Console

#New Relic

To enable the New Relic agent within Rails console

NEWRELIC_AGENT_ENABLED=true rails c

And then you can send errors

@c2k
c2k / resque.rake
Last active August 29, 2015 14:08 — forked from ewherrmann/resque.rake
require 'resque/tasks'
namespace :resque do
def del(key)
Resque.redis.keys(key).each { |k| Resque.redis.del(k) }
end
desc "Resque setup according to installation guide"
task :setup => :environment
#!/bin/sh
# Pivotal Tracker Ticket Extraction
# =================================
# Extract Pivotal Tracker ticket ID from branch name and prepend to commit
# message for GitHub hook.
#
# Takes a commit message like: "A commit comment" for branch "bug-1234-hello"
# and changes it to: "A commit comment [#1234]" for easier commit ticket
# updates.
https://www.pivotaltracker.com/help/api?version=v3#github_hooks
https://www.pivotaltracker.com/help/api?version=v3#scm_post_commit_message_syntax
SCM Post-Commit Message Syntax
To associate an SCM commit with a specific Tracker story, you must include a special syntax in the commit message to indicate one or more story IDs and (optionally) a state change for the story. Your commit message should have square brackets containing a hash mark followed by the story ID. If a story was not already started (it was in the "not started" state), a commit message will automatically start it. For example, if Scotty uses the following message when committing SCM revision 54321:
[#12345677 #12345678] Diverting power from warp drive to torpedoes.