Skip to content

Instantly share code, notes, and snippets.

View berkus's full-sized avatar
🪢
~consume.enhance.replicate~

Berkus Decker berkus

🪢
~consume.enhance.replicate~
View GitHub Profile
@berkus
berkus / gist:36dc64f8f3432de1d95d
Last active August 29, 2015 14:02
constexpr alloc
#include <iostream>
class Boo
{
public:
static constexpr char const* string_of_kind[5] = {"FREE", "EXEC", "READ", "WRITE", "INITRD"};
};
constexpr char const* Boo::string_of_kind[];
protocol ISubscriber {
typealias Element
func sendNext(e: Element)
func sendError(e: NSError)
func sendCompleted()
}
/// Wraps RACSubscriber
class Subscriber<T: AnyObject> : ISubscriber {
@berkus
berkus / memoize.swift
Last active April 2, 2017 19:19
A "fast" memoization generic in Swift
Promised speed:
0.1s https://dl.dropboxusercontent.com/s/bpgountdjrbs17n/2014-06-09%20at%2019.00.png
Actual speed:
575s https://dl.dropboxusercontent.com/s/2kbn5p1g4t03fvl/2014-06-09%20at%2019.00%20%281%29.png
With optimizations:
@berkus
berkus / boost.sh
Last active August 29, 2015 14:07 — forked from rsobik/boost.sh
#===============================================================================
# Filename: boost.sh
# Author: Pete Goodliffe
# Copyright: (c) Copyright 2009 Pete Goodliffe
# Licence: Please feel free to use this, with attribution
# Modified version
#===============================================================================
#
# Builds a Boost framework for the iPhone.
# Creates a set of universal libraries that can be used on an iPhone and in the
@berkus
berkus / introrx.md
Last active August 29, 2015 14:08 — forked from staltz/introrx.md

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called (Functional) Reactive Programming (FRP).

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

// * a variable sized field, where size is controlled by external bitfield with certain mapping
// - where this bitfield is
// - offset of bits
// - mask of bits
// - mapping function (bits to type)
#include <array>
#include <iostream>
#include <boost/asio/buffer.hpp>
#include <boost/mpl/range_c.hpp>
#include <boost/mpl/for_each.hpp>
@berkus
berkus / gist:bd3d38587676aa707816
Last active August 29, 2015 14:16
Pepyatka OSX dev setup

Prereqs

  • OSX 10.10.2
  • homebrew
  • development branch of pepyatka-server/pepyatka-html

Install nvm

brew install nvm

@berkus
berkus / dig.lua
Last active August 29, 2015 14:22
Minecraft turtle machinery
-- To load to turtle: pastebin get aKard6z3 dig
-- Simple digger --
-- When called, will dig down to bedrock, move one forward and dig back up to original location.
-- Call "dig <N>" - N times dig down and back up.
-- Can refuel from any slot.
-- Will group resources into same slot.
-- Will drop junk items if no free space.
--
@berkus
berkus / Jade.php
Last active December 3, 2015 23:31
How to use Talesoft/tale-jade with FlightPHP as a render engine
<?php
Flight::register('view', 'Tale\Jade\Renderer', [[
'paths' => [__DIR__.'/templates/'], // Where you keep your jade templates
'pretty' => true, // For debug only
'adapterOptions' => [
'path' => __DIR__.'/pages-cache/', // Where to cache generated files, writable by webserver
'lifeTime' => 3600
]
]], function($jade) {
// additional init code here, if needed
@berkus
berkus / bugreports.md
Last active December 20, 2016 10:55
Reporting Twilio Android SDK bugs
  1. Enable debug log

    // Before creating a new ChatClient with ChatClient.create() add this line:
    ChatClient.setLogLevel(android.util.Log.DEBUG);
    ...
    
    ChatClient.create(....