Skip to content

Instantly share code, notes, and snippets.

View juanger's full-sized avatar

Juan Germán Castañeda Echevarría juanger

View GitHub Profile
@juanger
juanger / resque_clean.rb
Created September 19, 2013 00:52
Clean Resque failed jobs without loading all of them into memory.
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)
@juanger
juanger / csv_splitter.rb
Created September 18, 2013 19:00
CSV Splitter
# 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
@juanger
juanger / failures_formatter.rb
Last active May 27, 2020 17:17 — forked from dblock/failures_formatter.rb
Rerun rspec failed tests and merge junit reports for jenkins.
# 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?
@juanger
juanger / button.scss
Last active December 11, 2015 09:48
Compass mixin for styling buttons
@mixin button($bg-image,
$color,
$border-color,
$bg-hover: linear-gradient(#e8e8e8, #d1cfcf),
$color-hover: #555454,
$border-color-hover: #bebdbd,
$bg-disabled: linear-gradient(#CACACA, #ABABAB),
$color-disabled: #EEE,
$border-color-disabled: #bebdbd,
$border-radius: 5px) {
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
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
$ hdiutil create -size 100m -fs UFS -volname UFS UFS.dmg
$ echo Pétalo | xxd
0000000: 5065 cc81 7461 6c6f 0a Pe..talo.
$ echo Pétalo | xxd
0000000: 50c3 a974 616c 6f0a P..talo.
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
$ 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