Skip to content

Instantly share code, notes, and snippets.

@lucaspiller
lucaspiller / gist:8952830
Created February 12, 2014 10:08
Ruby 1.8.6 crashes parsing YAML
$ ruby -v 1 ↵
ruby 1.8.6 (2009-08-04 patchlevel 383) [i686-darwin13.0.0]
$ irb -v
irb 0.9.5(05/04/13)
$ irb 134 ↵
irb(main):001:0> require 'yaml'
=> true
irb(main):002:0> YAML::load("--- !ruby/object:Gem::Specification\nname: multi_xml\nversion: !ruby/object:Gem::Version\n version: 0.5.1\n prerelease: \nplatform: ruby\nauthors:\n- Erik Michaels-Ober\nautorequire: \nbindir: bin\ncert_chain: []\ndate: 2012-05-10 00:00:00.000000000 Z\ndependencies:\n- !ruby/object:Gem::Dependency\n name: maruku\n requirement: !ruby/object:Gem::Requirement\n none: false\n requirements:\n - - ! '>='\n - !ruby/object:Gem::Version\n version: '0'\n type: :development\n prerelease: false\n version_requirements: !ruby/object:Gem:
@lucaspiller
lucaspiller / rss.xml
Created February 26, 2014 13:56
Octopress, export all posts as RSS
---
layout: nil
---
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
<channel>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com" xmlns:atom="http://www.w3.org/2005/Atom"/>
<title>{{ site.title | xml_escape }}</title>
<generator>Octopress</generator>
<link>{{ site.url }}</link>
@lucaspiller
lucaspiller / gist:c544024738bca2be598f
Created May 20, 2014 14:11
wysihtml5: Tidy HTML pasted from Word
var tidyHtml = function() {
var html = this.getValue();
// remove empty paragraphs
html = html.replace(/<p>(&nbsp;|\s+)?<\/p>/g, "");
html = html.replace(/<p><b>(&nbsp;|\s+)?<\/b><\/p>/g, "");
// remove newlines between words
html = html.replace(/([^>])\n([^<])/g, "$1 $2");
@lucaspiller
lucaspiller / honeypot.c
Created July 3, 2014 17:23
DMCA Honeypot
/*
* This file is not Copyright (C) QUALCOMM Austria Research Center GmbH.
* It is not Copyright (C) Sony Computer Entertainment America LLC ("SCEA").
* It is also not Copyright (C) of Apple Inc. (“Apple”).
* Lastly it is not Copyright (C) Epic Games, Inc.
*/
#include <stdio.h>
int main() {
@lucaspiller
lucaspiller / dates.rb
Last active August 29, 2015 14:04
HMRC Residency Check
require 'active_support/core_ext'
in_out = :out
out_days = 0
in_days = 0
transit_days = 0
last = "2013-05-06".to_date
@lucaspiller
lucaspiller / active_job.rb
Created May 11, 2015 12:41
ActiveJob + Cucumber
# features/support/active_job.rb
# Specify the inline adapter so jobs run straight away
Rails.application.config.active_job.queue_adapter = :inline
@lucaspiller
lucaspiller / gist:177135
Created August 28, 2009 18:23
My first gist!
puts "Hello World!"
@lucaspiller
lucaspiller / gist:360176
Created April 8, 2010 15:19
Patron benchmark
require 'rubygems'
require 'patron'
50.times do
Thread.new do
print "+ Start\n"
session = Patron::Session.new
session.timeout = 30000
session.connect_timeout = 30000
@lucaspiller
lucaspiller / play_spec.rb
Created April 29, 2010 15:49
Play Spec - Making your specs fun!
We couldn’t find that file to show.
@lucaspiller
lucaspiller / tag_fixer.rb
Created October 24, 2010 08:53
Set ID3 tags from filename
require 'rubygems'
require 'id3lib'
file=ARGV.join
filename=File.basename(file, '.mp3')
parts = filename.split('-')
artist = parts[1].strip
title = parts[2].strip