Skip to content

Instantly share code, notes, and snippets.

View rbazinet's full-sized avatar

Rob Bazinet rbazinet

View GitHub Profile
@rbazinet
rbazinet / es.sh
Created August 13, 2012 20:35 — forked from kajic/es.sh
Install ElasticSearch on Ubuntu 10.04/11.04
cd ~
sudo apt-get update
sudo apt-get install curl python-software-properties -y
sudo apt-get install openjdk-6-jre-headless
curl -L https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.18.7.tar.gz | tar -xz
sudo mv elasticsearch-* /usr/local/share/elasticsearch
curl -L http://github.com/elasticsearch/elasticsearch-servicewrapper/tarball/master | tar -xz
sudo mv *servicewrapper*/service /usr/local/share/elasticsearch/bin/
rm -Rf *servicewrapper*
@rbazinet
rbazinet / es.sh
Created November 29, 2012 16:01
Install ElasticSearch on Ubuntu 12.04
cd ~
sudo apt-get update
sudo apt-get install openjdk-7-jre -y
wget https://github.com/downloads/elasticsearch/elasticsearch/elasticsearch-0.19.0.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz
rm elasticsearch.tar.gz
sudo mv elasticsearch-* elasticsearch
sudo mv elasticsearch /usr/local/share
Assuming you have remote branch called heroku/master, start by creating a local tracking branch
called heroku.
> git checkout -b heroku -t heroku/master
This will checkout the last revision you deployed to Heroku.
Now tell git to push the heroku branch to heroku/master
> git config remote.heroku.push heroku:master
#!/usr/bin/env ruby
require 'net/http/persistent'
require 'uri'
require 'thread'
USAGE = <<EOS
Parse a Rails log file and send metrics to stathat
export EMAIL=email
@rbazinet
rbazinet / tinyurl.rb
Created June 6, 2013 12:10
Simple Ruby class to shorten URLs using TinyURL.
class Tinyurl
include HTTParty
base_uri 'tinyurl.com'
def shorten(url)
self.class.get("/api-create.php?url=#{url}")
end
end
@implementation UITextView (RSExtras)
static BOOL stringCharacterIsAllowedAsPartOfLink(NSString *s) {
/*[s length] is assumed to be 0 or 1. s may be nil.
Totally not a strict check.*/
if (s == nil || [s length] < 1)
return NO;
-- data structure for RGBA, RGB & CMYK colors
data Color = RGBA Float Float Float Float
| RGB Float Float Float
| CMYK Float Float Float Float
deriving (Eq, Ord, Show)
-- list of colors
colors = [ RGBA 0.1 0.1 0.5 0.2
, RGBA 1 1 0 0.9
, RGB 0.5 0.5 0
@rbazinet
rbazinet / README.md
Created March 9, 2016 20:35 — forked from derwiki/README.md
Ruby module that you can use in a `before_action` on sensitive controllers for which you'd like a usage audit trail

Adding an audit log to your Rails app

If you have any sort of administrative interface on your web site, you can easily imagine an intruder gaining access and mucking about. How do you know the extent of the damage? Adding an audit log to your app is one quick solution. An audit log should record a few things:

  • controller entry points with parameter values
  • permanent information about the user, like user_id
  • transient information about the user, like IP and user_agent

Using the Rails framework, this is as simple as adding a before_action to your admin controllers. Here’s a basic version that I’m using in production.

@rbazinet
rbazinet / AllCraigslistLocations
Created June 12, 2016 00:47 — forked from jeffThompson/AllCraigslistLocations
A list of all active Craigslist locations. Format as a URL using "http://<location>.craigslist.org".
auburn
bham
dothan
shoals
gadsden
huntsville
mobile
montgomery
tuscaloosa
anchorage
@rbazinet
rbazinet / uploads_controller.rb
Created June 16, 2016 13:33 — forked from longlostnick/uploads_controller.rb
Rails JSON file upload with carrierwave (from base64 string)
class Api::UploadsController < ApiController
def create
@upload = Upload.new(upload_params)
ensure
clean_tempfile
end
private