Skip to content

Instantly share code, notes, and snippets.

Avatar

Maurício Hanika mAu888

View GitHub Profile
View firebase-remote-config.js
// 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 Aug 4, 2016 — forked from kgrz/workaround.md
Possible workaround for installing nokogiri 1.6.8 on OSX with brewed libxml2 2.9.4
View workaround.md

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:

View product.swift
struct Product {
let price: NSDecimalNumber
let locale: NSLocale
var priceString: String {
let formatter = NSNumberFormatter()
formatter.numberStyle = .CurrencyStyle
formatter.locale = locale
return formatter.stringFromNumber(price)!
}
View string_extension.swift
extension String {
var bytes: [UInt8]? {
return dataUsingEncoding(NSUTF8StringEncoding)
.flatMap { data in
return (0..<data.length).map {
UnsafeMutablePointer<UInt8>(data.bytes.advancedBy($0)).memory
}
}
}
}
View initial-test.swift
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 Apr 19, 2016
Finds an appointment for you at the Berliner Bürgeramt
View buergerbot.rb
#!/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
View ProfileViewModelTests.swift
class ProfileViewModelTests: XCTestCase {
func testDelegateNotifiedWhenProfileDeleted_Refactored() {
// given
let (viewModel, _, delegate) = initializedViewModel()
// when
viewModel.deleteProfile()
// then
XCTAssert(delegate.didDeleteUser)
View ProfileViewModelTests.swift
class ProfileViewModelTests: XCTestCase {
func testDelegateNotifiedWhenProfileDeleted() {
// given
let fakeClient = FakeAPIClient()
let delegate = FakeDelegate()
let viewModel = ProfileViewModel(apiClient: fakeClient, delegate: delegate)
// when
viewModel.deleteProfile()
View ProfileViewModel.swift
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 Aug 29, 2015
Resolve (short) URLs
View expandurl.sh
# 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