Skip to content

Instantly share code, notes, and snippets.

@purcell
purcell / access-log-to-parquet.sql
Created September 4, 2023 19:23
Use DuckDB to convert a compressed web access log in Combined Log Format to Parquet
COPY (
WITH
-- Read the raw log line by line by abusing CSV parser
raw_log AS (
FROM read_csv_auto('/tmp/log/access.log-20230904.gz', header=false, delim='\0')
)
, combined_log AS (
SELECT regexp_extract(column0
, '^(\S+) (\S+) (\S+) \[(.*?)\] "([A-Z]+?) (.*?) HTTP/(.*?)" (\d+) (\d+) "(.*?)" "(.*?)"$'
, [ 'ip', 'identity', 'userid', 'timestamp', 'method'
@kepano
kepano / obsidian-web-clipper.js
Last active June 14, 2024 10:45
Obsidian Web Clipper Bookmarklet to save articles and pages from the web (for Safari, Chrome, Firefox, and mobile browsers)
javascript: Promise.all([import('https://unpkg.com/turndown@6.0.0?module'), import('https://unpkg.com/@tehshrike/readability@0.2.0'), ]).then(async ([{
default: Turndown
}, {
default: Readability
}]) => {
/* Optional vault name */
const vault = "";
/* Optional folder name such as "Clippings/" */
@maxtaco
maxtaco / bot-signup-flow.md
Last active May 5, 2023 16:47
New bot signup flow

Get a Bot Token

As your keybase user run:

$ keybase bot token create > /tmp/bot-token

You'll get back a base64 token, like: 6C37sjCBgMNf06Z6oTgixIxHJpja8G-Qp. This is your bot token that allows you to sign up bots.

@JosePedroDias
JosePedroDias / JSON_number_limits.md
Created July 20, 2019 11:58
JSON number limits

JSON number limits

So we we're using an API which returns a JSON response. One of its attributes is a numeric key. Due to historical reasons we're now being served longer number (longs) so the server, which is not based on JavaScript, started returning long integers.

I had heard about issues like this but hadn't cross against a real use case before.

So what started happening on our JavaScript clients (browser and React Native alike) is that the primitive value we get back once we get the fetch json promise resolved is an overflown number.

JavaScript engines commonly have the symbol Number.MAX_SAFE_INTEGER so one can retrieve the number above which problems start to appear (it is 9007199254740991).

@y0ngb1n
y0ngb1n / docker-registry-mirrors.md
Last active June 16, 2024 17:27
国内的 Docker Hub 镜像加速器,由国内教育机构与各大云服务商提供的镜像加速服务 | Dockerized 实践 https://github.com/y0ngb1n/dockerized
@asukakenji
asukakenji / go-stdlib-interface-selected.md
Last active June 6, 2024 08:15
Go (Golang) Standard Library Interfaces (Selected)

Go (Golang) Standard Library Interfaces (Selected)

This is not an exhaustive list of all interfaces in Go's standard library. I only list those I think are important. Interfaces defined in frequently used packages (like io, fmt) are included. Interfaces that have significant importance are also included.

All of the following information is based on go version go1.8.3 darwin/amd64.

@localshred
localshred / nice_hash_comparison_test.rb
Last active November 22, 2023 13:27
Minitest assert_equal sucks for comparing output diffs of two hashes. Using HashDiff, awesome_print, and StringIO we can get actual comparable hashes without pulling our hair out.
require "test_helper"
require "awesome_print"
require "hashdiff"
class MyClass
def self.do_stuff
{a:[{y:3}, {x:11, z:33}], b:{y:22}}
end
end
@denji
denji / http-benchmark.md
Last active May 28, 2024 15:48
HTTP(S) Benchmark Tools / Toolkit for testing/debugging HTTP(S) and restAPI (RESTful)
@jboner
jboner / latency.txt
Last active June 16, 2024 08:12
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
@fred
fred / active_admin.rb
Created May 2, 2012 08:10
extend active admin to prettier boolean values
# It extends activeadmin to show pretty boolean values
#
# config/initializers/active_admin.rb
module ActiveAdmin
module Views
class TableFor
def bool_column(attribute)
column(attribute){ |model| model[attribute] ? '✔'.html_safe : '✗'.html_safe }
end