Skip to content

Instantly share code, notes, and snippets.

View danielpuglisi's full-sized avatar
💭
🤘

Daniel Puglisi danielpuglisi

💭
🤘
View GitHub Profile
@danielpuglisi
danielpuglisi / migrate_from_jekyll_to_rails.rb
Last active April 29, 2016 17:51
A Rake Task which I wrote to migrate my Jekyll posts and categories to a custom Rails application I've built.
# A Ruby script to migrate Jekyll Posts to a custom Database
DIRECTORIES = ["tmp/blog/articles/_posts/*", "tmp/blog/startup/_posts/*",
"tmp/blog/productivity/_posts/*", "tmp/blog/music/_posts/*",
"tmp/blog/programming/_posts/*"]
def export(content, key)
match = content.match( /^---.*\n#{key}: ([^\n]*).*---$/m )
if match
match[1].gsub("\"", "")
# Hook to save the html page of every failed features into the temp
# # file directory taht it can be checked after cucumber has finished running.
require 'fileutils'
FAILED_FEATURES_PAGES_PATH = File.join Rails.root, 'tmp', 'failed_features'
FAILED_FEATURES_IMAGES_PATH = File.join Rails.root, 'tmp', 'failed_features_images'
FileUtils.rm_rf FAILED_FEATURES_PAGES_PATH
FileUtils.rm_rf FAILED_FEATURES_IMAGES_PATH
# Convert a locations response to an Array of Location Objects
#
# response - The Hash object from an API response
#
# Returns an array of Location objects, returns nil if the Hash is empty
def self.objectify(response)
response.empty? ? nil : response.map {|station| Rtransport::Location.new(station)}
end
@danielpuglisi
danielpuglisi / keep-alive.sh
Created August 27, 2012 17:52
Heroku keep alive
#!/bin/bash
apps=( app1-demo app1-staging app2-draft )
for app in ${apps[@]}; do
host="http://$app.herokuapp.com"
curl --silent --output /var/log/keep-alive.txt -L $host
done
@danielpuglisi
danielpuglisi / crontab
Last active October 9, 2015 10:38
Heroku keep alive
*/5 * * * * root /etc/cron.custom/keep-alive.sh