Notes on AngularJS apps testing through Karma and Protractor
This file contains hidden or 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 'clipboard' #gem install clipboard | |
| def cbcopy(value) | |
| Clipboard.copy value unless value.empty? | |
| flash_message = value.empty? ? "Sorry, nothing to copy" : "Copied to clipboard" | |
| print "# #{flash_message}: " | |
| puts %Q("#{value}") | |
| end | |
| # Copy last result to the Clipboard |
This file contains hidden or 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
| module Decorator | |
| def initialize(decorated) | |
| @decorated = decorated | |
| end | |
| def method_missing(method, *args) | |
| args.empty? ? @decorated.send(method) : @decorated.send(method, args) | |
| end | |
| end |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| ///////////////////////////////////////////////////////////// | |
| // 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>') |
This file contains hidden or 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
| ;------------------------------------------------------------------------------ | |
| ;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} |
This file contains hidden or 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
| // 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() |
This file contains hidden or 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
| 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 |
This file contains hidden or 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
| #!/usr/bin/perl | |
| use strict; | |
| my $action = ''; | |
| my $filename = '-'; | |
| for my $arg (@ARGV){ | |
| if ($arg eq "-e" or $arg eq "--export"){ | |
| $action = 'export'; |
- 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"'
- Rebase