Skip to content

Instantly share code, notes, and snippets.

View gi11es's full-sized avatar
🤠
mov ax, 13h

Gilles Dubuc gi11es

🤠
mov ax, 13h
  • France
View GitHub Profile
@gi11es
gi11es / 3SUM.py
Last active March 9, 2022 20:21
My solution to the 3SUM https://en.wikipedia.org/wiki/3SUM puzzle on https://leetcode.com/problems/3sum/ which runs faster than 99.91% of previous submissions https://leetcode.com/submissions/detail/656602954/ Too good to be correct?
class Solution:
def threeSum(self, nums: List[int]) -> List[List[int]]:
result = []
negativeDict = {} # Hash map. keys are the negative values found in the list and values are how many times they occur
positiveDict = {} # Same for positive values
zeroCount = 0 # How many zeros are in the list
# Go through the list once to populate the hash maps described above and count zeros - complexity: O(n)
length = len(nums)
for i in range(length):
@gi11es
gi11es / perf-calendar-2018-avif.md
Last active December 19, 2018 15:38
Is AVIF the future of images on the web?

Kornel Lesiński, of ImageOptim fame, did an excellent talk at performance.now() about image optimisation. In it, he suggested that a single-frame AV1 video could already outperform a JPG or WebP image in terms of compression ratio. With the single-frame AV1 being half the size of the JPG. I decided to verify that claim.

Compression performance

First, I took a reference image from Wikimedia Commons and generated a "perfect thumbnail" for it, as a PNG. PNG being losslesss, this gives us the reference to aim for. If image compression was lossless, it would end up being 100% identical to that PNG. But by definition, with JPG, WebP and AV1, we're talking about lossy compression. The main question when you use lossy compression is: how much visual quality do you lose?

The images embedded in the article are lossless PNGs generated from the mentione

@gi11es
gi11es / cpubenchmark.js
Created December 5, 2018 20:48
CPU benchmark
function cpuBenchmark() {
var blob, worker, work;
function onMessage() {
var i,
startTime,
amount = 100000000;
// IE11 doesn't have window.performance exposed inside workers
if ( !self.performance ) {
@gi11es
gi11es / perf-calendar-2019-post.md
Last active November 30, 2018 09:43
Magic numbers

Guidelines like RAIL are popular in the web performance community. They often define time limits that must be respected, like 100ms for what feels instantaneous, or 1000ms for the limit of acceptable response time.

Prominent people in the performance community keep telling us that there's a lot of science behind those numbers.

I've always been skeptical of that claim, and earlier this year I set out to find out if there's any merit to those numbers by doing an extensive literature review of web performance perception academic research. Here are some of the findings from that project.

Following the citation trail

If you follow paper citations, some classic papers keep showing up as references. And in the world of web performance, two

@gi11es
gi11es / gist:5b55347a9888596fda74
Created January 19, 2016 12:53
libvmod-xkey build failure on 4.0
vagrant@mediawiki-vagrant:/tmp/libvmod-xkey$ make
make all-recursive
make[1]: Entering directory `/tmp/libvmod-xkey'
Making all in src
make[2]: Entering directory `/tmp/libvmod-xkey/src'
/usr/share/varnish/vmodtool.py ../src/vmod_xkey.vcc
make all-am
make[3]: Entering directory `/tmp/libvmod-xkey/src'
/bin/bash ../libtool --tag=CC --mode=compile gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I.. -I/usr/include/varnish -Wall -Werror -g -O2 -MT vcc_if.lo -MD -MP -MF .deps/vcc_if.Tpo -c -o vcc_if.lo vcc_if.c
libtool: compile: gcc -std=gnu99 -DHAVE_CONFIG_H -I. -I.. -I/usr/include/varnish -Wall -Werror -g -O2 -MT vcc_if.lo -MD -MP -MF .deps/vcc_if.Tpo -c vcc_if.c -fPIC -DPIC -o .libs/vcc_if.o