Skip to content

Instantly share code, notes, and snippets.

@johan
johan / README.md
Last active April 18, 2025 15:35
A micro-library (4k minified) for DRY:ing up the boring boilerplate of user scripts.

The fun part of user scripting is deciding what happens. The boring part is scavenging the DOM for bits of templated data, or elements you want to mod.

Have on.js do it for you!

@guipn
guipn / then.js
Created November 4, 2012 05:44
Function.prototype.then
function square(x) {
return x*x;
}
function add3(x) {
return x + 3;
}
function sub10(x) {
return x - 10;
@jareware
jareware / SCSS.md
Last active April 11, 2025 18:25
Advanced SCSS, or, 16 cool things you may not have known your stylesheets could do

⇐ back to the gist-blog at jrw.fi

Advanced SCSS

Or, 16 cool things you may not have known your stylesheets could do. I'd rather have kept it to a nice round number like 10, but they just kept coming. Sorry.

I've been using SCSS/SASS for most of my styling work since 2009, and I'm a huge fan of Compass (by the great @chriseppstein). It really helped many of us through the darkest cross-browser crap. Even though browsers are increasingly playing nice with CSS, another problem has become very topical: managing the complexity in stylesheets as our in-browser apps get larger and larger. SCSS is an indispensable tool for dealing with this.

This isn't an introduction to the language by a long shot; many things probably won't make sense unless you have some SCSS under your belt already. That said, if you're not yet comfy with the basics, check out the aweso

@ForbesLindesay
ForbesLindesay / Real World Specification.md
Last active January 4, 2022 22:41
Functional Programming from the perspective of a JavaScript Programmer.

Real World Specification

(aka "Algebraic JavaScript Specification")

This project specifies the behavior of a number of methods that may optionally be added to any object. The motivation behind this is to encourage greater code reuse. You can create functions that just rely on objects having implementations of the methods below, and in doing so you can make them work with a wide variety of different, but related data structures.

Definitions

For the purposes of this, spec, an "entity" is an object that has an [[equivalent]] operation (see bellow) and may implement some or all of the other methods.

@ssylvan
ssylvan / rh_hash_table.hpp
Last active February 23, 2025 03:20
Quick'n'dirty Robin Hood hash table implementation. Note, I have implemented this algorithm before, with tons of tests etc. But *this* code was written specifically for the blog post at http://sebastiansylvan.com/post/robin-hood-hashing-should-be-your-default-hash-table-implementation/, it has not been extensively tested so there may be bugs (an…
#define USE_ROBIN_HOOD_HASH 1
#define USE_SEPARATE_HASH_ARRAY 1
template<class Key, class Value>
class hash_table
{
static const int INITIAL_SIZE = 256;
static const int LOAD_FACTOR_PERCENT = 90;
struct elem
@willurd
willurd / web-servers.md
Last active April 20, 2025 00:42
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@timyates
timyates / lenstest.groovy
Last active January 3, 2016 05:29
Functional Lenses and Groovy
import groovy.transform.*
// Immutable test object
def tim = new Person( 'tim', new Address( 'Woo', 123 ) )
// Lens for setting address for a person
Lens personAddress = new Lens( { p -> p.address }, { p, a -> new Person( p.name, a ) } )
// And one for setting zipcode for an address
Lens addressZipcode = new Lens( { a -> a.zip }, { a, z -> new Address( a.street, z ) } )
@timyates
timyates / _README.md
Created March 24, 2014 14:16
Simple recommendation system written in Groovy based on Jaccard index.
macro protocol {
case { _ $name:ident { $fn:protocol_fn ... } } => {
// Probably not a good idea to rely on `__fresh`. Sweet.js should provide
// some sort of blessed gensym capability.
letstx $id = [makeValue(__fresh(), #{ here })];
return #{
function $name(proto, impl) {
if (!impl) {
impl = proto;
proto = {};
@staltz
staltz / introrx.md
Last active April 21, 2025 04:15
The introduction to Reactive Programming you've been missing