Skip to content

Instantly share code, notes, and snippets.

View alekseykulikov's full-sized avatar
🚄
Making treo.sh

Aleksey Kulikov alekseykulikov

🚄
Making treo.sh
View GitHub Profile
// Translates a Google diff-match-patch diff to an array of ottypes textv1 ops
// Pretty straight-forward!
module.exports = function (diff) {
var ops = [];
for(var i = 0; i < diff.length; i++) {
var diffComp = diff[i];
switch(diffComp[0]) {
case -1: // DELETION
ops.push({d:diffComp[1].length});
break;
@kof
kof / external-motivators.md
Last active July 3, 2017 17:43
External things that keep me motivated at work
  1. Open Source being officially part of the job, not just an "after job fun" instead of spending time with the family.
  2. Colleagues one can learn from, not those one needs to clean up after.
  3. Money matters. Only a stupid person can think that money doesn't matter in our capitalistic society. This also includes social security, medical ensurance and any other expenses. I am not mercantile, no.
  4. Soft deadlines. Having time to do things right.
  5. No pressure in being at time every day in the office. We all got our issues.
  6. Workout during working hours. Possibility to go quickly for a run or to the gym.
  7. Office is optional. I prefer to work from any location I want. Sometimes being in the office is nice though.
  8. Good sitting conditions: good chairs, gym ball, stay desk, sofas.
  9. Relaxation room or nap room.

Setup

Static files and 404 pages.

{{ mkdir "build" }}
{{ copy "static/*" "build" }}
{{ render "404" | write "build/404.html" }}
@matthewmueller
matthewmueller / index.html
Last active January 11, 2018 09:41
HTML Starter Template for rock-solid Web Apps
<!--
What?
HTML Starter Template for rock-solid Web Apps
Where?
Get the latest template here: https://gist.github.com/matthewmueller/cb33e2c5f6834511cd45f17b59271052
@rweald
rweald / simple-linear-regression.rb
Created August 29, 2012 19:13
Simple Linear Regression in Ruby
class SimpleLinearRegression
def initialize(xs, ys)
@xs, @ys = xs, ys
if @xs.length != @ys.length
raise "Unbalanced data. xs need to be same length as ys"
end
end
def y_intercept
mean(@ys) - (slope * mean(@xs))

Avoid live "then()-ables"

Like a Promise, await will call any .then() function on its operand. This can be used to create values that change every time they are awaited.

let lastId = 1;
const id = {
  then(fn, errfn) {
    fn(lastId++);
 }
@pmeenan
pmeenan / gist:7465158c6439db066a53
Created May 20, 2015 12:45
RUM Speed Index Custom Metric
[RUMSpeedIndex]
var RUMSpeedIndex = function(win) {
win = win || window;
var doc = win.document;
/****************************************************************************
Support Routines
****************************************************************************/
// Get the rect for the visible portion of the provided DOM element
var GetElementViewportRect = function(el) {
@adamjspooner
adamjspooner / _config.yml
Created May 24, 2011 06:08
A Jekyll plugin to convert .styl to .css.
stylus:
compress: true
path: ./path/to/styl
@mafintosh
mafintosh / bitcoin-for-laypeople.md
Last active April 1, 2020 12:46
Blog post about how Bitcoin works in a way non computer people can understand it

Bitcoin for laypeople

(Chinese version available here, courtesy of @jiangplus

(This is an English translation of my Danish blog post, Bitcoin for voksne)

Bitcoin is a digital currency that has no central authority. It's a currency where you do not have to rely on anyone to know it's worth it. As a concept, it's similar to gold. Gold has a value in itself, as opposed to, say a $100 note that only has value if the U.S. government says it has value. Similarly, the idea of ​​Bitcoins is that they have value by themselves.

Let's try to understand how Bitcoin works.

@paulirish
paulirish / eqt.js
Last active April 26, 2020 01:14
Expected Queueing Time metric
// Expected Queueing Time
// https://docs.google.com/document/d/1Vgu7-R84Ym3lbfTRi98vpdspRr1UwORB4UV-p9K1FF0/edit
// Initial impl by Nicolás Peña (npm), Tim Dresser (tdresser)
// Usage:
// var eqt = EQT.begin();
// // ...
// const {expectedQueueingTime} = EQT.end();
class EQT {
constructor() {