Skip to content

Instantly share code, notes, and snippets.

View mikecarroll's full-sized avatar

Michael Carroll mikecarroll

View GitHub Profile
@mikecarroll
mikecarroll / CamanImageEditor
Last active December 15, 2015 05:59
Coffeescript code that allows user to choose an Caman image filter from a dropdown list (using select2), creates a slider with the appropriate values for that filter, and then saves the final set of adjustments as a hash that can be sent back to the server and stored for later reference.
camanCache = {}
imageValues = {}
$('.blimage, .largedisplay').each (->
imgName = $(@).attr('id')
loc = $(@).html()
camanCache[imgName] = Caman(loc, "##{imgName}")
$(@).css('height', '')
imageValues[imgName] = {}
)
@mikecarroll
mikecarroll / sitemap_generator.rake
Last active December 25, 2015 14:07 — forked from rorra/sitemap_generator.rb
Some changes made to make this work with the most recent version of sitemap_generator. Also, changed from using an s3.yml file to just using the Heroku S3 config variables directly.
require 'aws'
class Rake::Task
def replace &block
@actions.clear
prerequisites.clear
enhance &block
end
end
desc "Normalize Uzbek file."
task :uzbek => :environment do
require 'csv'
counter = 0
entry_counter = 0
previous = nil
desc_array = []
new_file = File.open("/Users/woodchip/fixed_UE.txt", 'w')
@mikecarroll
mikecarroll / fastforward_health_raffle.rb
Last active December 25, 2015 17:59
Win a free ticket to the FastForward Health movie night, courtesy of Health Devs (http://www.meetup.com/HealthDevsNYC/)!
tickets = {83=>"@_mcarroll_"}
winner = nil
nojoys = []
while winner.nil? do
number = rand(1..1000)
tickets.include?(number) ? winner = tickets[number] : nojoys << number
end
p nojoys
puts "After #{nojoys.count} draws, the winner is: #{winner}!"
@mikecarroll
mikecarroll / nyec_digital_health_conference_raffle.rb
Last active December 25, 2015 17:59
Win a free ticket to the NYeC Digital Health Conference (http://digitalhealthconference.com/), courtesy of Health Devs (http://www.meetup.com/HealthDevsNYC/)!
tickets = {83=>"@_mcarroll_", 9=>"@nygeog", 750=>"@binbrain", 267=>"@sanjivslall", 899=>"@kendeveloper", 99=>"@SkiNatasha", 396=>"@ElFuturero", 600=>"@shahakash", 526=>"@sarahjukes", 512=>"@chasballew", 626=>"@fancyremarker", 4=>"@johnpaulett", 131=>"@shawn_oakley", 19=>"@mackenco", 482=>"@_clapaz"}
winner = nil
nojoys = []
while winner.nil? do
number = rand(1..1000)
tickets.include?(number) ? winner = tickets[number] : nojoys << number
end
p nojoys
puts "After #{nojoys.count} draws, the winner is: #{winner}!"
@mikecarroll
mikecarroll / nutritionix.rb
Created March 22, 2014 16:42
Nutritionix Ruby API library
require 'net/http'
class Nutritionix
def initialize(app, key)
@app = app
@key = key
@url = URI.parse('https://api.nutritionix.com/v1_1/search')
end
#!/usr/bin/env ruby
##########################################
#
# This script is to help you get around the dreaded 'Resource Has A Dependent Object'
# when deleting something in AWS. It will search a handful of places for that sg ID
# and let you know if it finds anything. Its a pretty quick n dirty script.
#
# If I missed any areas it should search, please let me know or better yet, make a pull request!
#
# You'll need to install the aws-sdk ruby gem: sudo gem install aws-sdk