Skip to content

Instantly share code, notes, and snippets.

View mAu888's full-sized avatar

Maurício Hanika mAu888

View GitHub Profile
// Unselect all territories
$('.mat-option.mat-selected').click()
// Select all territories that are listed in the array
$('.mat-option').filter((idx, el) => { return ["Austria"].indexOf(el.children[1].textContent) != -1 }).click()
@mAu888
mAu888 / workaround.md
Created August 4, 2016 18:10 — forked from kgrz/workaround.md
Possible workaround for installing nokogiri 1.6.8 on OSX with brewed libxml2 2.9.4

Problem:

The following commands fail on OSX:

gem install nokogiri
gem install nokogiri -- --use-system-libraries
gem install nokogiri -- --use-system-libraries --with-xslt-dir=/usr/local/opt/libxslt --with-xml2-dir=/usr/local/opt/libxml2

Version:

struct Product {
let price: NSDecimalNumber
let locale: NSLocale
var priceString: String {
let formatter = NSNumberFormatter()
formatter.numberStyle = .CurrencyStyle
formatter.locale = locale
return formatter.stringFromNumber(price)!
}
extension String {
var bytes: [UInt8]? {
return dataUsingEncoding(NSUTF8StringEncoding)
.flatMap { data in
return (0..<data.length).map {
UnsafeMutablePointer<UInt8>(data.bytes.advancedBy($0)).memory
}
}
}
}
func testPriceIsBeingLocalizedForGivenLocale() {
let sut = Product(price: NSDecimalNumber(float: 9.99), locale: NSLocale(localeIdentifier: "de_DE"))
XCTAssertEqual(sut.priceString, "9,99 €")
}
@mAu888
mAu888 / buergerbot.rb
Created April 19, 2016 07:36
Finds an appointment for you at the Berliner Bürgeramt
#!/usr/bin/env ruby
require 'open-uri'
require 'nokogiri'
def log (message) puts " #{message}" end
def success (message) puts "+ #{message}" end
def fail (message) puts "- #{message}" end
def notify (message)
success message.upcase
system 'osascript -e \'Display notification "Bürgerbot" with title "%s"\'' % message
class ProfileViewModel {
let apiClient: APIClientType
weak var delegate: ProfileViewModelDelegate?
init(apiClient: APIClientType = APIClient(), delegate: ProfileViewModelDelegate) {
self.apiClient = apiClient
self.delegate = delegate
}
func deleteProfile() {
class ProfileViewModelTests: XCTestCase {
func testDelegateNotifiedWhenProfileDeleted_Refactored() {
// given
let (viewModel, _, delegate) = initializedViewModel()
// when
viewModel.deleteProfile()
// then
XCTAssert(delegate.didDeleteUser)
class ProfileViewModelTests: XCTestCase {
func testDelegateNotifiedWhenProfileDeleted() {
// given
let fakeClient = FakeAPIClient()
let delegate = FakeDelegate()
let viewModel = ProfileViewModel(apiClient: fakeClient, delegate: delegate)
// when
viewModel.deleteProfile()
@mAu888
mAu888 / git-sclean
Created November 1, 2012 12:50
git safe clean
#!/bin/bash
# Place this script under /usr/bin or /usr/local/bin
# and make it executable with sudo chmod +x /path/to/the/script/git-sclean
#
# Run git sclean from terminal and be happy!
# Dry-run git clean
git clean -n
CLEARFILES=$(git clean -n | wc -l | sed 's/[^0-9]*\([0-9]*\)[^0-9]*/\1/')