Skip to content

Instantly share code, notes, and snippets.

@jonathanclarke
jonathanclarke / dedup.rb
Created June 19, 2021 12:13
Export files recusively to a common directory with a unique sha
# frozen_string_literal: true
# Export files recusively to a common directory with a unique sha
# Ignore duplicate files, skip directories
require 'pathname'
INPUT_DIR = '/home/jonathan/duplicate-input'
OUTPUT_DIR = '/home/jonathan/deduped-output'
@jonathanclarke
jonathanclarke / 0-readme.md
Created May 25, 2021 11:49 — forked from toolmantim/0-readme.md
Using rvm and node on Ubuntu with Buildkite Agent

Firstly, you'll need to install rvm as the buildkite-agent user:

sudo su buildkite-agent
curl -sSL https://get.rvm.io | bash -s stable
source /var/lib/buildkite-agent/.rvm/scripts/rvm
rvm install 2.4.0 && rvm use 2.4.0 && gem install bundler

Secondly, make rvm available to your build commands by adding the following pre-command Buildkite Agent hook:

require 'formula'
class Imagemagick < Formula
homepage 'https://legacy.imagemagick.org'
url 'https://ftp.osuosl.org/pub/blfs/conglomeration/ImageMagick/ImageMagick-6.9.7-8.tar.xz'
head 'https://github.com/ImageMagick/ImageMagick/tree/ImageMagick-6',
:using => UnsafeSubversionDownloadStrategy
@jonathanclarke
jonathanclarke / gist:3197355
Created July 29, 2012 10:27 — forked from danparsons/gist:3195652
How to stream the London 2012 Olympics

How to stream the London 2012 Olympics

There have been several HOWTOs posted regarding streaming the 2012 Olympics using HTTP / SOCKS proxies via SSH and other similar methods. None of these actually work using the latest Flash on Mountain Lion (with Firefox, Chrome or Safari). Additionally, the third-party streaming sites don't provide BBC's amazing interface, which lets you quickly skip to individual competitors and events. However, setting up an OpenVPN server does work, with some tweaks. You'll get the exact same UX that people in England receive.

@jonathanclarke
jonathanclarke / Avoiding precompile if no assets change when synching to S3
Created February 13, 2012 03:13
Avoiding precompile if no assets change when synching to S3
namespace :assets do
task :precompile, :roles => :web, :except => { :no_release => true } do
from = source.next_revision(current_revision)
if capture("cd #{latest_release} && #{source.local.log(from)} vendor/assets/ app/assets/ | wc -l").to_i > 0
run %Q{cd #{latest_release} && #{rake} RAILS_ENV=#{rails_env} #{asset_env} assets:precompile}
else
logger.info "Skipping asset pre-compilation because there were no asset changes"
end
end
end
{ "account" => {
"categories" => {
"18" => 1,
"19" => 1,
"20" => 1,
"21" => 1,
"22" => 1,
"23" => 1,
"24" => 1,
"25" => 1,
@jonathanclarke
jonathanclarke / daily_deal_rss_feed
Created August 8, 2011 09:20 — forked from davemorro/daily_deal_rss_feed
Recommended Daily Deal RSS Feed
<?xml version="1.0" encoding="UTF-8" ?>
<deals>
<deal>
<title>A perfect daily deal feed for just $17.50</title>
<link>http://www.dailydealsite/deals/1</link>
<guid>http://www.dailydealsite/deals/1</guid>
<description><![CDATA[Set your daily deal site up for maximum distribution effectiveness. Many deal sites include HTML within the description however, we recommend you remove all formatting, enabling the aggregator to more easily integrate your information. If you do include HTML, be sure wrap the description in CDATA sequences.]]></description>
<highlights><![CDATA[Usually a list of the deal highlights. Like the description, you should wrap the highlights in CDATA sequences.]]></highlights>
<image>http://www.dailydealsite.com/images/image.jpg</image>
<price>17.50</price>
@jonathanclarke
jonathanclarke / gist:848224
Created February 28, 2011 22:59
Regenerate thumbnails for has_many paperclip
has_attached_file :file,
:styles => { :thumb => "139x107#", :thumb_ems => "64x64#", :thumb_aar => "100x100#", :thumb_newsletter => "80x60#", :thumb_newsletter_product => "110x85#", :web_image => "145x>" },
:storage => :s3,
:bucket => "domain.com_#{RAILS_ENV}",
:s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
:path => ":class/:id/:style/:filename"
RAILS_ENV=staging rake paperclip:refresh:thumbnails CLASS=Asset
#Remove existing node.js
cd ~/node-previously-installed
./configure
make uninstall
#Installation without using sudo
#IIRC, this only works for shell windows opened
echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc
. ~/.bashrc
before_create :my_cool_thing
def my_cool_thing
p Time.now
end