This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class PostsController < ApplicationController | |
| # POST /posts | |
| # POST /posts.json | |
| def create | |
| @post = Post.new(params[:post]) | |
| respond_to do |format| | |
| if @post.save | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| You are here: | |
| <%= trail.to_html(response) %> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # make short links with Bit.ly | |
| link = 'http://www.google.com' | |
| short_link = open('http://bit.ly/api?url=' + link, "UserAgent" => "Ruby-ShortLinkCreator").read | |
| # => "http://bit.ly/AvxfY" |
NewerOlder