Skip to content

Instantly share code, notes, and snippets.

Luca Spiller lucaspiller

View GitHub Profile
@lucaspiller
lucaspiller / gist:8952830
Created Feb 12, 2014
Ruby 1.8.6 crashes parsing YAML
View gist:8952830
$ 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 Feb 26, 2014
Octopress, export all posts as RSS
View rss.xml
---
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
wysihtml5: Tidy HTML pasted from Word
View gist:c544024738bca2be598f
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");
View honeypot.c
/*
* 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 Aug 29, 2015
HMRC Residency Check
View dates.rb
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
ActiveJob + Cucumber
View active_job.rb
# features/support/active_job.rb
# Specify the inline adapter so jobs run straight away
Rails.application.config.active_job.queue_adapter = :inline
View gist:177135
puts "Hello World!"
View gist:360176
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 Apr 29, 2010
Play Spec - Making your specs fun!
We couldn’t find that file to show.
@lucaspiller
lucaspiller / tag_fixer.rb
Created Oct 24, 2010
Set ID3 tags from filename
View tag_fixer.rb
require 'rubygems'
require 'id3lib'
file=ARGV.join
filename=File.basename(file, '.mp3')
parts = filename.split('-')
artist = parts[1].strip
title = parts[2].strip
You can’t perform that action at this time.