Skip to content

Instantly share code, notes, and snippets.

View franky47's full-sized avatar

François Best franky47

View GitHub Profile
@franky47
franky47 / 00-header
Last active July 1, 2016 07:49
RasPi 3 Dynamic MOTD à la Ubuntu
View 00-header
#!/bin/bash
#
# 00-header - create the header of the MOTD
# Copyright (c) 2013 Nick Charlton
# Copyright (c) 2009-2010 Canonical Ltd.
#
# Authors: Francois Best <francois.best@fortyseveneffects.com>
# Nick Charlton <hello@nickcharlton.net>
# Dustin Kirkland <kirkland@canonical.com>
#
@franky47
franky47 / noteBuffer.cpp
Last active October 29, 2016 06:38
Snippet for Neil
View noteBuffer.cpp
#include <iostream>
#include <inttypes.h>
#include <cstring>
#define _STRINGIFY(LitteralString) #LitteralString
#define STRINGIFY(LitteralString) _STRINGIFY(LitteralString)
#define ASSERT(expr) \
{ \
if (!(expr)) \
{ \
@franky47
franky47 / robothash-env.sh
Created September 20, 2017 04:54
Get a robotic avatar of your environment variables setup
View robothash-env.sh
#!/usr/bin/env bash
# This simple line lists your environment variables,
# hashes them into a SHA-1 and uses that to query a "unique"
# robotic avatar from robohash.org.
#
# This lets you see quickly if something is out of place in
# a server configuration, as any slight change of the config
# will result in a totally different image, which is easier
# to catch at a glimpse than remembering checksums.
@franky47
franky47 / front-end-url-farm.md
Last active December 26, 2017 13:17
Front-End URL Farm
View front-end-url-farm.md
View keybase.md

Keybase proof

I hereby claim:

  • I am franky47 on github.
  • I am franky47 (https://keybase.io/franky47) on keybase.
  • I have a public key whose fingerprint is 4A13 03D1 C816 DF95 5713 661E ED1B 3C13 7048 076B

To claim this, I am signing this object:

@franky47
franky47 / hosts
Last active December 7, 2018 08:05
Block undesired web services from even resolving their DNS
View hosts
# Block Facebook IPv4
0.0.0.0 www.facebook.com
0.0.0.0 facebook.com
0.0.0.0 login.facebook.com
0.0.0.0 www.login.facebook.com
0.0.0.0 fbcdn.net
0.0.0.0 www.fbcdn.net
0.0.0.0 fbcdn.com
0.0.0.0 www.fbcdn.com
0.0.0.0 static.ak.fbcdn.net
@franky47
franky47 / list-of-lists.md
Created January 11, 2019 08:18
List of lists
View list-of-lists.md
@franky47
franky47 / .zprofile
Created February 3, 2019 12:51
System status MOTD for Raspberry Pi (with ZSH)
View .zprofile
# Inspiration: https://www.raspberrypi.org/forums/viewtopic.php?t=23440
let upSeconds="$(/usr/bin/cut -d. -f1 /proc/uptime)"
let secs=$((${upSeconds}%60))
let mins=$((${upSeconds}/60%60))
let hours=$((${upSeconds}/3600%24))
let days=$((${upSeconds}/86400))
UPTIME=`printf "%d days, %dh %dm %ds" "$days" "$hours" "$mins" "$secs"`
# get the load averages
View upperoi.md

upperoi

Unsplash practical progressively enhanced responsive optimised images

Unsplash has the best free pictures out there.

However, their delivery is painful if you want to follow all the best practices:

  • Optimised images, to avoid sending useless bytes over the wire
  • Responsive to deliver the right image for the right screen size
@franky47
franky47 / useDerivedState.ts
Last active May 21, 2019 06:20
React useDerivedState hook
View useDerivedState.ts
import React from 'react'
const useDerivedState = <T>(derive: () => T, deps: any[]): T => {
const [value, setValue] = React.useState<T>(derive)
React.useEffect(() => {
setValue(derive())
}, deps)
return value
}