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
@tylermilner
tylermilner / Slow_Compiling_Swift_Code.swift
Created November 27, 2017 22:55
Code samples of common sources of slowdowns for the Swift 2/3 compiler.
//
// The code snippets below showcase common "problem code" that can take a long time to compile.
// These examples were primarily observed in Swift 2/3 and may no longer be relevant in Swift 4 or higher.
//
/// 1. Array concatenation
// Observed by Robert Gummesson - https://medium.com/@RobertGummesson/regarding-swift-build-time-optimizations-fc92cdd91e31#c75c
// Joining two arrays together with the '+' operator can be expensive to compile.
let someArray = ["a", "b"] + ["c", "d"]
@quocnb
quocnb / UserNotificationsExample.swift
Last active March 16, 2022 12:28
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)
@ilyapuchka
ilyapuchka / UIVisualEffect.swift
Last active January 21, 2020 21:57
(Ab)using UIVisualEffectView effect settings
extension UIVisualEffectView {
private var filterLayer: CALayer? {
return layer.sublayers?.first
}
private var blurFilter: NSObject? {
return filterLayer?
.filters?.flatMap({ $0 as? NSObject })
.first(where: { $0.value(forKey: "name") as? String == "gaussianBlur" })
@yossorion
yossorion / what-i-wish-id-known-about-equity-before-joining-a-unicorn.md
Last active April 7, 2024 22:55
What I Wish I'd Known About Equity Before Joining A Unicorn

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

@hollance
hollance / XOR.swift
Created January 11, 2017 18:05
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.
@khorbushko
khorbushko / PHPhotoLibrary+SaveImage
Created December 29, 2016 09:27
PHPhotoLibrary+SaveImage - save image with Photos Framework swift 3
import UIKit
import Photos
extension PHPhotoLibrary {
// MARK: - PHPhotoLibrary+SaveImage
// MARK: - Public
func savePhoto(image:UIImage, albumName:String, completion:((PHAsset?)->())? = nil) {
func save() {
@ollieatkinson
ollieatkinson / HTTPStatusCode.swift
Last active April 15, 2024 18:34
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
@dimi-tree
dimi-tree / 01_models.py
Last active November 17, 2020 07:16
Django REST Framework: understaning ModelSerializer
from django.db import models
class Member(models.Model):
# RE: null vs blank
#
# NULL https://docs.djangoproject.com/en/1.10/ref/models/fields/#null
# Avoid using null on string-based fields such as CharField and TextField because
# empty string values will always be stored as empty strings, not as NULL.
#
@pandafulmanda
pandafulmanda / Python3 Virtualenv Setup.md
Last active March 12, 2024 15:59 — forked from akszydelko/Python3 Virtualenv Setup.md
Setting up and using Python3 Virtualenv on Mac

Python3 Virtualenv Setup

Requirements
  • Python 3
  • Pip 3
$ brew install python3
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<string>fb254145378030027</string>
<string>isupr8</string>
<string>fb176151905794941</string>
<string>recipeSearch-iPad</string>
<string>airfile</string>
<string>univision</string>