Skip to content

Instantly share code, notes, and snippets.

François Lamboley Frizlab

  • Frost Land
  • Paris, France
Block or report user

Report or block Frizlab

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View NSLocale.m
/*
======================================================
THIS CODE IS FOR EDUCATIONAL PURPOSES ONLY.
I'M NOT RESPONSIBLE IF YOU SHIP THIS AND IT BLOWS UP IN YOUR FACE.
IF IT DOES AND YOU COMPLAIN TO ME I WILL LAUGH AT YOU.
@DougGregor
DougGregor / dynamic_member_lookup_environment.swift
Created May 2, 2018
Using Swift 4.2's @dynamicMemberLookup to expose environment variables
View dynamic_member_lookup_environment.swift
import Darwin
@dynamicMemberLookup
struct Environment {
subscript(dynamicMember name: String) -> String? {
get {
guard let value = getenv(name) else { return nil }
return String(validatingUTF8: value)
}
@lattner
lattner / async_swift_proposal.md
Last active Nov 11, 2019 — forked from oleganza/async_swift_proposal.md
Concrete proposal for async semantics in Swift
View async_swift_proposal.md

Async/Await for Swift

Introduction

Modern Cocoa development involves a lot of asynchronous programming using closures and completion handlers, but these APIs are hard to use. This gets particularly problematic when many asynchronous operations are used, error handling is required, or control flow between asynchronous calls gets complicated. This proposal describes a language extension to make this a lot more natural and less error prone.

This paper introduces a first class Coroutine model to Swift. Functions can opt into to being async, allowing the programmer to compose complex logic involving asynchronous operations, leaving the compiler in charge of producing the necessary closures and state machines to implement that logic.

@hollance
hollance / neural.c
Last active Nov 5, 2019
Playing with BNNS on macOS 10.12. The "hello world" of neural networks.
View neural.c
/*
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.
@jakubpetrik
jakubpetrik / handle-signal.swift
Created Sep 23, 2015
Signal handling in Swift
View handle-signal.swift
/**
http://rosettacode.org/wiki/Handle_a_signal
Most general purpose operating systems provide interrupt facilities, sometimes called signals.
Unhandled signals generally terminate a program in a disorderly manner. Signal handlers are
created so that the program behaves in a well-defined manner upon receipt of a signal.
For this task you will provide a program that displays a single integer on each line of output at
the rate of one integer in each half second. Upon receipt of the SigInt signal (often created by the user typing ctrl-C)
the program will cease printing integers to its output, print the number of seconds the program has run,
@JadenGeller
JadenGeller / AnySet.swift
Created Mar 30, 2015
Swift Set of "Any" Type
View AnySet.swift
// Examples
var set = AnySet()
set.insert(3)
set.insert("hello")
set.insert("hi")
set.insert(2.3)
set.contains(6) // -> false
set.contains(3) // -> true
@natecook1000
natecook1000 / NSScanner+Swift.swift
Created Mar 3, 2015
Swift-friendly NSScanner methods
View NSScanner+Swift.swift
// NSScanner+Swift.swift
// A set of Swift-idiomatic methods for NSScanner
//
// (c) 2015 Nate Cook, licensed under the MIT license
import Foundation
extension NSScanner {
// MARK: Strings
@seanlilmateus
seanlilmateus / channel.swift
Last active Nov 22, 2017
swift Go like channels
View channel.swift
import Foundation
// Playground - noun: a place where people can play
class Channel<T> {
var stream: Array<T>
let queue: dispatch_queue_t
let semaphore: dispatch_semaphore_t
init() {
self.stream = []
@jverkoey
jverkoey / NSManagedObjectContext+DebugSwizzling.m
Created Apr 14, 2014
Core Data Managed Object Context Debugging
View NSManagedObjectContext+DebugSwizzling.m
// NSManagedObjectContext+DebugSwizzling.h
#import <CoreData/CoreData.h>
#if DEBUG
/**
* Toggles debugging of Core Data managed object contexts.
*
* When enabled, will fire NSLogs in the following cases:
@rickharrison
rickharrison / UIViewController.m
Created Aug 16, 2013
iOS 7 Messages Gradient Experimentation
View UIViewController.m
//
// NRTRootViewController.m
// GradientTableView
//
// Created by Rick Harrison on 8/15/13.
// Copyright (c) 2013 Rick Harrison. All rights reserved.
//
#import "NRTRootViewController.h"
You can’t perform that action at this time.