This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# USAGE: Hash.from_libxml(YOUR_XML_STRING) | |
require 'xml/libxml' | |
# adapted from | |
# http://movesonrails.com/articles/2008/02/25/libxml-for-active-resource-2-0 | |
class Hash | |
class << self | |
def from_libxml(xml, strict=true) | |
begin | |
XML.default_load_external_dtd = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coderwall.coffee | |
# Display coderwall.com badges | |
username = "hermanjunge" | |
el = $(".coderwall") | |
$.getJSON "http://www.coderwall.com/#{username}.json?callback=?", (data) -> | |
el.empty() | |
for item in data.data.badges | |
$("<img>") | |
.attr( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a=b=c=(1..100).each do |num| | |
print num, ?\r, | |
("Fizz" unless (a = !a) .. (a = !a)), | |
("Buzz" unless (b = !b) ... !((c = !c) .. (c = !c))), | |
?\n | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="disqus_thread"></div> | |
<script type="text/javascript"> | |
var disqus_shortname = 'example'; // required: replace example with your forum shortname | |
var disqus_identifier = '{{post.id}}'; // make sure to use the post.id as an identifier, otherwise disqus will use the pages url per default, which might be problematic... | |
/* * * DON'T EDIT BELOW THIS LINE * * */ | |
(function() { | |
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true; | |
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js'; | |
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This script is to work round the problem of broken RubyMine dependencies for bundle files. | |
# It uses an undocumented feature for RubyMine (but available in Intellij Idea) to create a | |
# gems library xml file and update the iml file. | |
# | |
# See Rubymine issues: | |
# https://youtrack.jetbrains.com/issue/RUBY-16428 | |
# https://youtrack.jetbrains.com/issue/RUBY-15026 | |
# https://youtrack.jetbrains.com/issue/RUBY-14542 | |
# | |
# Usage: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'fileutils' | |
# SETUP | |
# Details about the local transmission service | |
transmission_remote_location = "/usr/sbin/transmission-remote" | |
transmission_server_port = "mini.local:9091" | |
# The place where downloaded but unsorted tv show torrents land | |
downloads_television_directory = "/Volumes/Drobo/Downloads/Television/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# These are my notes from the PragProg book on CoffeeScript of things that either | |
# aren't in the main CS language reference or I didn't pick them up there. I wrote | |
# them down before I forgot, and put it here for others but mainly as a reference for | |
# myself. | |
# assign arguments in constructor to properties of the same name: | |
class Thingie | |
constructor: (@name, @url) -> | |
# is the same as: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example with basic types | |
--- | |
hash: | |
string: some text | |
number: 12345 | |
array_of_bool: [on, off, true, false, yes, no] | |
ruby symbol: :symbol | |
array: | |
- item one | |
- item two |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
# | |
## Stupid small pure Ruby JSON parser & generator. | |
# | |
# Copyright © 2013 Mislav Marohnić | |
# | |
# Permission is hereby granted, free of charge, to any person obtaining a copy of this | |
# software and associated documentation files (the “Software”), to deal in the Software | |
# without restriction, including without limitation the rights to use, copy, modify, | |
# merge, publish, distribute, sublicense, and/or sell copies of the Software, and to |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# In my tag-filing system where top-level "context" folders are tagged with | |
# "=Context" tags and subfolders are tagged with "@project" tags, this function | |
# lets me quickly cd to any tagged folder in my filing system. The first | |
# argument is a context folder, the rest are a chain of subfolders. The | |
# subfolders don't need to be contiguous, and the matching is fuzzy. | |
cdt() { | |
local fuzzy | |
local root | |
local sub | |
local list |
OlderNewer