Skip to content

Instantly share code, notes, and snippets.

@plexus
plexus / smt-plexus.zsh
Created June 13, 2012 10:41
My adaptation of the smt zsh theme included in oh-my-zsh
# -----------------------------------------------------------------------------
# FILE: smt-plexus.zsh-theme
# DESCRIPTION: oh-my-zsh theme file, based on smt by Stephen Tudor.
# AUTHOR: Stephen Tudor (stephen@tudorstudio.com) changes by Arne Brasseur
# VERSION: 0.1
# SCREENSHOT: coming soon
# -----------------------------------------------------------------------------
MODE_INDICATOR="%{$fg_bold[red]%}❮ %{$reset_color%}%{$fg[red]%}❮❮ %{$reset_color%}"
local return_status="%{$fg[red]%}%(?..⏎)%{$reset_color%} "
@plexus
plexus / proxy.rb
Created November 22, 2012 13:18
Minimal TCP/HTTP proxy. Useful for debugging web services.
#!/usr/bin/ruby
require 'socket'
require 'thread'
require 'optparse'
require 'tmpdir'
class ProxyServer
attr_reader :switches
attr_reader :listen_port, :remote_host, :remote_port
@plexus
plexus / spec_helper.rb
Created December 5, 2012 15:37 — forked from ryanb/spec_helper.rb
Use RSpec tags to add behavior around specs.
# Add this to your spec_helper.rb
RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.around(:each, :vcr) do |example|
name = example.metadata[:full_description].downcase.gsub(/\W+/, "_").split("_", 2).join("/")
begin
VCR.use_cassette(name, :record => :new_episodes) do
example.call
end
rescue Errno::ENAMETOOLONG
@plexus
plexus / eavesdrop.gemspec
Created December 11, 2012 11:38
Eavesdrop : Declaritively decouple your Ruby
Gem::Specification.new do |s|
s.name = 'eavesdrop'
s.version = '0.1.0'
s.platform = Gem::Platform::RUBY
s.author = 'Arne Brasseur'
s.email = 'arne.brasseur@gmail.com'
s.summary = 'Event listener DSL'
s.description = 'Decouple your code declaritively.'
s.files = ['eavesdrop.rb']
@plexus
plexus / wikitable.rb
Created December 29, 2012 14:32
Naive parsing/generating off Mediawiki tables. I use this for automating some Wikipedia edits.
# -*- coding: utf-8 -*-
class WikiTable
attr_accessor :rows, :attributes
class Row
attr_accessor :cells, :attributes
def initialize
@cells = []
end
def <<(c); cells << c ; end
// Revoke / delete all Facebook apps that have access to your account.
// 1. Log in to FB
// 2. go to https://www.facebook.com/settings?tab=applications
// 3. Open javascript console (in Chrome : Ctrl-Shift-J / ALT-⌘-J)
// 4. Paste this snippet
function deleteApps($$) {
$$('input[title="Remove"]')[0].click()
setTimeout( function() {

Shoes has amazing potential to make coding fun and easy to start with. Unfortunately the original C version proved to be unmaintainable. The project has chosen for a fresh start, creating a new, clean implementation in pure Ruby, which is to become the fourth major release of the toolkit.

This is important for the long term health of the project, and Shoes 4 features a pluggable backend architecture, so different low level windowing toolkits can be easily hooked up. This will ensure that Shoes is viable and can stay relevant in different contexts. The project's contributors are currently uniting forces and working hard to finish a reference implementation using SWT on the JVM.

Starting a rewrite has set us back in time though, and Shoes would really benefit from a little push to get us over the line. Students could help by focusing on individual subsystems, or by improving compatibility with the old implementation. We hope that with the help of GSoC, we will be able to release Shoes 4 sooner, so people can

require 'nokogiri'
require 'open-uri'
paragraphs = Nokogiri( open('http://en.wikipedia.org/wiki/Ruby_(programming_language)') )/'p'
# Print fromt the first paragraphs containing 'Google Tech Talk' to the first following paragraph containing 'mixins'
paragraphs.map(&:text).each do |p|
puts p if (p =~ /Google tech talk/i)..(p =~ /mixins/i)
end
require 'minitest/autorun'
# spec_helper.rb
require 'open3'
class Command
attr_reader :stdin, :stdout, :stderr, :thread
def initialize(cmd)
@stdin, @stdout, @stderr, @thread = Open3.popen3 cmd
# Quick rendition of Conway's game of life
class Grid
def initialize
@width = 100
@height = 30
generate_grid
end
def generate_grid
@grid = (0...@width).map do