by Ossi Hanhinen, @ohanhi
with the support of Futurice 💚.
Licensed under CC BY 4.0.
import Foundation | |
protocol Channel: IteratorProtocol { | |
func send(_ value: Element?) | |
} | |
/// A blocking channel for sending values. | |
/// | |
/// `send` and `receive` must run in separate separate execution contexts, otherwise you get a deadlock. | |
final class BlockingChannel<A>: Channel { |
// A common redux pattern when dealing with async functions is to use thunk. | |
// This usually means your action returns a new function instead of an action object, | |
// and the thunk middleware will make it all work. Example: | |
const asyncAction = () => dispatch => setTimeout(() => dispatch(someOtherAction()), 10000); | |
// Now: maybe that async stuff going on is calling some API which you don't want to overload | |
// with request, and that's what debounce is for. | |
// This is an example of a debounced function which will only be calleable once every second. | |
import { debounce } from 'lodash'; | |
const debouncedFn = debounce(() => callApi(), 1000, { leading: true, trailing: false }); |
The easiest way to start using the LLVM C++ API by example is to have LLVM generate the API usage for a given code sample. In this example it will emit the code required to rebuild the test.c
sample by using LLVM:
$ clang -c -emit-llvm test.c -o test.ll
$ llc -march=cpp test.ll -o test.cpp
operator infix --> {} | |
func --> (instance: Any, key: String) -> Any? { | |
let mirror = reflect(instance) | |
for index in 0 ..< mirror.count { | |
let (childKey, childMirror) = mirror[index] | |
if childKey == key { | |
return childMirror.value | |
} | |
} |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
DIR = File.dirname(__FILE__) | |
BRIDGESUPPORT_FILE = "BridgeSupport.bridgesupport" | |
namespace :gen do | |
desc "Generates the bridgesupport file for RubyMotion" | |
task :bridgesupport do | |
Dir.chdir(DIR) do | |
SHELL_COMMAND=<<-EOS.gsub(/^\s*/, '') |
// | |
// FGOManagedObjectContextStack.h | |
// | |
// Created by Indragie Karunaratne on 2012-12-23. | |
// | |
#import <Foundation/Foundation.h> | |
typedef void (^FGOConfigurationBlock)(id); |
class people::jfryman { | |
# Applications | |
include chrome::stable | |
include onepassword | |
include dropbox | |
include alfred | |
include macvim | |
include zsh | |
include homebrew | |
include fitbit |
@synthesize firstName = _firstName; | |
@synthesize txtFirstName = _txtFirstName; | |
[RACAbleSelf(self.firstName) subscribeNext:^(id x) { [self firstNameChanged:x]; }]; | |
[self rac_bind:RAC_KEYPATH_SELF(self.firstName) to:self.txtFirstName.rac_textSubscribable]; | |
- (void) firstNameChanged:(id)firstName { | |
NSLog(@"changed: %@", firstName); | |
} |