Skip to content

Instantly share code, notes, and snippets.

View freemansion's full-sized avatar
🛠️
iOS Developer, growth hacking enthusiast

Stanislau Baranouski freemansion

🛠️
iOS Developer, growth hacking enthusiast
View GitHub Profile
@freemansion
freemansion / UserNotificationsExample.swift
Created April 6, 2021 09:19 — forked from quocnb/UserNotificationsExample.swift
UserNotifications iOS 10 Example
import UserNotifications
// 1. Request Permission
func requestAuthorization() {
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound]) { (granted, error) in
if granted {
// Success
} else {
// Error
print(error?.localizedDescription)
@freemansion
freemansion / starttmux.sh
Created February 25, 2019 11:38 — forked from todgru/starttmux.sh
Start up tmux with custom windows, panes and applications running
#!/bin/sh
#
# Setup a work space called `work` with two windows
# first window has 3 panes.
# The first pane set at 65%, split horizontally, set to api root and running vim
# pane 2 is split at 25% and running redis-server
# pane 3 is set to api root and bash prompt.
# note: `api` aliased to `cd ~/path/to/work`
#
session="work"
@freemansion
freemansion / tmux-cheatsheet.markdown
Created February 25, 2019 11:38 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@freemansion
freemansion / keybase.md
Created January 10, 2019 10:54
keybase prove

Keybase proof

I hereby claim:

  • I am freemansion on github.
  • I am freemansion (https://keybase.io/freemansion) on keybase.
  • I have a public key ASCVChC-Kpcjy1F-2-2pUHFWnV7LhTRTEQhMyLN4xAOdpQo

To claim this, I am signing this object:

@freemansion
freemansion / UITableViewHideEmptyRows.swift
Created November 12, 2018 06:23
UITableView hide empty rows example
import UIKit
class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {
let dataSource: [String] = [Int](0..<8).map { "Cell #\($0+1)" }
var tableView: UITableView?
static let cellIdentifier = "TableViewCellIdentifier"
override func viewDidLoad() {
super.viewDidLoad()
@freemansion
freemansion / FibonacciSequence.swift
Created September 21, 2018 07:17
Fibonacci sequence in swift
func fib(_ num: Int) -> Int {
switch num {
case Int.min...1: return max(0, num)
default: return fib(num-2) + fib(num-1)
}
}
Array(0...10).forEach { print(fib($0)) }
ACTION = build
AD_HOC_CODE_SIGNING_ALLOWED = NO
ALTERNATE_GROUP = staff
ALTERNATE_MODE = u+w,go-w,a+rX
ALTERNATE_OWNER = grantdavis
ALWAYS_SEARCH_USER_PATHS = NO
ALWAYS_USE_SEPARATE_HEADERMAPS = YES
APPLE_INTERNAL_DEVELOPER_DIR = /AppleInternal/Developer
APPLE_INTERNAL_DIR = /AppleInternal
APPLE_INTERNAL_DOCUMENTATION_DIR = /AppleInternal/Documentation
@freemansion
freemansion / HTTPStatusCode.swift
Created June 25, 2018 04:47 — forked from ollieatkinson/HTTPStatusCode.swift
HTTP status codes as a Swift enum.
/// This is a list of Hypertext Transfer Protocol (HTTP) response status codes.
/// It includes codes from IETF internet standards, other IETF RFCs, other specifications, and some additional commonly used codes.
/// The first digit of the status code specifies one of five classes of response; an HTTP client must recognise these five classes at a minimum.
enum HTTPStatusCode: Int, Error {
/// The response class representation of status codes, these get grouped by their first digit.
enum ResponseType {
/// - informational: This class of status code indicates a provisional response, consisting only of the Status-Line and optional headers, and is terminated by an empty line.
case informational
@freemansion
freemansion / XOR.swift
Created May 6, 2017 13:14 — forked from hollance/XOR.swift
Playing with BNNS (Swift version). The "hello world" of neural networks.
/*
The "hello world" of neural networks: a simple 3-layer feed-forward
network that implements an XOR logic gate.
The first layer is the input layer. It has two neurons a and b, which
are the two inputs to the XOR gate.
The middle layer is the hidden layer. This has two neurons h1, h2 that
will learn what it means to be an XOR gate.
@freemansion
freemansion / universal-framework.sh
Created September 15, 2016 16:28 — forked from cromandini/universal-framework.sh
This run script will build the iphoneos and iphonesimulator schemes and then combine them into a single framework using the lipo tool (including all the Swift module architectures).
#!/bin/sh
UNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal
# make sure the output directory exists
mkdir -p "${UNIVERSAL_OUTPUTFOLDER}"
# Step 1. Build Device and Simulator versions
xcodebuild -target "${PROJECT_NAME}" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build
xcodebuild -target "${PROJECT_NAME}" -configuration ${CONFIGURATION} -sdk iphonesimulator ONLY_ACTIVE_ARCH=NO BUILD_DIR="${BUILD_DIR}" BUILD_ROOT="${BUILD_ROOT}" clean build