Skip to content

Instantly share code, notes, and snippets.

@sindresorhus
sindresorhus / compile-objc.sh
Last active November 25, 2023 21:13
Compile Objective-C on the command-line with clang
# -fobjc-arc: enables ARC
# -fmodules: enables modules so you can import with `@import AppKit;`
# -mmacosx-version-min=10.6: support older OS X versions, this might increase the binary size
clang main.m -fobjc-arc -fmodules -mmacosx-version-min=10.6 -o main
@rodricios
rodricios / summarize.py
Last active November 18, 2020 17:21
Flipboard's summarization algorithm, sort of
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
pip install networkx distance pattern
In Flipboard's article[1], they kindly divulge their interpretation
of the summarization technique called LexRank[2].
@rix501
rix501 / dynamic-logs.coffee
Last active December 16, 2015 23:21
Because we needed a birdlog and a jvstinlog
# Description:
# Keep a variaty of logs
#
# Dependencies:
#
# Configuration:
#
# Commands:
# hubot logs - shows all logs stored
# hubot <name>log last <number> - show last number of logs
@jakeonrails
jakeonrails / Ruby Notepad Bookmarklet
Created January 29, 2013 18:08
This bookmarklet gives you a code editor in your browser with a single click.
data:text/html, <style type="text/css">#e{position:absolute;top:0;right:0;bottom:0;left:0;}</style><div id="e"></div><script src="http://d1n0x3qji82z53.cloudfront.net/src-min-noconflict/ace.js" type="text/javascript" charset="utf-8"></script><script>var e=ace.edit("e");e.setTheme("ace/theme/monokai");e.getSession().setMode("ace/mode/ruby");</script>
@font-face {
font-family: 'EntypoRegular';
src: url('font/entypo.eot');
src: url('font/entypo.eot?#iefix') format('embedded-opentype'),
url('font/entypo.woff') format('woff'),
url('font/entypo.ttf') format('truetype'),
url('font/entypo.svg#EntypoRegular') format('svg');
font-weight: normal;
font-style: normal;
}
@anantn
anantn / firebase_player_assignment.js
Last active January 14, 2023 01:51
Firebase: Assigning players in a multiplayer game. This snippet assigns you a spot in a game if the game isn't full yet.
function go() {
var userId = prompt('Username?', 'Guest');
// Consider adding '/<unique id>' if you have multiple games.
var gameRef = new Firebase(GAME_LOCATION);
assignPlayerNumberAndPlayGame(userId, gameRef);
};
// The maximum number of players. If there are already
// NUM_PLAYERS assigned, users won't be able to join the game.
var NUM_PLAYERS = 4;
@tonyg
tonyg / oomachine.rkt
Created October 10, 2012 01:51
OO-machine: A heady mixture of TNG-R4, Jay&Kesner's Pure Pattern Calculus, and Cardelli&Abadi's ς calculus. Dec 2010 - Feb 2011.
#lang racket
;; OO-machine
;; A heady mixture of TNG-R4,
;; Jay&Kesner's Pure Pattern Calculus, and
;; Cardelli&Abadi's ς calculus.
(require redex)
(require rackunit)
(define-language oc
@dvanhorn
dvanhorn / memo-dyn.txt
Created August 24, 2012 17:53
Memoization vs dynamic programming
Memoization is fundamentally a top-down computation and dynamic
programming is fundamentally bottom-up. In memoization, we observe
that a computational *tree* can actually be represented as a
computational *DAG* (the single most underrated data structure in
computer science); we then use a black-box to turn the tree into a
DAG. But it allows the top-down description of the problem to remain
unchanged.
In dynamic programming, we make the same observation, but construct
the DAG from the bottom-up. That means we have to rewrite the
(defn distincto
"s is a sequence of sequence of vars.
ensure that vars in each particular sequence
take on distinct values."
[s]
(if (seq s)
(let [vars (first s)]
(all
(distinctfd vars)
(distincto (next s))))