Skip to content

Instantly share code, notes, and snippets.

View tcocca's full-sized avatar

Tom Cocca tcocca

  • Boston Logic Technology Partners, Inc.
  • Boston, MA
View GitHub Profile
{
"access": {
"token": {
"id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"expires": "2014-11-24T22:05:39.115Z",
"tenant": {
"id": "110011",
"name": "110011"
},
"RAX-AUTH:authenticatedBy": [
@tcocca
tcocca / backup.sh
Created November 29, 2013 05:37 — forked from karussell/backup.sh
# TO_FOLDER=/something
# FROM=/your-es-installation
DATE=`date +%Y-%m-%d_%H-%M`
TO=$TO_FOLDER/$DATE/
echo "rsync from $FROM to $TO"
# the first times rsync can take a bit long - do not disable flusing
rsync -a $FROM $TO
# now disable flushing and do one manual flushing
@tcocca
tcocca / query.json
Last active December 25, 2015 00:09 — forked from danmactough/query.json
{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"bool": {
"must_not": [
{"term": {"topic_ids": "NTfaluJAzhU6ajVN"}},
@tcocca
tcocca / stylesheet_check.rb
Created December 18, 2012 16:47
Read through stylesheets and determine images that are missing from the file system that are referenced in the stylesheet, print a report of those images for each file
stylesheets_path = File.join(Rails.root, 'public', 'stylesheets')
Dir.glob("#{stylesheets_path}/*/**/*.css").each do |css_file|
data = File.read(css_file)
matches = data.scan(/url\([\s"']*([^\)"'\s]*)[\s"']*\)/m).collect do |match|
match.first
end
uniq_matches = matches.uniq
report_matches = {}
unless uniq_matches.blank?
matches.uniq.each do |match|
@tcocca
tcocca / walkscore.rb
Created January 5, 2012 15:44 — forked from DemitryT/walkscore.rb
walkscore.rb
require 'httparty'
class Walkscore
include HTTParty
default_params :format => 'json'
attr_accessor :api_key, :property
def initialize(api_key, property)
self.api_key = api_key
ProductsController.class_eval do
respond_to :html, :js
def show
product_source = Product.find_by_permalink!(params[:id])
@product = ProductDecorator.new(product_source)
return unless @product
if params[:option_values]
option_values_ids = [
module Sunspot
module SessionProxy
class NamespacedSessionProxy
class MultipleConnectionsError < StandardError
def initialize
super("Can not perform operations against multiple namespaced (connections)")
end
end
class NotImplementedError < StandardError
def initialize
require 'spec_helper'
inputs = [:path, :hash, :file, :tempfile, :stringio]
outputs = [:path, :file, :tempfile, :stringio, :nil]
def get_input(input_type, file_name = 'fields.pdf')
case input_type
when :path
path_to_pdf(file_name)
when :hash
@tcocca
tcocca / delayed_job.monitrc
Created March 17, 2011 13:30
Monit script for multiple delayed_job workers
check process sequoia_dj2_delayed_job_0
with pidfile /home/deploy/rails/sequoia/shared/pids/delayed_job.0.pid
start program = "/home/deploy/rails/sequoia/shared/delayed_job_runner.sh start production 0"
as uid deploy and gid deploy
stop program = "/home/deploy/rails/sequoia/shared/delayed_job_runner.sh stop production 0"
as uid deploy and gid deploy
check process sequoia_dj2_delayed_job_1
with pidfile /home/deploy/rails/sequoia/shared/pids/delayed_job.1.pid
start program = "/home/deploy/rails/sequoia/shared/delayed_job_runner.sh start production 1"
class FollowsController < ApplicationController
def create
@followable = find_followable
@follower = find_follower
@follower.follow(@followable)
redirect_to (@followable)
end
def destroy