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
class CatalogExportingTests: XCTestCase {
var container: NSPersistentContainer!
override func setUp() {
guard
let managedObjectModelURL =
Bundle(for: Self.self).url(
forResource: "GoShopping",
withExtension: "momd"
class RefactoredCatalogExportingTests: XCTestCase {
func test_Categories_Are_Exported_By_DisplayOrder() {
let fooCategory = CatalogCategory2(displayOrder: 1, name: "Foo")
let barCategory = CatalogCategory2(displayOrder: 2, name: "Bar")
let stubCatalog = StubCatalog(stubs: [fooCategory, barCategory])
let catalogExporter = CatalogExporter()
let exportedCatalog = catalogExporter.export(stubCatalog)
XCTAssertEqual(exportedCatalog.count, 2)
@rbsgn
rbsgn / WelcomeViewController.swift
Last active April 13, 2020 11:05
Conditionals vs. State Pattern View Controller implementation
import UIKit
class WelcomeViewController: UIViewController {
override func loadView() {
let view = UIView(frame: .zero)
view.backgroundColor = .systemBackground
let title = makeTitleLabel()
import UIKit
class WelcomeViewController: UIViewController {
override func loadView() {
let view = UIView(frame: .zero)
view.backgroundColor = .systemBackground
let title = makeTitleLabel()
@rbsgn
rbsgn / UB.h
Created January 17, 2018 08:32
Is this an undefined behaviour in Objective-C?
#import <Foundation/Foundation.h>
@interface Foo : NSObject
@end
@interface Foo (UndefinedBehaviour)
- (void)foo:(id)foo bar:(id)bar;
@rbsgn
rbsgn / vlc-ios-upload.sh
Last active January 19, 2024 23:37
upload videos to VLC running on iOS device
IP=10.0.1.18
for f in *; do
echo ">>> Uploading $f <<<"
curl \
--progress-bar \
--form "files[]=@$f" \
http://"$IP"/upload.json \
| tee -a vlc-ios-upload.log; test ${PIPESTATUS[0]} -eq 0
@rbsgn
rbsgn / .rvmrc
Created November 28, 2016 09:05
export rvm_project_rvmrc_default=1
export rvm_pretty_print_flag=auto
rvm_with_gems="cocoapods"
rvm_with_default_gems="cocoapods"
@rbsgn
rbsgn / .bashrc
Last active November 28, 2016 09:06
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 $ "
import CoreData
func newManagedObjectModel() -> NSManagedObjectModel {
// you get new instance of MOM with the same properties
// each time you call the function.
// this function uses entity description returned by
// newEntityDescription function
}
func newEntityDescription() -> NSEntityDescription {
@rbsgn
rbsgn / json.swift
Created November 7, 2015 20:21
JSON in Swift
enum JSON {
indirect case Object([Swift.String: JSON])
indirect case Array([JSON])
case String(Swift.String)
case Number(Int)
case Boolean(Bool)
case Null
}
let json = JSON.Object(["foo": JSON.String("bar")])