Skip to content

Instantly share code, notes, and snippets.

View elgalu's full-sized avatar

Leo Gallucci elgalu

View GitHub Profile
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html"/>
<xsl:template match="/">
<xsl:text disable-output-escaping="yes"><![CDATA[<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">]]></xsl:text>
<html>
<head>
<title>
Xunit Test Results - For: <xsl:value-of select="@name"/>
</title>
@elgalu
elgalu / steps.md
Last active January 4, 2016 12:19 — forked from carlosmcevilly/gist:2221249
Fix commit author of last commit
  1. Fix your email address in git config
git config user.name "Your Name"
git config user.email "your@address.com"
git submodule foreach --recursive 'git config user.name "Your Name" && git config user.email "your@address.com"'
  1. Rebase
@elgalu
elgalu / keybindings.pl
Created January 19, 2014 22:27
Export Ubuntu shortcuts: keybindings.pl -e keys.csv ;; Import (DANGER) Ubuntu shortcuts: keybindings.pl -i keys.csv
#!/usr/bin/perl
use strict;
my $action = '';
my $filename = '-';
for my $arg (@ARGV){
if ($arg eq "-e" or $arg eq "--export"){
$action = 'export';
@elgalu
elgalu / set_xvfb.sh
Last active January 3, 2016 13:59
ChromeDriver headless testing on debian-based unix systemsBased on: https://www.exratione.com/2013/12/angularjs-headless-end-to-end-testing-with-protractor-and-selenium/
sudo apt-get install xvfb
sudo vim /etc/init.d/xvfb
sudo chown root:root /etc/init.d/xvfb
sudo chmod a+x /etc/init.d/xvfb
sudo update-rc.d xvfb defaults
# The Ubuntu server can now run software with a GUI in a headless mode
@elgalu
elgalu / README.md
Last active December 31, 2015 22:48
AngularJS apps testing through Karma and Protractor
@elgalu
elgalu / a-drip-of-javascript-quiz.js
Created September 4, 2013 23:10
A Drip of JavaScript - book notes / quizzes
// Explain what the Function.prototype.bind method allows.
// Use properly to fix this TypeError: Illegal invocation
var myLog = console.log;
myLog("hola");
=>
// The bind method allows us to create a new function which is permanently bound to a given value of `this`
var myLog = console.log.bind(console);
myLog("hola"); //==> "hola"
// As a bonus, you can't override its `this` value using call or apply.
myLog.call(window, "hello"); // will be ignored and will keep bound to console.log()
@elgalu
elgalu / create_new_empty_file.ahk
Last active December 21, 2015 16:48
Hotkey to create a new empty file in Windows Explorer {Ctrl+Alt+N} using AutoHotKey. When in Windows Explorer this allows you to press {Ctrl+Alt+N} then type a file name that will be created in the current directory. In a similar way you use {Ctrl+Shift+N} to create a new folder. Tested on Windows 8 x64 (2012); AutoHotKey 1.1.11 (2013)
;------------------------------------------------------------------------------
;begin Create a new file with Ctrl+Alt+N keyboard shortcut in Windows Explorer
;------------------------------------------------------------------------------
SetTitleMatchMode RegEx
; Ctrl+Alt+N to create new empty file
#IfWinActive ahk_class CabinetWClass ;Windows Explorer
^!n::
ExplorerFocusFilePane()
Sleep 50
Send {End}
@elgalu
elgalu / custom_events.js
Last active December 20, 2015 06:18
Decoupling event/DOM/business logic using custom jQuery events http://flippinawesome.org/?p=662 http://jsfiddle.net/elgalu/C7kbK/
/////////////////////////////////////////////////////////////
// Creating a custom event listener on the document object //
/////////////////////////////////////////////////////////////
var $doc = $(document);
var $items = $('.items');
var $log = $('.log');
// DOM-related logic
$doc.on('addItem', function (event, value) {
$items.append('<li>New item ' + value + '</li>')
@elgalu
elgalu / order_service.rb
Created July 24, 2013 04:26
Services Objects: Moving Behavior from Controllers http://goo.gl/jtjDw
module OrderService
def self.create(listener, user, order_attrs)
Order.new(order_attrs.merge(user: current_user))
if order.save
transaction = PaymentProcessor.create_payment(order)
listener.order_creation_succeeded(order, transaction)
else
listener.order_creation_failed(order)
end
end
@elgalu
elgalu / decorator-pattern-with-ruby-in-8-lines.rb
Last active December 19, 2015 17:09
Decorator Pattern with Ruby in 8 lines - http://goo.gl/d960j
module Decorator
def initialize(decorated)
@decorated = decorated
end
def method_missing(method, *args)
args.empty? ? @decorated.send(method) : @decorated.send(method, args)
end
end