Skip to content

Instantly share code, notes, and snippets.

@gmarik
gmarik / 0_new.md
Created February 8, 2021 19:11 — forked from zaach/0_new.md
New Jison 0.3 features

Some improvements have been made for parser and lexer grammars in Jison 0.3 (demonstrated in the FlooP/BlooP example below.)

For lexers:

  • Patterns may use unquoted characters instead of strings
  • Two new options, %options flex case-insensitive
  • flex: the rule with the longest match is used, and no word boundary patterns are added
  • case-insensitive: all patterns are case insensitive
  • User code section is included in the generated module

Option 1: Command-line download extension as zip and extract

extension_id=jifpbeccnghkjeaalbbjmodiffmgedin   # change this ID
curl -L -o "$extension_id.zip" "https://clients2.google.com/service/update2/crx?response=redirect&os=mac&arch=x86-64&nacl_arch=x86-64&prod=chromecrx&prodchannel=stable&prodversion=44.0.2403.130&x=id%3D$extension_id%26uc" 
unzip -d "$extension_id-source" "$extension_id.zip"

Thx to crxviewer for the magic download URL.

@gmarik
gmarik / latency.txt
Created July 2, 2020 05:33 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@gmarik
gmarik / ca.md
Created June 23, 2020 22:06 — forked from soarez/ca.md
How to setup your own CA with OpenSSL

How to setup your own CA with OpenSSL

For educational reasons I've decided to create my own CA. Here is what I learned.

First things first

Lets get some context first.

@gmarik
gmarik / clojure-match.clj
Created June 23, 2020 15:49 — forked from ckirkendall/clojure-match.clj
Language Compare F#, Ocaml, Scala, Clojure, Ruby and Haskell - Simple AST example
(use '[clojure.core.match :only [match]])
(defn evaluate [env [sym x y]]
(match [sym]
['Number] x
['Add] (+ (evaluate env x) (evaluate env y))
['Multiply] (* (evaluate env x) (evaluate env y))
['Variable] (env x)))
(def environment {"a" 3, "b" 4, "c" 5})
package main
import (
"net/http"
"net/url"
"runtime"
"strings"
"context"
"bytes"
@gmarik
gmarik / google-apps-script.md
Last active June 23, 2020 05:56 — forked from labnol/google-apps-script.md
How to Learn Google Apps Script - The best resources for learning Google Apps Script, the glue that connects GSuite services including Gmail, Google Drive, Calendar, Maps, Analytics and more.

Learning Google Apps Script

The best place to learn more about Google Script is the official documentation available at developers.google.com. Here are other places that will help you get up to speed.

  1. MAKING A GMAIL BOT WITH APPS SCRIPT AND TYPESCRIPT
  2. Google Apps Scripts - Snippets by +Amit Agarwal
  3. Apps Script Starter - Create Google Apps Script projects locally inside VS Code.
  4. Digital Inspiration by +Amit Agarwal - Google Addons
  5. Awesome Google Scripts by +Amit Agarwal
  6. Build with Google Apps Script - Setup a local development environment for Apps Script
@gmarik
gmarik / Dockerfile
Created September 29, 2019 06:37 — forked from Irio/Dockerfile
GCP Serverless scrapers
FROM golang:1.12 as build
WORKDIR $GOPATH/src/github.com/Irio/wohnung
COPY scraper scraper
COPY main.go .
RUN go get -d -v ./...
RUN go install
FROM gcr.io/distroless/base
@gmarik
gmarik / analyze.go
Created November 12, 2015 19:26 — forked from nf/analyze.go
'spent' script to log where time is spent
package main
import (
"bufio"
"fmt"
"os"
"regexp"
"sort"
"strconv"
"strings"
package main
import (
"bufio"
"fmt"
"net"
)
type Client struct {
incoming chan string