Skip to content

Instantly share code, notes, and snippets.

View rbsgn's full-sized avatar

Roman Busygin rbsgn

  • Dodo Engineering
  • Moscow
  • X @rbsgn
View GitHub Profile
@rbsgn
rbsgn / sweet-doubles.swift
Last active October 13, 2015 18:58
Sweet and concise stubbing and dummying in Swift
struct Money {
let currencyCode: String
let cents: Int
}
struct Cost {
let price: Money
let fee: Money
let total: Money
}
@rbsgn
rbsgn / StubHTTP.swift
Last active October 29, 2015 07:37
A minimum viable HTTP response stubber
import Foundation
class StubHTTP: NSURLProtocol {
// MARK: - Public Interface
class func stubRequest(requestTest: NSURLRequest -> Bool, withResponse data: NSData) {
stubRequest(requestTest, withResponses: [data])
}
@rbsgn
rbsgn / FBAnimationPerformanceTracker.h
Last active August 29, 2015 14:25 — forked from clementgenzmer/FBAnimationPerformanceTracker.h
FBAnimationPerformanceTracker
/*
* This is an example provided by Facebook are for non-commercial testing and
* evaluation purposes only.
*
* Facebook reserves all rights not expressly granted.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL
* FACEBOOK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
@rbsgn
rbsgn / gist:205d619bdb5dfa5f8489
Created June 29, 2015 07:45
Merge pull request from the command line
  1. git ls-remote origin to find pull request you want to merge. Usually their names start with refs/pull-requests/$ID/from (Atlassian Stash style) or refs/pull/$ID/head (GitHub style).
  2. git fetch origin refs/pull-requests/$ID/from or git fetch origin refs/pull/$ID/head and work with the branch from FETCH_HEAD
@rbsgn
rbsgn / TC agent as a service with Xcode 6.md
Last active October 25, 2020 21:25
TeamCity build agent as a launchd service done right

There are several complaints regarding TeamCity build agent can't run tests in iOS Simulator all gathered in issue TW-38954 Agent started automatically on Yosemite could not launch iOS simulator.

Official workaround from JetBrains found on StackOverflow for this issue looks like this:

$ sh buildAgent/bin/agent.sh start

This means we should convert from automatic launch by launchd to manual via Terminal.app. Side effect of this is no relaunch on agent crash or system reboot.

Further investigation on that issue has led me to the Apple Developer Forums topic where Apple engineer claims following about xcodebuild:

@rbsgn
rbsgn / .bashrc
Last active August 29, 2015 14:07
Terminal setup
readonly GIT_CORE='/Applications/Xcode.app/Contents/Developer/usr/share/git-core'
readonly GIT_BASH_COMPLETION="$GIT_CORE/git-completion.bash"
readonly GIT_PS1="$GIT_CORE/git-prompt.sh"
[ -f "$GIT_BASH_COMPLETION" ] && source "$GIT_BASH_COMPLETION"
if [ -f "$GIT_PS1" ] ; then
source "$GIT_PS1"
export PS1='[\A] $(tput setaf 2)\u$(tput sgr0):\w$(tput setaf 1)$(__git_ps1 " (%s)")$(tput sgr0) $ '
else
export PS1="[\A] $(tput setaf 2)\u$(tput sgr0):\w $ "

Patch flushDNSCache function located in /Applications/Tunnelblick.app/Contents/Resources/client.up.tunnelblick.sh with following code inside case statement:

10.10 )
  if [ -x /usr/sbin/discoveryutil ] ; then
    /usr/sbin/discoveryutil mdnsflushcache
    logMessage "Flushed the DNS Cache"
  else
    logMessage "/usr/sbin/discoveryutil not present. Not flushing the DNS cache"
 fi
@rbsgn
rbsgn / gist:7331483
Created November 6, 2013 05:42
Last night I discovered Array#each_cons. Now I love Ruby even more!
2.0.0-p247 :008 > Array(1..5).each_cons(2) { |first, second| puts "#{first}, #{second}" }
1, 2
2, 3
3, 4
4, 5
=> nil
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
MKPlacemark *firstPlacemark = [[MKPlacemark alloc] initWithCoordinate:CLLocationCoordinate2DMake(55.755768, 37.617671)
addressDictionary:nil];
MKPlacemark *secondPlacemark = [[MKPlacemark alloc] initWithCoordinate:CLLocationCoordinate2DMake(55.910528, 37.736339)
addressDictionary:nil];
#!/usr/bin/perl -w
# Copyright (C) 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.