Skip to content

Instantly share code, notes, and snippets.

@mitaki28
mitaki28 / lens.ts
Created November 5, 2016 17:51
Type-safe Lens (TypeScript 2.1)
// requires TypeScript 2.1 or higher
export abstract class Lens<T, U> {
abstract get: (obj: T) => U;
abstract set: (value: U) => (obj: T) => T;
then = <V>(lens: Lens<U, V>) => new ComposedLens(this, lens);
thenKey = <L extends keyof U>(key: L): Lens<T, U[L]> => this.then(new ObjectLens<U, L>(key));
modify = (f: (value: U) => U) => (obj: T) => this.set(f(this.get(obj)))(obj);
}
export class IdLens<T> extends Lens<T, T> {
@hatashiro
hatashiro / ps-v1-public.md
Last active June 8, 2017 12:34
perfect-scrollbar v1 design draft for public

PS v1 is still in heavy development and everything can be discussed and changed later. It's being developed in the next branch, so please take a look if interested.

API

The following code shows how PS v1 will be used. For the detailed information, some parts are tagged with a number following *. The details are described below with the indexing number.

@rauchg
rauchg / README.md
Last active January 6, 2024 07:19
require-from-twitter
@plapier
plapier / LaunchStarter.swift
Created May 23, 2015 23:45
Add Login item using Launch Services (Shared List File) in Swift
//
// toggleLaunchAtStartup.swift
// Recents
//
// Created by Phil LaPier on 5/21/15.
// Copyright (c) 2015 Philip LaPier. All rights reserved.
//
// With help from: https://github.com/RamonGilabert/Prodam/blob/master/Prodam/Prodam/LaunchStarter.swift
import Foundation
@staltz
staltz / introrx.md
Last active March 4, 2025 04:54
The introduction to Reactive Programming you've been missing
@briankung
briankung / The Project Euler Sprint Rules.md
Last active December 14, 2017 02:20
The Project Euler Sprint Rules

The Project Euler Sprint Hack Nights

Project Euler Sprint Hack Nights are beginner friendly events where you can work on your own projects or engage in a friendly competition called the Project Euler Sprint.

The Project Euler Sprint is a friendly competition involving solving Project Euler ([http://projecteuler.net][projecteuler]) problems for points. Project Euler is a series of increasingly difficult computational math problems that must be solved with code (generally speaking - we've had some impressive solutions in pen and paper as well as on an Excel spreadsheet).

Each problem is harder than the last, so each problem is worth its problem number in points. Problem #1 is easy, so it's worth 1 point, while problem #50 is much harder, but worth 50 points. You can form teams of 4 people and solutions can be in any language as long as it's coded there. More detailed rules below.

Sprint Rules

@dergachev
dergachev / GIF-Screencast-OSX.md
Last active February 18, 2025 18:20
OS X Screencast to animated GIF

OS X Screencast to animated GIF

This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.

Screencapture GIF

Instructions

To capture the video (filesize: 19MB), using the free "QuickTime Player" application:

@henrik
henrik / gist:3181718
Created July 26, 2012 12:15
Fix "unsupported new OS, trying as if it were 10.6-10.7" from reattach-to-user-namespace on Mountain Lion (probably in tmux).
# Start by checking if they fixed it upstream:
brew update
brew upgrade reattach-to-user-namespace
# If it says it's already installed, they haven't fixed it upstream. So do this:
# Edit the recipe:
brew edit reattach-to-user-namespace
@lucasfais
lucasfais / gist:1207002
Created September 9, 2011 18:46
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt