Skip to content

Instantly share code, notes, and snippets.

View brianr's full-sized avatar

Brian Rue brianr

View GitHub Profile
@brianr
brianr / fabfile.py
Created August 16, 2012 00:10
Simple deploy script with Fabric
import sys
from fabric.api import run, local, cd, env, roles, execute
import requests
env.roledefs = {
'web': ['web1', 'web2']
}
@brianr
brianr / fabfile.py
Created August 16, 2012 01:15
Simple deploy script with Fabric
import sys
from fabric.api import run, local, cd, env, roles, execute
import requests
env.hosts = ['web1', 'web2']
def deploy():
# pre-roll checks
@brianr
brianr / fabfile.py
Created August 16, 2012 01:17
Simple deploy script with Fabric, with @roles
import sys
from fabric.api import run, local, cd, env, roles, execute
import requests
env.roledefs = {
'web': ['web1', 'web2']
}
@brianr
brianr / test.py
Created December 4, 2012 00:04
sample ratchet.io. api usage including custom fingerprint and title
import json
import time
import requests
access_token = 'xxxxx'
payload = {
'access_token': access_token,
@brianr
brianr / hi.rb
Last active March 30, 2016 21:36
basic Rollbar usage with sinatra
require 'sinatra'
require 'rollbar'
configure do
Rollbar.configure do |config|
config.access_token = 'aaaabbbbccccddddeeeeffff00001111'
config.environment = 'sinatra-test'
end
end
@brianr
brianr / deploy.rb
Created December 4, 2012 15:57 — forked from mertonium/deploy.rb
Capistrano task to notify Ratchet.io about deployment
# I am trying out Ratchet.io and I want to add their deployment notification to my
# normal capistrano deployment process. Here is my first working attempt.
# Add this task to your deploy.rb
task :notify_ratchetio, :roles => :app do
set :revision, `git log -n 1 --pretty=format:"%H"`
set :local_user, `whoami`
set :ratchetio_token, YOUR_ACCESS_TOKEN
rails_env = fetch(:rails_env, "production")
run "curl https://submit.ratchet.io/api/1/deploy/ -F access_token=#{ratchetio_token} -F environment=#{rails_env} -F revision=#{revision} -F local_username=#{local_user}", :once => true
@brianr
brianr / wtf.md
Created December 4, 2012 19:59
WTF of the day: MySQL integer<->string comparison gotcha

To implement Ratchet.io's Person Tracking feature, we have a MySQL table like this:

create table person (
  id int unsigned not null,
  project_id int unsigned not null
  environment varchar(255) not null,
  person_id varchar(40) not null,
  username varchar(255),
  email varchar(255),
@brianr
brianr / output
Created January 9, 2013 03:29
PHP - detect parse errors via shutdown handler
Brian-Rues-MacBook-Pro:test brian$ php parse_error_1.php
Parse error: parse error in /Users/brian/www/ratchetio-php/test/parse_error_2.php on line 2
in shutdown handler
last error:
array(4) {
["type"]=>
int(4)
["message"]=>
string(11) "parse error"
@brianr
brianr / resolve_example.php
Created January 9, 2013 23:57
Ratchet.io API example: resolving an item through the API
<?php
// needs to have the 'write' scope. see the Security tab on the project settings page.
$access_token = 'access-token-here';
$item_id = 12345;
// acceptable values: 'resolved', 'active', 'muted'
$new_status = 'resolved';
$url = 'https://submit.ratchet.io/api/1/item/' . $item_id . '?access_token=' . $access_token;
$ch = curl_init($url);
@brianr
brianr / test.php
Last active December 14, 2015 09:50
Example usage of rollbar.php with a logger
<?php
require_once('rollbar.php');
class EchoLogger {
public function log($level, $message) {
echo "[Rollbar] $level $message\n";
}
}