Skip to content

Instantly share code, notes, and snippets.

@harry-wood
harry-wood / fluxbb-bbcode.txt
Created Nov 7, 2022
BBCode syntax examples
View fluxbb-bbcode.txt
[h]Fluxbb bbcode tests[/h]
[h]Text[/h]
[b]Bold text[/b]
[u]Underlined text[/u]
[i]Italic text[/i]
@harry-wood
harry-wood / installing libxml on mac for ruby.md
Last active Sep 28, 2022
Installing libxml on mac for ruby.md
View installing libxml on mac for ruby.md

Installing/debugging libxml on mac for ruby/rails

Install xcode command line tools (or check if they're already installed)

xcode-select --install

Do we have libxml installed already?

xsltproc --version
View Wordpress template for CSV export
<?php /*template name: Export*/
if ( !is_user_logged_in() ) {
auth_redirect();
}
$admin_user = current_user_can('manage_options');
if (!$admin_user) die("ACCESS DENIED");
if (isset($_GET['export'])) {
$table_head = array('column1', 'column2', 'column3');
View linear-time-calculator.html
<html>
<head>
<title>Linear time calculator</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
background: WHITE;
font-family: Verdana, Helvetica, Arial, sans-serif;
}
View london-wards.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View actionmailer-test.rb
class TestMailer < ActionMailer::Base
default from: "test@gmail.com"
def test_mail
mail(
to: "Harry Wood <test@gmail.com>",
subject: "Testing mail sending",
from: "test@gmail.com",
content_type: "text/html",
) do |format|
@harry-wood
harry-wood / inone.rb
Created Sep 13, 2018
Spit out any lines which are in the first file and not in the second
View inone.rb
#!/usr/local/bin/ruby -w
# Assuming the two files are sorted, this will walk through them in parallel comparing
# and spitting out any lines which are in the first one and not in the second.
# its equivalend to the unix command: diff A.txt B.txt|grep '^<'|awk '{print $2}'
fa = File.open(ARGV[0])
fb = File.open(ARGV[1])
linea = nil
lineb = nil
@harry-wood
harry-wood / holidays.rb
Created Dec 5, 2017
That thing when you write a ruby script to calculate holiday days :-)
View holidays.rb
require 'date'
DAY_NAMES = %w[Sun Mon Tue Wed Thu Fri Sat].freeze
BANK_HOLIDAYS = [
Date.new(2017, 1, 2),
Date.new(2017, 4, 14),
Date.new(2017, 4, 17),
Date.new(2017, 5, 1),
Date.new(2017, 5, 29),
@harry-wood
harry-wood / random_kml.rb
Created Oct 16, 2017
Little ruby script to generate a test KML file, with 40 random markers
View random_kml.rb
puts '<?xml version="1.0" encoding="UTF-8"?>'
puts '<kml xmlns="http://www.opengis.net/kml/2.2">'
puts '<Document>'
puts " <name>Lots of placemarks #{random_str}</name>"
puts ' <description>A test KML file with lots of placemarks</description>'
(0..40).each do
puts '<Placemark>'
puts " <name>placemark name #{random_str}</name>"
puts " <description>#{random_str}#{random_str}#{random_str}</description>"
@harry-wood
harry-wood / Vagrantfile for jekyll
Last active Jan 3, 2017
Vagrantfile for jekyll (ruby2 rbenv bundle-installed project)
View Vagrantfile for jekyll
Vagrant::Config.run do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.forward_port 4000, 4000
$script = <<-SCRIPT
set -o verbose
set -e
whoami