Skip to content

Instantly share code, notes, and snippets.

@lizixroy
lizixroy / deprecated.py
Created June 15, 2018 20:02 — forked from Xion/deprecated.py
@deprecated decorator for Python classes
import functools
import inspect
import os
import warnings
class _DeprecatedDecorator(object):
MESSAGE = "%s is @deprecated"
def __call__(self, symbol):
class ViewController: UIViewController {
var aplysia: Aplysia?
@IBAction func touchSiphon(_ sender: Any) {
self.aplysia!.siphon.touch()
}
override func viewDidLoad() {
super.viewDidLoad()
@lizixroy
lizixroy / 0.article.swift
Last active April 2, 2017 06:17
Aplysia
class Neuron {
var incomingNeurons: [Neuron] = []
var outcomingNeurons: [Neuron] = []
var releasableSynapticVesicles: Int = 1000
private weak var timer: Timer?
init() {
Timer.scheduledTimer(withTimeInterval: 5, repeats: true, block: { _ in
self.replenishSynapticVesicles()
})
func submitButtonPressed {
showLoadingWheel()
defer { hideLoadingWheel() }
guard let username = validateInput() else {
showErrorAlert()
return
}
let payload = ["username": username];
webService.sendPOSTRequest(withPayload: payload)
func submitButtonPressed {
showLoadingWheel()
defer { hideLoadingWheel() }
guard validateInput() else {
hideLoadingWheel()
showErrorAlert()
return
}
}
@lizixroy
lizixroy / 1.article.swift
Created March 26, 2017 01:11
examples for blog
func performPreflightCheck -> Bool {
guard let fuelTank = self.fuelTank else { return false }
guard fuelTank.fuel.type == .jetFuel else { return false }
let destination = self.flightPlan.dest
let origin = self.flightPlan.origin
let distance = origin.distanceFrom(destination)
let currentFuelLevel = fuelTank.level
let currentBodyWeight = hardwareService.currentWeight
let windSpeed = WeatherService.averageWindSpeed(forFlightPlan:flightPlan)
@lizixroy
lizixroy / 0.article.swift
Created March 26, 2017 01:11
examples for blog
func performPreflightCheck -> Bool {
return checkFuelTank() && checkWeather() && checkEngines() && checkGPS() && checkLandingGears()
}
@lizixroy
lizixroy / universal-framework.sh
Created November 28, 2016 20:39 — 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
@lizixroy
lizixroy / 0.usage.swift
Created September 10, 2016 22:20
usage
func testMeToo() {
var optional: Bool?
let value = uw(optional) // instead of using "let value = optional!"
XCTAssertTrue(value)
}
@lizixroy
lizixroy / 0.usage.swift
Created September 10, 2016 22:10
usage
func testMe() {
let array = [1, 2, 3]
let b = g(array, at: 5) // instead of using a[5]
XCTAssertEqual(1, b)
}