Skip to content

Instantly share code, notes, and snippets.

View rmnblm's full-sized avatar
🍾
Uncorking

Roman Blum rmnblm

🍾
Uncorking
View GitHub Profile
import UIKit
private class Line {
var path = UIBezierPath()
var layer = CAShapeLayer()
}
private enum AnimationKey {
static let activeStart = "ActiveLineStartAnimation"
@rmnblm
rmnblm / scopes.js
Last active February 1, 2017 12:20
Hoisting and Scopes in ES6
(function () {
l1 = 'STEP 1';
console.log(l1); // Output: STEP 1
if (true) {
console.log(l1); // Output: STEP 1
var l1 = 'STEP 2'; // var isn't block-scoped, gets hoisted
console.log(l1); // Output: STEP 2
}
@rmnblm
rmnblm / nullable_example.cs
Last active December 17, 2016 15:20
Swift Optionals in C#
// int num = null; -> Error
int? num = null;
if (num.HasValue)
{
System.Console.WriteLine("num = " + num.Value);
}
else
{
System.Console.WriteLine("num = Null");
@rmnblm
rmnblm / GIF-Screencast-OSX.md
Created December 12, 2016 15:18 — forked from dergachev/GIF-Screencast-OSX.md
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@rmnblm
rmnblm / optionals_part1.swift
Last active December 12, 2016 07:53
Swift: Optionals Part 1
var text: String?
print(text)
// Output: nil
print(text ?? "B")
// Output: B
text = "A"
print(text ?? "B")
// Output: A
print(text)
// Output: Optional("A")
@rmnblm
rmnblm / guards.swift
Last active December 12, 2016 07:28
Swift: Guards
// Declare an optional variable
var name: String? = "Roman"
guard let name = name else {
print("name is nil")
return
}
print(name)
// Output: Roman
@rmnblm
rmnblm / pyramid_of_doom.swift
Last active December 12, 2016 07:13
Swift: Pyramid of Doom
/* Example JSON Object
{
"key": {
"nestedKey": {
"nestedKey": {
"nestedKey": 42.0
}
}
}
@rmnblm
rmnblm / optionals_part3.swift
Last active December 12, 2016 07:53
Swift: Optionals Part 3
// Declare two optional values
var firstName: String? = "Roman"
var lastName: String? = "Blum"
// Option 1: Nested
if let firstName = firstName {
if let lastName = lastName {
// Use firstName and lastName
}
}
@rmnblm
rmnblm / optionals_part2.swift
Last active December 12, 2016 07:54
Swift: Optionals Part 2
// Declare an optional value
var name: String? = "Roman"
// Optional chaining
name?.characters.count
if name != nil {
// Force unwrap
name!.characters.count
}
@rmnblm
rmnblm / if_vs_guard.swift
Last active December 12, 2016 07:29
Swift: if vs. guard
// Declare three optional variables
var firstName: String?
var lastName: String?
var age: Int?
// EXAMPLE: if-Statement
if let firstName = firstName {
if let lastName = lastName {
if let age = age, age >= 18 {
doSomething(firstName, lastName, age)