Skip to content

Instantly share code, notes, and snippets.

View leonprime's full-sized avatar

Leon Torres leonprime

  • SupplyFrame, Inc.
  • Pasadena, CA
View GitHub Profile
#!/usr/bin/env ruby
#
# to run this, you'll need two gems:
# gem install sinatra httparty
#
# run like this:
# ruby server.rb
#
# go to http://localhost:4567/ and then after authorizing, you should get back /v1/projects JSON response
#
@leonprime
leonprime / gist:5548989
Created May 9, 2013 17:17
script to monitor WAL lag in bytes between slave and master
#!/usr/bin/env ruby
#
# Script to montior WAL lag in bytes between master and slave.
# This script should be run from the slave.
#
require 'socket'
require 'rubygems'
require 'graphite-api'
# configurables
this is a test
@leonprime
leonprime / gist:5548434
Created May 9, 2013 16:07
xlogid definition in PostgreSQL bufpage.h
/*
* For historical reasons, the 64-bit LSN value is stored as two 32-bit
* values.
*/
typedef struct
{
uint32 xlogid; /* high bits */
uint32 xrecoff; /* low bits */
} PageXLogRecPtr;
@leonprime
leonprime / gist:5548392
Created May 9, 2013 16:01
sample from pg_current_xlog_location
postgres=# select * from pg_current_xlog_location();
pg_current_xlog_location
--------------------------
6F/E3C53568
(1 row)
@leonprime
leonprime / how-to-plot-mouse-data-set.R
Last active December 16, 2015 20:19
How to plot mouse data set in R
library(ggplot2)
mouse <- read.csv("~/R/mouse.csv", sep=" ")
# create plot
p <- ggplot(mouse, aes(x=x,y=y))
p <- p + geom_point(aes(color = actual))
p <- p + ggtitle("Mouse data set")
p <- p + xlim(c(0,1)) + ylim(c(0,1))
# now render it