Skip to content

Instantly share code, notes, and snippets.

View lydell's full-sized avatar

Simon Lydell lydell

View GitHub Profile
[
[" ",1988063],
["e",1162450],
["a",888755],
["t",832684],
["i",762070],
["n",746426],
["o",728126],
["r",667531],
["s",655854],
@lydell
lydell / index.js
Last active August 29, 2015 14:08
convert-source-map-simple
var sourceMap = require("source-map")
function convert(map) {
var simpleMap = shallowCopy(map)
// Prevent the source-map module from joining sources with the sourceRoot (if
// any), so that we can find the indexes of in the `sources` property.
delete simpleMap.sourceRoot
simpleMap.mappings = {}
@lydell
lydell / tokenize.coffee
Created December 19, 2014 16:17
Simple tokenizer function (for js-tokens and css-tokens)
###
Tokenizes `string` into an array of tokens, using `regex` such as [js-tokens]
or [css-tokens].
[js-tokens]: https://github.com/lydell/js-tokens
[css-tokens]: https://github.com/lydell/css-tokens
###
tokenize = (string, regex) ->
regex.lastIndex = 0
@lydell
lydell / package.json
Created August 15, 2015 18:20
Source map Simple format proposal
{
"private": true,
"scripts": {
"test": "mocha --ui tdd test.js"
},
"dependencies": {
"convert-source-map-simple": "git://gist.github.com/857cba1b00cf8dd3c169.git",
"source-map": "~0.4.4"
},
"devDependencies": {
@lydell
lydell / bigrams-to-pairs.js
Created August 23, 2015 08:54
English bigram and letter pair frequencies from the Google Corpus Data in JSON format
// By Simon Lydell 2015.
// This file is in the public domain.
var stdin = require("get-stdin")
var tools = require("text-frequencies-analysis")
var helpers = require("text-frequencies-analysis/lib/helpers")
stdin(function(text) {
process.stdout.write(tools.jsonStringifyRow(convert(JSON.parse(text))))
})
@lydell
lydell / bigrams-all.json
Created August 23, 2015 09:31
English bigram and character pair frequencies from Michael Dickens in JSON format
[
["e ",2357988],
[" t",2060528],
["th",1810335],
[" a",1554503],
["he",1523680],
["s ",1435225],
["in",1318298],
["t ",1268890],
["d ",1188359],
<!doctype html>
<title>test</title>
<style>
a:hover::after {
content: ':hover';
}
a:focus::after {
content: ':focus';
}
a:active::after {
@lydell
lydell / convert.py
Last active August 23, 2023 12:21
“J.R.R. Tolkien's The Hobbit” (“The Hobbit” trilogy fan edit) subtitle converter
# Written by Simon Lydell 2016. This file is in the public domain.
#
# To print instructions, run `python3 convert.py`.
import datetime
import re
def parse_file(file_name):
@lydell
lydell / base64.css
Created September 4, 2016 09:47
Embedded source map support test
.base64 { font-weight: bold; }
/*# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJtYXBwaW5ncyI6IkFBQUEiLCJzb3VyY2VzIjpbInN1Y2Nlc3MuY3NzIl0sIm5hbWVzIjpbXX0= */
@lydell
lydell / LessCrazy.elm
Last active September 21, 2016 09:10
Crazy elm
module Main exposing (..)
import Html exposing (Html, div, button, text)
import Html.App
import Html.Events exposing (onClick)
main : Program Never
main =
Html.App.beginnerProgram