Skip to content

Instantly share code, notes, and snippets.

View danivovich's full-sized avatar

Dan Ivovich danivovich

View GitHub Profile
@danivovich
danivovich / migrate_ghost_to_jekyll.rb
Created October 27, 2017 12:05
Migrate from Ghost JSON into Jekyll Markdown Files
#!/usr/bin/env ruby
require 'fileutils'
require 'json'
require 'date'
require 'yaml'
FileUtils.mkdir_p("_posts")
FileUtils.mkdir_p("_drafts")
FileUtils.mkdir_p("_data")
@danivovich
danivovich / zube_to_csv.rb
Last active August 11, 2021 16:51
Zube JSON to CSV
require 'json'
require 'csv'
data = JSON.parse(File.read("data.json"))
out = CSV.open("data.csv", "wb")
out << ["Number", "State", "Status", "Column", "Epic", "Labels", "Title", "Body"]
row = []

Updating timex_ecto and ecto on a project created a situation where we can no longer run migrations when deployed via distillery.

Running migrations on Heroku and locally when exected as a mix task continue to work. This specific lock diff causes the migration command to fail as shown in the output. Nothing about the database or its connection string changes between deploys with and without this diff applied.

Since we cannot update just timex_ecto or just ecto, I'm unclear as to which the issue is with, and since neither breaks a non-distillery release migration (mix ecto.migrate mechanism) it could be something specific about how distillery interacts with these two updates.

@danivovich
danivovich / nginx-ghost.conf
Created June 24, 2016 13:18
Basic nginx configuration for a caching proxy for ghost blogging, designed for use in Docker
server {
listen 80 default_server;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
location ~* \.(jpg|jpeg|svg|png|gif|ico|css|js|eot|woff)$ {
proxy_cache GHOST;
@danivovich
danivovich / ladders.go
Created September 10, 2013 20:43
Chutes and Ladders in Go
package main
import (
"fmt"
"math/rand"
"os"
"text/tabwriter"
"time"
)
@danivovich
danivovich / gunicorn.conf.py
Created March 12, 2013 00:23
Graceful restarts with code reloading on Capistrano style deployed Python applications
import os
import signal
bind = "127.0.0.1:8888"
errorlog = "%s/log/gunicorn.log" % (os.getcwd())
workers = 4
keepalive = 5
preload_app = True
def on_starting(server):

Keybase proof

I hereby claim:

  • I am danivovich on github.
  • I am danivovich (https://keybase.io/danivovich) on keybase.
  • I have a public key ASCxJr_4CBEf8zxo6eyWMYfW24NpG3zQlwRI6-0Jkj6Vowo

To claim this, I am signing this object:

@danivovich
danivovich / static_assets.rake
Last active December 11, 2015 17:49
replace links to assets in static error pages with links to hashed asset pipeline assets
namespace :assets do
desc 'Update the URIs for assets used in the static pages (e.g. 500.html)'
task :update_static_pages => :environment do
manifest_path = Rails.root.join('public', 'assets', 'manifest.yml')
unless File.exists?(manifest_path.to_s)
raise "Must run assets:precompile first"
end
manifest = YAML.load(manifest_path.read)
%w[404 422 500 504 browser].each do |static_page|
path = Rails.root.join('public', "#{static_page}.html")
@danivovich
danivovich / render_the_page_steps.rb
Created June 14, 2012 17:51
Capybara Webkit save and open page but with render
Then /^render the page$/ do
if Capybara.current_driver == Capybara.javascript_driver
file_name = "capybara-webkit-#{Time.new.strftime("%Y%m%d%H%M%S")}#{rand(10**10)}.png"
name = File.join(*[Capybara.save_and_open_page_path, file_name].compact)
page.driver.render name
begin
require "launchy" # could raise LoadError
raise LoadError unless Launchy::Version::MAJOR >= 2
Launchy.open(name)
rescue LoadError
@danivovich
danivovich / factory_girl_step_helpers.rb
Created March 22, 2012 01:39
Factory Girl steps for Turnip
module FactoryGirlStepHelpers
def convert_human_hash_to_attribute_hash(human_hash, associations = [])
HumanHashToAttributeHash.new(human_hash, associations).attributes
end
class HumanHashToAttributeHash
attr_reader :associations
def initialize(human_hash, associations)
@human_hash = human_hash