Skip to content

Instantly share code, notes, and snippets.

@jaredpalmer
jaredpalmer / ReducerComponent.js
Last active July 27, 2019 15:59
React.ReducerComponent
import React from 'react';
class ReducerComponent extends React.Component {
constructor(props) {
super(props);
}
reducer = (state, action) => state;
dispatch = action => this.setState(state => this.reducer(state, action));
@liamzebedee
liamzebedee / BackgroundTask.h
Last active February 18, 2024 09:27
Attempts at implementing background tasks in React Native iOS
//
// BackgroundTask.h
// tomtrack
//
// Created by Liam Edwards-Playne on 13/02/2016.
//
#import "RCTBridgeModule.h"
@interface BackgroundTask : NSObject <RCTBridgeModule>
@bkaradzic
bkaradzic / orthodoxc++.md
Last active April 23, 2024 13:59
Orthodox C++

Orthodox C++

What is Orthodox C++?

Orthodox C++ (sometimes referred as C+) is minimal subset of C++ that improves C, but avoids all unnecessary things from so called Modern C++. It's exactly opposite of what Modern C++ suppose to be.

Why not Modern C++?

@kastermester
kastermester / immutable.js
Last active August 29, 2015 14:25
Flowtype definition for immutable.js
declare module "immutable" {
declare class Iterable<K, V> {
static isIterable(maybeIterable: any): boolean;
static isKeyed(maybeKeyed: any): boolean;
static isIndexed(maybeIndexed: any): boolean;
static isAssociative(maybeAssociative: any): boolean;
static isOrdered(maybeOrdered: any): boolean;
toArray(): Array<V>;
toIndexedSeq(): IndexedSeq<V>;
@ailispaw
ailispaw / boot2docker-xhyve.md
Last active June 15, 2016 20:57
Manage boot2docker-xhyve from the menu bar
@gr0uch
gr0uch / errors.js
Last active August 29, 2015 14:14
Custom typed errors in ES6
// Hello. There is now a module for this.
// https://github.com/0x8890/error-class
// $ npm install error-class
const hasCaptureStackTrace = 'captureStackTrace' in Error
// Internal function to set up an error.
function setup (message) {
const { constructor, constructor: { name } } = this
@shiva
shiva / FindNim.cmake
Created October 21, 2014 12:47
cmake module for running nimrod compiler
include(CMakeParseArguments)
find_program(NIM_EXECUTABLE nimrod PATHS ENV PATH)
mark_as_advanced(NIM_EXECUTABLE)
# Determine the valac version
if(NIM_EXECUTABLE)
execute_process(COMMAND ${NIM_EXECUTABLE} "--version"
OUTPUT_VARIABLE NIM_VERSION
@denji
denji / unbound-osx-homebrew.md
Last active November 27, 2022 08:33
Install unbound DNS(SEC) resolver on OS X, on the basis of https://www.spatof.org/blog/unbound-dns-resolver-on-osx.html
To install unbound you can use homebrew
$ brew install unbound ldns
Now we can edit the configuration file of unbound which by default is located in /usr/local/etc/unbound/unbound.conf:
@mseeley
mseeley / webworker-preloader.html
Created March 3, 2014 09:29
WebWorker Image preloader proof of concept (Tested in Mobile Safari 6.0/IOS 6.1.3 and Chrome 33)
<!DOCTYPE html>
<html>
<head>
<title>WebWorker image preloading</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no" />
</head>
<body>
<div id="output"></div>
<script id="imgloader" type="javascript/worker">
// Not race proof or robust. Proof of concept.
@mtdowling
mtdowling / gist:4516558
Last active March 7, 2018 00:56
Fibonacci in PHP using anonymous functions and memoization
<?php
$fibMemo = call_user_func(function () {
$memo = array(0 => 0, 1 => 1);
$fib = function ($n) use (&$memo, &$fib) {
if (!isset($memo[$n])) {
$memo[$n] = $fib($n - 1) + $fib($n - 2);
}
return $memo[$n];
};