Skip to content

Instantly share code, notes, and snippets.

@til
til / self_returning.rb
Created February 24, 2014 12:44
Ruby server script that returns itself, with comment function
#!/usr/bin/env ruby
#
# Leave a comment if you can ...
%w[ rubygems socket syntax/convertors/html ].each { |lib| require lib }
def header(*args)
args.join("\r\n") + "\r\n" + "\r\n"
end
@til
til / projects.org
Created March 23, 2014 15:44
notmuch for emacs-berlin

notmuch

notmuch is a search engine and emacs frontend for locally stored email. The name implies that it is efficient:

“You have 200k emails? That’s not much!”

Features

Fast local search

(defun downcase-word-with-camelcase ()
"This works similar to downcase-word, but additionally inserts
an underscore before upper case chars within camel cased words, so that:
FooBar => foo_bar"
(interactive)
(progn
(if (looking-at-p "\\>") (search-forward-regexp "\\<"))
(let ((start (point)))
(search-forward-regexp "\\>")
(let ((end (point)))
require 'rspec'
require 'set'
class Traverser
attr_reader :elements, :satisfied
def initialize(elements, satisfied:)
@elements = elements
@satisfied = satisfied
end
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@til
til / init.el
Created October 29, 2014 21:10
(defun grep-project (q)
"Search using git grep"
(interactive (list
(read-from-minibuffer "git grep: "
(if (region-active-p)
(buffer-substring-no-properties (region-beginning) (region-end))
(current-word))
nil nil 'grep-project)))
(let ((command
(concat
module SpecPageRefresh
class SpecPageRefreshMatcher
include Merb::Test::ViewHelper
def matches?(response)
response.should have_selector('form.hidden_refresh')
rescue Spec::Expectations::ExpectationNotMetError
false
end
diff --git a/lib/integrity/builder.rb b/lib/integrity/builder.rb
index 4b6ffa3..af90c8a 100644
--- a/lib/integrity/builder.rb
+++ b/lib/integrity/builder.rb
@@ -37,6 +37,9 @@ module Integrity
def complete
Integrity.log "Build #{commit} exited with #{@status} got:\n #{@output}"
+ # Remove invalid UTF8, see http://po-ru.com/diary/fixing-invalid-utf-8-in-ruby-revisited/
+ @output = (Iconv.iconv('UTF-8//IGNORE', 'UTF-8', @output).first + ' ')[0..-2]
Debugger entered--Lisp error: (file-error "Cannot open load file" "gist")
require(gist)
eval((require (quote gist)))
eval-last-sexp-1(nil)
eval-last-sexp(nil)
call-interactively(eval-last-sexp nil nil)
~/ptwitter/my2cents/trunk $ ant debug
Buildfile: build.xml does not exist!
Build failed