Skip to content

Instantly share code, notes, and snippets.

View kimadactyl's full-sized avatar

Dr Kim Foale kimadactyl

View GitHub Profile
@kimadactyl
kimadactyl / blogspot-to-hugo-converter.rb
Last active December 17, 2021 21:24
Migrate Blogspot to Hugo page bundles
# To grab site, do something like:
# wget --mirror --convert-links --adjust-extension --page-requisites --span-hosts --domains 1.bp.blogspot.com,2.bp.blogspot.com,3.bp.blogspot.com,4.bp.blogspot.com,myblog.blogspot.com, http://myblog.blogspot.com/ -P pass_01
require 'date'
require 'fileutils'
require 'kramdown'
require 'logger'
require 'nokogiri'
require 'rake'
require 'sanitize'
@kimadactyl
kimadactyl / 1-trim-lines.rb
Last active August 10, 2021 17:09
Scripts to migrate an existing HTML site to Jekyll when you can't access the source
# First grab the remote site
# wget --mirror --convert-links --adjust-extension --page-requisites --no-parent http://yourdomain.co.uk
# If you have images hosted on another site then do
# wget --mirror --convert-links --adjust-extension --page-requisites --span-hosts --domains mydomain.com,imagehostingcdn.com https://mydomain.com
# Then have a look how many lines to trim from beginning and end
htmls = Dir.glob('/**/*.html')
htmls.each do |file|
# Change numbers to how many lines you want to trim
@kimadactyl
kimadactyl / Dockerfile
Last active August 17, 2017 18:44
Troubleshooting
FROM ruby:2.4.0
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs
RUN mkdir /gofg-db
WORKDIR /gofg-db
ADD Gemfile /gofg-db/Gemfile
ADD Gemfile.lock /gofg-db/Gemfile.lock
RUN bundle install
ADD . /gofg-db
ENTRYPOINT ["/gofg-db/docker-entry.sh"]
@kimadactyl
kimadactyl / README.sh
Last active May 10, 2024 14:23
Dokku / Digital Ocean / Rails / Postgres / Let's Encrypt / persistent storage
# Creating a Digital Ocean droplet running Rails + Postgres with persistant storage and https
#--------------------------------------------------------------------------------------------
# For your ctrl-D pleasure...
# SERVER_IP
# APP_NAME
# RAILS_SECRET (generate with `rails secret`)
# ADMIN_EMAIL
@kimadactyl
kimadactyl / royalmail_seeds.rb
Created October 26, 2016 15:24
Create Royal Mail postal regions for Spree
# A couple of helper functions
# This one converts country strings to Spree::Country objects.
def convert_countries(countries)
log = ""
output = []
countries.each do |country|
spree_country = Spree::Country.find_by(name: country)
if spree_country.nil?
spree_country = Spree::Country.find_by("name like ?", "%#{country}%")
@kimadactyl
kimadactyl / Error log
Created October 19, 2016 10:06
Spree error when progressing to payment
Started PATCH "/shop/checkout/update/address" for 127.0.0.1 at 2016-10-19 11:02:58 +0100
Processing by Spree::CheckoutController#update as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"Wr4CSN3bs2Ft8GeveWat+eKqjkcjR7pOsDZKYtJWncHShITVJjHV+gWaE3pNGzz94nceB/sX0B45MNKcrUvQ7g==", "order"=>{"email"=>"kim@testtest.com", "state_lock_version"=>"2", "bill_address_attributes"=>{"firstname"=>"Kim", "lastname"=>"Foale", "address1"=>"5 Ribston St", "address2"=>"", "city"=>"Manchester", "country_id"=>"77", "zipcode"=>"M15 5RH", "phone"=>"3423423423432", "id"=>"44"}, "use_billing"=>"1", "ship_address_attributes"=>{"id"=>"45"}}, "commit"=>"Save and Continue", "save_user_address"=>"1", "state"=>"address"}
User Load (0.3ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT 1 [["id", 136]]
Spree::Store Load (0.3ms) SELECT "spree_stores".* FROM "spree_stores" ORDER BY "spree_stores"."id" ASC LIMIT 1
Spree::Order Load (0.2ms) SELECT "spree_orders".* FROM "spree_orders" WHERE "spree_orders"."comple

Commands

  • azk deploy ssh -- remote shell
  • azk deploy full -- restart after updating environment variables

Nameserver problems

DNS not resolving

Check /etc/resolver/dev.azk.io equals ip address for docker0

@kimadactyl
kimadactyl / Azkfile.js
Last active February 8, 2018 22:59
Adventures in azk
/**
* Documentation: http://docs.azk.io/Azkfile.js
*/
// Adds the systems that shape your system
systems({
'taichi-school': {
// Dependent systems
depends: ["postgres"],
// More images: http://images.azk.io
image: {"docker": "azukiapp/ruby:2.3.0"},
@kimadactyl
kimadactyl / install.md
Last active January 11, 2018 12:30
Ubuntu new installation checklist
@kimadactyl
kimadactyl / preview.rb
Created February 18, 2016 19:22
Video previewer. Outputs 10 evenly spaced frames for a directory of videos.
Dir.glob('/YOUR_VIDEOS/*.mp4') do |f|
name = File.basename(f, ".*")
len = `ffprobe #{f} -show_entries format=duration -v quiet -of csv="p=0"`
for n in (1..10)
l = len.to_f / 10 * n
`ffmpeg -i #{f} -ss #{l} -v quiet -vframes 1 './preview/#{name}_#{n}.png'`
end
end