Skip to content

Instantly share code, notes, and snippets.

View JonathanTron's full-sized avatar

Jonathan Tron JonathanTron

View GitHub Profile
@limhoff-r7
limhoff-r7 / authenticate.ex
Created June 3, 2015 19:09
Authenticate user using session or params (uses session keys stuff from Authlogic in Rails). **NOTE: this is does no authorization, another plug needs to be written to require conn.assigns[:authorized_user] is set or that they have permissions to read records**
defmodule Metasploit.Pro.Plugs.Authenticate do
import Ecto.Query, only: [from: 2]
import Plug.Conn
def init(configuration) do
configuration
|> Keyword.put_new(:single_access_token_parm, "single_access_token")
|> valid_configuration!
end
@johnpaulashenfelter
johnpaulashenfelter / upgrade_homebrew_pg.sh
Created November 11, 2011 15:31
Upgrading homebrew postgres from 9.0.x to 9.1
Upgrading to homebrew postgresql 9.1.1 from 9.0.x
* Copy the old data
mv -R /usr/local/var/postgres/ /usr/local/var/postgres-901
* Create a new database using 9.1.1
/usr/local/Cellar/postgresql/9.1.1/bin/initdb /usr/local/var/postgres
@indirect
indirect / snippet.rb
Created November 17, 2011 17:44
Rack middleware so NewRelic shows time as ruby
# This adds a request header so NewRelic knows when the middleware stack
# started processing. Hopefully this means we'll get better metrics, split
# between actual request queueing and time spent in the middlewares.
module Plex
class MiddlewareStart
def initialize(app)
@app = app
end
def call(env)
@jbraeuer
jbraeuer / package-graphite.sh
Created February 1, 2012 08:43
Install graphite 0.9.9 on Ubuntu 11.10 using PACKAGES
#! /bin/bash
#
# This script needs "fpm". If you dont have it,
# run "gem install fpm"
#
# You also need to "apt-get install python-setuptools" (otherwise fpm fails)
clean() {
rm -rf whisper-0.9.9 carbon-0.9.9 graphite-web-0.9.9
@ryandotsmith
ryandotsmith / instruments.rb
Created April 6, 2012 07:09
Sequel & Sinatra Instrumentation
module Instruments
def self.set_logger(l, m)
@logger = l
@method = m
end
def self.logger
@logger
end
@ryanobjc
ryanobjc / pkg-graphite.sh
Created September 6, 2012 21:05
package up graphite using fpm
#!/bin/bash
VER=0.9.10
HERE=`pwd`
apt-get install python-setuptools python-django-tagging python-pysqlite2 python-memcache python-ldap python-django python-cairo-dev
wget https://launchpad.net/graphite/0.9/${VER}/+download/graphite-web-${VER}.tar.gz
wget https://launchpad.net/graphite/0.9/${VER}/+download/carbon-${VER}.tar.gz
@wesgarrison
wesgarrison / gist:3921560
Created October 20, 2012 01:10
October 19 2012 - rubygems.org - notes on server

[transcript from http://www.youtube.com/watch?v=z73uiWKdJhw and irc]

Why is the server unhappy?

  • Bundle API is 70%-80% of traffic and it has to resolve the dependency graph and Marshal
  • x Processes are spinning in Ruby with 380% (of 400% total CPU [4 x 100%])
  • x Bundle can only use vanilla gems, so that's why we have to use Marshal
  • Redis Heapsize
  • Diskspace

Timing - middle of the day US

@manpages
manpages / elixir-newbie-digest-002.md
Last active December 11, 2015 22:39
Elixir Newbie Digest, Issue 2

Intro

Today I'll cover three basic topics:

  • Mistakes and misuses every Erlanger does when he starts to write in Elixir

  • Dependencies and Mix

  • Writing OTP-enabled Elixir applications

@adamhjk
adamhjk / Guardfile
Last active December 17, 2015 03:19
A Guardfile with inline support for test-kitchen, before we turn it into a gem.
# A sample Guardfile
# More info at https://github.com/guard/guard#readme
require 'guard/guard'
require 'mixlib/shellout'
module ::Guard
class Kitchen < ::Guard::Guard
def start
::Guard::UI.info("Guard::Kitchen is starting")
@xaviershay
xaviershay / ruby_live_gc_stats.rb
Created November 10, 2013 21:17
naive jstat proof-of-concept for ruby
Thread.new do
GC::Profiler.enable
current_message = ""
epoch = Time.now
total_time = 0
gc_events = 0
heap_use = 0
heap_size = 0
fmt = "%7s %5s %15s %15s %10s"