Skip to content

Instantly share code, notes, and snippets.

View kristerkari's full-sized avatar

Krister Kari kristerkari

View GitHub Profile
@staltz
staltz / introrx.md
Last active July 19, 2025 08:08
The introduction to Reactive Programming you've been missing
var randomNumbers = [42, 12, 88, 62, 63, 56, 1, 77, 88, 97, 97, 20, 45, 91, 62, 2, 15, 31, 59, 5]
func partition(v: Int[], left: Int, right: Int) -> Int {
var i = left
for j in (left + 1)..(right + 1) {
if v[j] < v[left] {
i += 1
(v[i], v[j]) = (v[j], v[i])
}
}
console.highlight = function(text, sample) {
var escapedSample = sample.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
var reSample = new RegExp(escapedSample, 'g');
var args = [''];
var highlightedText = text.replace(reSample, function(match) {
args.push('background-color: #ffc', 'background-color: none');
return '%c' + match + '%c';
});
args[0] = highlightedText;
console.log.apply(console, args);
@sergejmueller
sergejmueller / ttf2woff2.md
Last active March 9, 2024 13:37
WOFF 2.0 – Learn more about the next generation Web Font Format and convert TTF to WOFF2
@JamieMason
JamieMason / get-new-execution-context.md
Last active May 9, 2019 15:19
Create a new JavaScript execution context, to safely extend hosts/natives for example.

Create a new JavaScript execution context

Source

const getNewExecutionContext = markup =>
  new Promise(resolve => {
    const iframe = document.createElement('iframe');
    iframe.style.display = 'none';
 iframe.setAttribute('src', 'about:blank');
/*
* Copyright (C) 2014 Chris Banes
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@domenic
domenic / .bashrc
Last active September 1, 2015 17:50
.bashrc with GitHub PR function
pr () {
git fetch origin refs/pull/$1/head:refs/remotes/origin/pr/$1 --force
git checkout -b pr/$1 origin/pr/$1
git rebase master
git checkout master
git merge pr/$1 --ff-only
}
@getify
getify / gist:10034276
Created April 7, 2014 19:19
bug with for-of iteration of traceur/es6fiddle?
var obj = {
_step: 0
};
obj[Symbol.iterator] = function() {
return {
next: function() {
return { value: ++obj._step, done: (obj._step === 4) };
}
};
@otobrglez
otobrglez / jaccard_recommendation.rb
Last active April 2, 2024 17:51
Simple recommendation system written in Ruby based on Jaccard index.
# Simple Recommendation Engine in Ruby
# Visit: http://otobrglez.opalab.com
# Author: Oto Brglez <[email protected]>
class Book < Struct.new(:title)
def words
@words ||= self.title.gsub(/[a-zA-Z]{3,}/).map(&:downcase).uniq.sort
end
// === Identifier rewriting for the ES6 module transpiler ===
// Proposal for minifier-friendly ES6 module transpiler output.
// This is for cases where we don't require any existing module
// format (AMD, CommonJS) and just want to emit a blackbox IIFE
// that uses modules internally. Those cases are Ember's normal
// global distribution (ember.min.js), as well as ES5 generated
// by the upcoming ember-cli ES6 stack.
// Do you all think this could work?