Skip to content

Instantly share code, notes, and snippets.

@icanswiftabit
icanswiftabit / bundlerInIOS.MD
Last active April 6, 2024 14:54
How to use bundler with iOS projects

#How to use Bundler with iOS projects

You probably stuck with situation when after finishing for example bundle install && bundle exec pod install Bundler couldn't access gems which he just download. Some of you may think "RVM is the answer!" and yes it is, but what if it is not?

##Don't use macOS's gems. Just DON'T.

  1. Establish that you will don't use macOS's gems and RVM.
  2. Go to your_app_dir
  3. Make sure you have Gemfile if not create one
import UIKit
import XCPlayground
XCPlaygroundPage.currentPage.needsIndefiniteExecution = true
func perform(initial: Int) {
var value: Int = initial
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1), dispatch_get_main_queue()) { [myConstant = value] in
print("constant in first block \(myConstant)")
print("captured \(value)")
value = initial * 2
@josteink
josteink / on_stateful_code.txt
Last active October 21, 2020 05:37
On why stateful code is bad
On why stateful code is bad
===========================
STUDENT: Sir, can I ask a question?
TEACHER: Yes!
STUDENT: How do you put an elephant inside a fridge?
TEACHER: I don't know.
STUDENT: It's easy, you just open the fridge and put it in. I have another question!
TEACHER: Ok, ask.
STUDENT: How to put a donkey inside the fridge?
@chriseidhof
chriseidhof / AppDelegate.swift
Created December 13, 2015 15:05
Functional Swift Talk
import UIKit
struct Screen<A> {
let run: (A -> ()) -> UIViewController
}
struct Step<A> {
let build: (navigationController: UINavigationController, callback: A -> ()) -> UIViewController
}
@nicklockwood
nicklockwood / gist:21495c2015fd2dda56cf
Last active August 13, 2020 13:57
Thoughts on Swift 2 Errors

Thoughts on Swift 2 Errors

When Swift was first announced, I was gratified to see that one of the (few) philosophies that it shared with Objective-C was that exceptions should not be used for control flow, only for highlighting fatal programming errors at development time.

So it came as a surprise to me when Swift 2 brought (What appeared to be) traditional exception handling to the language.

Similarly surprised were the functional Swift programmers, who had put their faith in the Haskell-style approach to error handling, where every function returns an enum (or monad, if you like) containing either a valid result or an error. This seemed like a natural fit for Swift, so why did Apple instead opt for a solution originally designed for clumsy imperative languages?

I'm going to cover three things in this post:

@omgmog
omgmog / gist:33ec177eea6b78adbaf3
Created May 28, 2014 14:28
Convert an m4v to gif with ffmpeg
ffmpeg -i input.m4v -pix_fmt rgb24 -r 10 -y -s [width]x[height] output.gif
@dergachev
dergachev / GIF-Screencast-OSX.md
Last active July 17, 2024 14:20
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: