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
@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 / 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 = [
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
class FollowsController < ApplicationController
def create
@followable = find_followable
@follower = find_follower
@follower.follow(@followable)
redirect_to (@followable)
end
def destroy
@tcocca
tcocca / yo.rb
Created September 25, 2010 18:11 — forked from dpickett/yo.rb
def following_by_type(followable_type, options={})
follows = followable_type.constantize.
includes(:followings).
where(
"follows.follower_id = ? AND follows.follower_type = ? AND follows.followable_type = ? AND blocked = ?",
self.id, parent_class_name(self), followable_type, false
)
if options.has_key?(:limit)
return follows.limit(options[:limit])
end
Factory.define :application do |factory|
factory.attachment(:sample, "public/samples/sample.doc", "application/msword")
end