Skip to content

Instantly share code, notes, and snippets.

View alvarogarcia7's full-sized avatar

Alvaro Garcia alvarogarcia7

View GitHub Profile
@alvarogarcia7
alvarogarcia7 / screenshot_after_failure.rb
Created September 27, 2017 09:50
Take a screenshot after a failure in Ruby, using Capybara
After do |scenario|
diff = (Time.new - time)
timings << { scenario: scenario.name, timing: diff }
if scenario.failed?
begin
Capybara.using_session(Capybara::Screenshot.final_session_name) do
filename_prefix = Capybara::Screenshot.filename_prefix_for(:cucumber, scenario)
saver = Capybara::Screenshot::Saver.new(Capybara, Capybara.page, true, filename_prefix)
@alvarogarcia7
alvarogarcia7 / repl_history.clj
Created August 3, 2017 22:44
Playing with group-by and destructuring
(def numbers [0 1 2 3 4 5 6 7 8 9])
=> #'es.joaquincaro.katas.Greeting/numbers
(filter odd? numbers)
=> (1 3 5 7 9)
(group-byodd? numbers)
CompilerException java.lang.RuntimeException: Unable to resolve symbol: group-byodd? in this context, compiling:(/private/var/folders/6p/p1cct37x19bgtnss368w24mm0000gn/T/form-init4565011324126899375.clj:1:1)
(group-by odd? numbers)
=> {false [0 2 4 6 8], true [1 3 5 7 9]}
(let [[pares even? impares odd?]] (group-by odd? numbers))
IllegalArgumentException let requires an even number of forms in binding vector in es.joaquincaro.katas.Greeting:1 clojure.core/let (core.clj:4333)

Keybase proof

I hereby claim:

  • I am alvarogarcia7 on github.
  • I am alvarogarcia (https://keybase.io/alvarogarcia) on keybase.
  • I have a public key whose fingerprint is 317C 7705 8F59 B6A4 1793 7276 C2E9 0DD2 532C 9136

To claim this, I am signing this object:

@alvarogarcia7
alvarogarcia7 / better_image_tag.rb
Created June 9, 2016 14:32 — forked from pichfl/better_image_tag.rb
Liquid Image Tag for Jekyll
# Source is https://gist.github.com/pichfl/1548864
# A simple plugin for Jekyll that allows you to use {% img url "alt text" %} to add images to your posts.
# It will automatically check those images for width and height.
#
# Requires http://imagesize.rubyforge.org/
require 'image_size'
require 'open-uri'
module Jekyll
We will practice a programming problem, in pairs.
This time we'll do the Attack of the Comments Kata. Formulation is here: http://alvarogarcia7.github.io/blog/2016/03/01/kata-formulation-find-comments/.
Each pair will choose a programming language and will practice TDD.
At the end of the programming part, we will get together and discuss our solutions, pros and cons of each one.
After that, we will gather feedback about it for following sessions.
@alvarogarcia7
alvarogarcia7 / next-read-chooser.js
Created January 27, 2016 18:47
Choose the next item in pocket (getPocket.com)
var items = $(".item_link");
var size = items.size();
var nextLinkIndex = Math.floor((Math.random() * size));
var nextLink = items[nextLinkIndex];
//enable pop-ups if you have links to twitter or similar
nextLink.click();
@alvarogarcia7
alvarogarcia7 / pertree.clj
Last active September 23, 2015 07:41
Persisted tree kata
(defn mktree
([label l r] (cons label (cons l r)))
([leaf] (cons leaf (cons nil nil))))
(defn getlabel [t] (first t))
(defn getchildren [t] (rest t))
(defn getleft [t] (first (getchildren t)))
(defn getright [t] (rest (getchildren t)))
(defn find_ [t node]
(let [root (getlabel t)]
(cond
[
{ "keys": ["f5"],
"command": "insert_date",
"args": {"format": "%Y%m%d-%H%M%S AGB"} } // for python's date reference, take a look at this: https://docs.python.org/2/library/datetime.html
]
@alvarogarcia7
alvarogarcia7 / .bashrc
Created February 26, 2015 07:10
my git CLI settings as of 20150226-0807
# [...]
# only the part part of it that relates to git
alias g=git
# [...]
@alvarogarcia7
alvarogarcia7 / discussion-code-review
Created February 7, 2015 18:20
Java snippet for code review - purpose: cli application for adding all numbers that come as parameters
public class Main {
// See http://alvarogarcia7.github.io/blog/2015/02/07/open-discussion-on-code-reviews/
public static void main(String[] args){
int a = Integer.parseFrom(args[0]);
int b = Integer.parseFrom(args[2]);
int c = Integer.parseFrom(args[1]);
System.out.println(a + b + c);