Skip to content

Instantly share code, notes, and snippets.

View rabet's full-sized avatar

rabet

View GitHub Profile
@rabet
rabet / main.go
Last active January 26, 2024 08:49
Write text into image with Go (with font.Drawer)
// Copyright 2015 The Freetype-Go Authors. All rights reserved.
// Use of this source code is governed by your choice of either the
// FreeType License or the GNU General Public License version 2 (or
// any later version), both of which can be found in the LICENSE file.
// +build example
//
// This build tag means that "go install github.com/golang/freetype/..."
// doesn't install this example program. Use "go run main.go" to run it or "go
// install -tags=example" to install it.
@rabet
rabet / codeSplitting.js
Created March 25, 2019 20:21 — forked from mgreer/codeSplitting.js
Code splitting HOC
// @flow
import * as React from 'react';
import {asyncComponent} from 'react-async-component';
export const loaderMaker = (bgColor: string = 'transparent') => () => (
<div style={{position: 'absolute', width: '100%', height: '100%', backgroundColor: bgColor}} />
);
const MAX_RETRIES = 3;
const STARTING_BACKOFF = 500;
import React, { Component } from 'react'
import ReactDOM from 'react-dom'
import debounce from 'lodash/debounce'
class AutoSizer extends Component {
constructor() {
super()
this.getWidthAndHeight = debounce(this.getWidthAndHeight.bind(this), 200)
this.state = {
width: 0,
// Count the each letter occurance in the "text",
// the result put into the "stats" object in a form of:
// {
// a: 10,
// c: 13,
// ...
// }
//
// NOTE! count letters only,
// consider lower case and upper case letter to be the same
@rabet
rabet / introrx.md
Created November 10, 2015 23:55 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="live typing indicator">
<script src="https://cdn.firebase.com/js/client/2.3.1/firebase.js"></script>
<meta charset="utf-8">
<title>Live Typing Indicator</title>
</head>
<body>
<ul id='typers'>