Skip to content

Instantly share code, notes, and snippets.

Avatar

Tom Cocca tcocca

  • Boston Logic Technology Partners, Inc.
  • Boston, MA
View GitHub Profile
View authentication_response.json
{
"access": {
"token": {
"id": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx",
"expires": "2014-11-24T22:05:39.115Z",
"tenant": {
"id": "110011",
"name": "110011"
},
"RAX-AUTH:authenticatedBy": [
View 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
View query.json
{
"query": {
"filtered": {
"query": {
"match_all": {}
},
"filter": {
"bool": {
"must_not": [
{"term": {"topic_ids": "NTfaluJAzhU6ajVN"}},
@tcocca
tcocca / stylesheet_check.rb
Created Dec 18, 2012
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
View stylesheet_check.rb
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 Jan 5, 2012 — forked from DemitryT/walkscore.rb
walkscore.rb
View 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
View gist:1355390
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 = [
View namespaced_session_proxy.rb
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
View wrapper_spec.rb
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 Mar 17, 2011
Monit script for multiple delayed_job workers
View delayed_job.monitrc
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"
View FollowsController.rb
class FollowsController < ApplicationController
def create
@followable = find_followable
@follower = find_follower
@follower.follow(@followable)
redirect_to (@followable)
end
def destroy
You can’t perform that action at this time.