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
def loop_failed(exception_or_class, from) | |
current_idx = from | |
current = Resque::Failure.all(current_idx) | |
while current | |
if current["exception"] == exception_or_class || current["payload"]["class"] == exception_or_class | |
yield(current_idx, current) | |
else | |
current_idx += 1 | |
end | |
current = Resque::Failure.all(current_idx) |
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 splits a csv file with header into multiple csv files | |
# Usage: ruby csv_splitter.rb FILENAME [NUM_CHUNKS=10] | |
# Example: ruby csv_splitter.rb wmeco_export.csv 20 | |
# Change this method to skip malformed lines | |
def malformed?(line) | |
false | |
## This could be: | |
# line.start_with?(',') | |
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
# inspired by https://github.com/rspec/rspec-core/pull/596 | |
require 'rspec/core/formatters/base_formatter' | |
module RSpec | |
module Core | |
module Formatters | |
class FailuresFormatter < BaseFormatter | |
def dump_failures | |
return if failed_examples.empty? |
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
if growlnotify -h &>/dev/null; then | |
preexec() { | |
zsh_growl_cmd=$1 | |
zsh_growl_time=`date +%s` | |
} | |
precmd() { | |
if (( $? == 0 )); then | |
zsh_growl_status=done | |
zsh_growl_priority=Normal |
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
require 'osx/cocoa' | |
include OSX | |
require_framework 'QTKit' | |
class Screen | |
def self.capture | |
screenshot = OSX::CGWindowListCreateImage(OSX::NSScreen.mainScreen.frame, OSX::KCGWindowListOptionOnScreenOnly, OSX::KCGNullWindowID, OSX::KCGWindowImageDefault) | |
screenshot.retain | |
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
$ hdiutil create -size 100m -fs UFS -volname UFS UFS.dmg |
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
$ echo Pétalo | xxd | |
0000000: 5065 cc81 7461 6c6f 0a Pe..talo. | |
$ echo Pétalo | xxd | |
0000000: 50c3 a974 616c 6f0a P..talo. |
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
javac -encoding UTF8 Pétalo.java | |
Pe?talo.java:1: class P?talo is public, should be declared in a file named P?talo.java | |
public class P?talo { | |
^ | |
1 error |
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
$ javac Pétalo.java | |
Pe?talo.java:1: illegal character: \8730 | |
public class Pétalo { | |
^ | |
Pe?talo.java:1: illegal character: \169 | |
public class Pétalo { | |
^ | |
2 errors |