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 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()
class ProfileViewModel {
let apiClient: APIClientType
weak var delegate: ProfileViewModelDelegate?
init(apiClient: APIClientType = APIClient(), delegate: ProfileViewModelDelegate) {
self.apiClient = apiClient
self.delegate = delegate
}
func deleteProfile() {
@mAu888
mAu888 / expandurl.sh
Last active August 29, 2015 14:26
Resolve (short) URLs
# Put this into your `~/.bashrc` and `source ~/.bashrc`
function expandurl {
# -s Only output
# -I HEAD request
# -L Follow redirects. Combined with -I will print headers from all intermediate redirects
REDIRECTS=$(curl -sIL $1 | grep ^Location);
if [[ -z $REDIRECTS ]]; then
echo "Location: ${1}";
else