Skip to content

Instantly share code, notes, and snippets.

View x0000ff's full-sized avatar

Konstantin Portnov x0000ff

View GitHub Profile
@x0000ff
x0000ff / Git aliases.md
Last active April 22, 2024 08:41
Git aliases

What is Git alias

Git aliases is a useful way to save your keyboard from typing a lot.

git status My alias for finishing code review
git status finish-code-review

Let's create one

You can create an alias type in yor terminal:

@tadasr
tadasr / CodableStorage.swift
Last active February 7, 2023 14:14
The easiest way to store data model to file using `Codable` and `NSKeyedArchiver`.
import PlaygroundSupport
import Foundation
func load<T: Decodable>(from file: URL) -> T? {
guard let data = NSKeyedUnarchiver.unarchiveObject(withFile: file.path) as? Data else { return nil }
do {
let products = try PropertyListDecoder().decode(T.self, from: data)
print("Successful load")
return products
} catch let e {
@wojteklu
wojteklu / clean_code.md
Last active September 21, 2024 05:38
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@scottdelly
scottdelly / FacebookLogin.swift
Last active April 23, 2021 21:43
Facebook Login with iOS SDK 4.0 in Swift
//If you have a Bridging-Header:
#import <FBSDKCoreKit/FBSDKCoreKit.h>
#import <FBSDKLoginKit/FBSDKLoginKit.h>
//In your AppDelegate:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [String: AnyObject]?) -> Bool {
//App launch code
FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
//Optionally add to ensure your credentials are valid:
@kharmabum
kharmabum / ocmock-cheatsheet.m
Last active July 30, 2024 07:14
OCMock cheatsheet
/*----------------------------------------------------*/
#pragma mark - XCTAsserts
/*----------------------------------------------------*/
XCTAssert(expression, format...);
XCTAssertTrue(expression, format...);
XCTAssertFalse(expression, format...);
XCTAssertEqual(expression1, expression2, format...);
XCTAssertNotEqual(expression1, expression2, format...);
XCTAssertNil(expression, format...);
@alex-sysoev
alex-sysoev / vcr_spec.md
Last active August 29, 2015 14:05
Test Web Services with VCR

Testing Web Services with RSpec & VCR

Often our application interacts with different web services, in order to test it we need to do some preparations to be able to stub those requests and then if they take a lot of time to proceed - to replay the records of it without repeating real requests.

Installation

To install VCR we need to add two gems to the test group, gem webmock will be installed as a dependancy and will handle all the external requests, there are

@lttlrck
lttlrck / gist:9628955
Created March 18, 2014 20:34
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@samsalisbury
samsalisbury / .gitconfig
Last active June 22, 2022 19:30
Git diff and merge with p4merge (OSX)
[merge]
keepBackup = false
tool = p4merge
[mergetool "p4merge"]
cmd = /Applications/p4merge.app/Contents/Resources/launchp4merge "\"$PWD/$BASE\"" "\"$PWD/$REMOTE\"" "\"$PWD/$LOCAL\"" "\"$PWD/$MERGED\""
keepTemporaries = false
trustExitCode = false
keepBackup = false
[diff]
tool = p4merge
@digitaljhelms
digitaljhelms / gist:4287848
Last active September 19, 2024 06:16
Git/GitHub branching standards & conventions

Branching

Quick Legend

Description, Instructions, Notes
Instance Branch