Instantly share code, notes, and snippets.

View SaliencyDetector.h
//
// Copyright © 2018 wojteklu. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface SaliencyDetector: NSObject
-(CGRect)findMostProminentPartOfImage:(UIImage *)image;
-(UIImage *)selectMostProminentPartOfImage:(UIImage *)image;
View Throttler.swift
public class Throttler {
private let queue: DispatchQueue = DispatchQueue.global(qos: .background)
private var job: DispatchWorkItem = DispatchWorkItem(block: {})
private var previousRun: Date = Date.distantPast
private var maxInterval: TimeInterval
public init(maxInterval: TimeInterval) {
self.maxInterval = maxInterval
View Breakpoints_v2.xcbkptlist
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
type = "2"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.ExceptionBreakpoint">
<BreakpointContent
shouldBeEnabled = "Yes"
ignoreCount = "0"
View backtracking.swift
class Board: CustomStringConvertible {
var values: [Int]
let kSize = 9 // number of rows and columns
init(_ string: String) {
values = string.characters.map { Int(String($0)) ?? 0 }
}
var empty: Int? {
return values.index(of: 0)
View board.swift
class Board {
fileprivate let kSize = 9 // number of rows and columns
fileprivate var squares: [Square]
fileprivate var units: [[[Int]]] = []
fileprivate var peers: [[Int]] = []
init(_ string: String) {
squares = [Square](repeating: Square(0b111111111), count: kSize * kSize)
for index in 0..<(kSize * kSize) {
View bayes.go
package bayes
// Classifier implements the Naive Bayes Classifier.
type Classifier struct {
classPerWordCount map[string]int
classPerDocument map[string]int
wordClassCount map[string]map[string]int
documentsCount int
}
View clean_code.md

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

View terminal_notification.md

Add the following to your ~/.zshrc:

function notifyme {
  LAST_EXIT_CODE=$?
  CMD=$(fc -ln -1)
  osascript -e 'on run argv
  tell application "System Events"
    set frontApp to name of first application process whose frontmost is true
    if frontApp is not "Terminal" then
View gitenv.md

Perfect git environment on OS X

Global alias

Add the following to your ~/.bashrc:

alias g='git'

Branch auto-completion