Skip to content

Instantly share code, notes, and snippets.

# xkpasswd config: https://xkpasswd.net/s/
{
"num_words": 4,
"word_length_min": 4,
"word_length_max": 8,
"case_transform": "ALTERNATE",
"separator_character": "-",
"padding_digits_before": 0,
"padding_digits_after": 0,
@tmarkiewicz
tmarkiewicz / delayed_statsmix.rb
Created August 9, 2012 20:11 — forked from djscruggs/delayed_statsmix.rb
A wrapper class for using StatsMix with DelayedJob
# A wrapper class for using StatsMix with DelayedJob
# Arguments to DelayedStatsmix.new should match the order and types in the StatsMix gem
# Gem documentation: http://www.statsmix.com/developers/ruby_gem
# Usage example: Delayed::Job.enqueue DelayedStatsmix.new('name of metric',100,:meta =>{'category'=>'ice cream','flavor'=>'chocolate'})
class DelayedStatsmix
def initialize(name,*optional)
optional ||= []
@name = name
@value = 1
@tmarkiewicz
tmarkiewicz / posts_controller.rb
Created July 25, 2012 19:43
Example of using StatsMix in a Rails controller
class PostsController < ApplicationController
# POST /posts
# POST /posts.json
def create
@post = Post.new(params[:post])
respond_to do |format|
if @post.save
@tmarkiewicz
tmarkiewicz / statsmix_webhooks.txt
Created January 13, 2012 16:20
Webhook format in StatsMix
# value of 1 only
http://statsmix.com/api/v2/stats?api_key=API_KEY&value=1&profile_id=123&metric_id=12345
# with metadata
http://statsmix.com/api/v2/stats?api_key=API_KEY&alue=1&profile_id=123&metric_id=12345&meta={%22source%22:%22github%22,%22author%22:jsmith}
@tmarkiewicz
tmarkiewicz / statsmix_curl.txt
Created January 3, 2011 22:05
Example Curl usage for the StatsMix API.
Curl is the easiest way to get started with the StatsMix API. Full documentation on how to use curl can be found here: http://curl.haxx.se/docs/manpage.html
In the following examples, user variables are indicated by uppercase (ex. API_KEY). Date values should be specific in the following format: YYYY-MM-DD (ex. 2010-02-22)
Create a stat (POST):
curl -H "X-StatsMix-Token: API_KEY" -d "value=VALUE&profile_id=2&metric_id=1&generated_at=2010-02-22" statsmix.com/api/v1/stats
--or--
curl -d "value=VALUE&profile_id=PROFILE_ID&metric_id=METRIC_ID&generated_at=2010-02-22&api_key=API_KEY" statsmix.com/api/v1/stats
Show a stat (GET):
@tmarkiewicz
tmarkiewicz / statsmix.rb
Created January 2, 2011 22:38
Example Ruby code for the StatsMix API.
# Full documentation for the StatsMix API can be found here: http://www.statsmix.com/developers
# In this example, a stat is posted using Ruby's net/http library.
require 'rubygems'
require 'net/http'
require 'uri'
require 'json'
url = URI.parse("http://api.statsmix.com/api/v1/stats")
http = Net::HTTP.new(url.host, url.port)
@tmarkiewicz
tmarkiewicz / statsmix.py
Created December 9, 2010 21:10
Python code to access the StatsMix API
# send a new stat to a metric
import httplib
import urllib
params = urllib.urlencode({'metric_id': XXXXX, 'value': 1})
# generated_at is set to now by default, to explicitly set use the following:
# params = urllib.urlencode({'metric_id': 4877, 'value': 1, 'generated_at':'2012-07-08 12:33:53'})
headers = {'X-StatsMix-Token': 'STATSMIX_API_KEY'}
conn = httplib.HTTPConnection('api.statsmix.com:80')
conn.request('POST', '/api/v2/stats', params, headers)
response = conn.getresponse()
You are here:
<%= trail.to_html(response) %>
desc 'Print out all defined routes in match order, with names. Target specific controller with CONTROLLER=x.'
task :routes => :environment do
all_routes = ENV['CONTROLLER'] ? ActionController::Routing::Routes.routes.select { |route| route.defaults[:controller] == ENV['CONTROLLER'] } : ActionController::Routing::Routes.routes
routes = all_routes.collect do |route|
name = ActionController::Routing::Routes.named_routes.routes.index(route).to_s
verb = route.conditions[:method].to_s.upcase
segs = route.segments.inject("") { |str,s| str << s.to_s }
segs.chop! if segs.length > 1
reqs = route.requirements.empty? ? "" : route.requirements.inspect
{:name => name, :verb => verb, :segs => segs, :reqs => reqs}