Skip to content

Instantly share code, notes, and snippets.

View berkus's full-sized avatar
🎯
Practice your desensitization exercises to remain unfazed by enemy atrocities

Berkus Decker berkus

🎯
Practice your desensitization exercises to remain unfazed by enemy atrocities
View GitHub Profile
////////// Usage ///////////
this.BindRadioButtons(v => v.ViewModel.RadioButtonValue,
v => v.RadioButtonA, "A",
v => v.RadioButtonB, "B");
////////// Implementation ///////////
public static IDisposable BindRadioButtons<TSender, TViewModelValue>(this TSender view,
Expression<Func<TSender, TViewModelValue>> viewModelProperty,
@jish
jish / promise.js
Created October 28, 2014 22:35
An example "always" behavior for ES6 promises. This only works if you do not create / return intermediate promises.
// A thing I want to do
// This flow only involves **one** promise, for example an ajax call
// None of the subsequent `then` or `catch` calls, return new promises.
var explode = false;
var promise = new Promise(function(resolve, reject) {
if (explode) {
@jansegre
jansegre / script.lua
Last active February 10, 2020 23:48
Very basic luajit from Rust.
-- script.lua
-- Receives a table, returns the sum of its components.
io.write("The table the script received has:\n");
x = 0
for i = 1, #foo do
print(i, foo[i])
x = x + foo[i]
end
io.write("Returning data back to C\n");
return x
@staltz
staltz / introrx.md
Last active April 19, 2025 05:15
The introduction to Reactive Programming you've been missing
@digal
digal / gist:11a482e47ee1b56c4b04
Last active August 29, 2015 14:02
Syncronous data fetcher in swift
//@auto_closure hack to prevent `LLVM ERROR: unimplemented IRGen feature! non-fixed multi-payload enum layout`
//as in https://github.com/maxpow4h/swiftz/blob/master/swiftz/Either.swift
enum Either<L,R> {
case Left(@auto_closure () -> L)
case Right(@auto_closure () -> R)
func flatMapLeft<L1>(f: (L) -> Either<L1, R>) -> Either<L1, R> {
switch self {
case let .Left(l): return f(l())
case let .Right(r): return .Right(r)
@cobbal
cobbal / monad.swift
Last active April 6, 2016 04:40
Monad protocol in swift
protocol Monad {
typealias F
typealias U
class func bind<M : Monad where M.U == U>(Self, F -> M) -> M
class func `return`(F) -> Self
}
extension Array : Monad {
typealias F = T
@andyshep
andyshep / PASDataSource.h
Created June 3, 2014 21:27
A network layer using ReactiveCocoa
#import <Foundation/Foundation.h>
#import <ReactiveCocoa/ReactiveCocoa.h>
@interface PASDataSource : NSObject
@property (nonatomic, strong, readonly) NSArray *passes;
+ (PASDataSource *)sharedInstance;
- (RACSignal *)refreshPassInfoSignal;
@nikolaykasyanov
nikolaykasyanov / RAC.swift
Last active August 29, 2015 14:02
Proof-of-concept typesafe RAC wrapper
protocol ISubscriber {
typealias Element
func disposable() -> RACCompoundDisposable
func sendNext(e: Element)
func sendError(e: NSError)
func sendCompleted()
}
@jquave
jquave / Swift Part 2 jamesonquave.com
Created June 3, 2014 00:37
Part 2 of the Swift tutorial at jamesonquave.com
//
// ViewController.swift
// TestSwift
//
// Created by Jameson Quave on 6/2/14.
// Copyright (c) 2014 JQ Software LLC. All rights reserved.
//
import UIKit
app-admin/logrotate clang
app-admin/sudo clang
app-admin/syslog-ng clang
app-arch/bzip2 clang
app-arch/cpio clang
app-arch/file-roller clang
app-arch/gzip clang
app-arch/lha clang
app-arch/libarchive clang
app-arch/lz4 clang