Skip to content

Instantly share code, notes, and snippets.

View meduzen's full-sized avatar
🌍
<body> in Belgium, <head> worldwide.

Mehdi meduzen

🌍
<body> in Belgium, <head> worldwide.
View GitHub Profile
@zachleat
zachleat / critical-foft-preload.html
Last active July 26, 2017 18:12
Compare Critical FOFT against Critical FOFT with preload
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Critical FOFT with preload</title>
<link rel="preload" href="/web/css/fonts/lato/lato-zachleat-optimized.woff2" as="font" type="font/woff2" crossorigin>
<style>
@font-face {
font-family: LatoSubset;
########################### LAST UPDATE: 2018-10-03 ###########################
# #
# Source: https://gist.github.com/meduzen/030aa314afeb4a9806c4c59994ed7ed4 #
# #
# Main idea: target every browser with at least 0.3% market shares, plus #
# IE 11, Safari 9 and Edge 15, no matter their shares evolution. #
# #
# Browserslist documentation: https://github.com/ai/browserslist#queries #
# #
###############################################################################
@karlwestin
karlwestin / gist:3163157
Created July 23, 2012 11:24
throttling a window.scroll handler for better performance
// underscore's throttle-metod
var throttle = function(func, wait) {
var context, args, timeout, throttling, more, result;
var whenDone = _.debounce(function(){ more = throttling = false; }, wait);
return function() {
context = this; args = arguments;
var later = function() {
timeout = null;
if (more) func.apply(context, args);
@dgoguerra
dgoguerra / Vagrantfile.diff
Last active January 8, 2019 22:20
Homestead v2.0.0 configuration
diff --git a/Vagrantfile b/Vagrantfile
index 12b8f52..7b77ab2 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -17,6 +17,11 @@ require File.expand_path(File.dirname(__FILE__) + '/scripts/homestead.rb')
Vagrant.require_version '>= 1.9.0'
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
+
+ config.vm.provider 'virtualbox' do |vb|

Parens And Performance

Years ago, some smart folks that worked on JS engines realized that not all JS that's loaded into a page/app initially is needed right away. They implemented JIT to optimize this situation.

JIT means Just-In-Time, which means essentially that the engine can defer processing (parsing, compiling) certain parts of a JS program until a later time, for example when the function in question is actually needed. This deferral means the engine is freer to spend the important cycles right now on the code that's going to run right now. This is a really good thing for JS performance.

Some time later, some JS engine devs realized that they needed to get some hints from the code as to which functions would run right away, and which ones wouldn't. In technical speak, these hints are called heuristics.

So they realized that one very common pattern for knowing that a function was going to run right away is if the first character before the function keyword was a (, because that usually m

Atmosphere Fatal Report (v1.0):
Result: 0x1BF802 (2002-3580)
Title ID: 010000000000000c
Process Name: bcat
Firmware: 9.0.0 (Atmosphere 0.9.4-master-c62c4846)
General Purpose Registers:
Start Address: 0000003551e00000
Stack Trace:
ReturnAddress[00]: 0000003551f79edc
@meduzen
meduzen / README.md
Last active August 31, 2020 11:17
Replace Nginx server name on Forge + Digital Ocean

Replace Nginx server name

This works on a Digital Ocean’s server managed by Laravel Forge. What this does:

  1. Power off the server by connecting through ssh and running sudo poweroff.
  2. Take a snapshot of the server in the Digital Ocean panel. If things goes wrong, it’ll help server restauration.
  3. Warning step:
@MaybeThisIsRu
MaybeThisIsRu / category.svelte
Last active September 13, 2020 08:17
a11y while adding categories
<!--
Problem statement:
I'm writing an interactive category field.
I have three major things on play here:
1. A text input that is described by a paragraph above it
2. A datalist of categories received from the server
3. A list of checked checkboxes for each new category
@wanderview
wanderview / sw.js
Last active January 29, 2021 08:16
Example "no-op" navigation preload service worker
self.addEventListener('fetch', evt => {
// Fallback for subresource requests or in browsers that do not
// support navigation preload.
if (evt.request.mode !== "navigate" || !evt.preloadResponse)
return;
evt.respondWith(async _ => {
// Try to get the navigation preload response.
let r = await evt.preloadResponse;
@terapyon
terapyon / aes_decrypt.py
Created November 29, 2017 02:08
AES PHP to Python
import binascii
from Crypto.Cipher import AES
data = "abcdefghijklmnopqrstuvwxyz"
key = "pqrstuvwxyz$abcdefghijAB"
iv = "DEFGHTABCIESPQXO"
encrypted = "2324ab5ec7a901247bf01b08bd1956688843dad5a8e15106ca3a5b9258918527"
cipher = AES.new(key, AES.MODE_CBC, iv)