Skip to content

Instantly share code, notes, and snippets.

Avatar

Roman Busygin rbsgn

  • Dodo Engineering
  • Moscow
  • Twitter @rbsgn
View GitHub Profile
View inital_test.swift
class CatalogExportingTests: XCTestCase {
var container: NSPersistentContainer!
override func setUp() {
guard
let managedObjectModelURL =
Bundle(for: Self.self).url(
forResource: "GoShopping",
withExtension: "momd"
View refactored_test.swift
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
View WelcomeViewController.swift
import UIKit
class WelcomeViewController: UIViewController {
override func loadView() {
let view = UIView(frame: .zero)
view.backgroundColor = .systemBackground
let title = makeTitleLabel()
View WelcomeViewController.swift
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?
View UB.h
#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 May 19, 2020 17:15
upload videos to VLC running on iOS device
View vlc-ios-upload.sh
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
View .rvmrc
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
View .bashrc
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 $ "
View mom + psc issue.swift
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
View json.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")])