Skip to content

Instantly share code, notes, and snippets.

View jeromegn's full-sized avatar
🏠
Rusting it up

Jerome Gravel-Niquet jeromegn

🏠
Rusting it up
View GitHub Profile
@timruffles
timruffles / svtail.sh
Created July 24, 2014 07:45
tails a (runit) service by name, or tail all services on a machine
# tail a service by name
#
# svtail cad-server 50
#
# becomes
#
# tail -fn 50 /var/log/cad-server/current
#
svtail() {
local n=${2:-50}
@wheresalice
wheresalice / dotcloud_build.yml
Created April 4, 2011 14:34
Tech demo of Faye/NodeJS/Jade pubsub
www:
requirements:
- faye
- jade
@tobz
tobz / context.rs
Last active December 4, 2019 20:18
use std::sync::Arc;
use futures_intrusive::sync::ManualResetEvent;
use crate::wg::{WaitGroup, WaitGroupHandle};
pub struct Context {
start: WaitGroup,
done: WaitGroup,
close: Arc<ManualResetEvent>,
}
@banks
banks / ecdh.go
Last active April 23, 2020 02:12
// ecdh implements a simple way to perform Diffie-Hellman Key Exchange using
// Curve25519 on the command line.
//
// NOTE: this is a toy for fun. Don't use it.
//
// See https://godoc.org/golang.org/x/crypto/curve25519 and
// https://cr.yp.to/ecdh.html for more info.
//
// The final shared secret given is the raw shared secret bytes from DH and is
// not typically suitable for direct use as an encryption key as it can leak

In order to use asset pipeline available for static error pages (like 404.html), a few steps are required

  • Move static pages from /public into /app/assets

    (eg: public/422.html → app/assets/html/422.html.erb)

  • Add html directory to the asset pipeline

  • Update exceptions middleware to understand assets with digests

@rahul286
rahul286 / nginx-pagespeed.conf
Last active January 10, 2023 18:28
nginx + pagespeed downstream caching example
#source: http://www.jefftk.com/2014-01-03--nginx.conf
# for debugging with valgrind
#daemon off;
#master_process off;
#user nobody;
worker_processes 1;
worker_rlimit_core 500M;
@summerwind
summerwind / xdp_load_balancer.c
Last active January 30, 2023 15:04
XDP based load balancer with L3DSR support
#define KBUILD_MODNAME "load_balancer"
#include <uapi/linux/bpf.h>
#include <linux/in.h>
#include <linux/if_ether.h>
#include <linux/if_packet.h>
#include <linux/if_vlan.h>
#include <linux/ip.h>
#include <linux/ipv6.h>
BPF_HASH(counter, uint32_t, long);
@inscapist
inscapist / flake-direnv.md
Last active December 13, 2023 00:05
Nix Flakes and Direnv on Mac OSX (Catalina)

Development environment with Nix Flakes and Direnv

This document is targeted at those who seek to build reproducible dev environment across machines, OS, and time.

It maybe easier for remote teams to work together and not spending hours each person setting up asdf/pyenv/rbenv, LSP servers, linters, runtime/libs. Nix is probably the closest thing to Docker in terms of development environment.

Flake is used here because it provides hermetic build, with absolutely no reliance on system environment (be it Arch/Catalina/Mojave). Also it freezes dependencies in flake.lock so builds are reproducible.

This gist provides the setup to develop Java/Clojure/Python applications on Nix. But it can be easily adapted to ruby, nodejs, haskell.

#!/bin/bash
###
### my-script — does one thing well
###
### Usage:
### my-script <input> <output>
###
### Options:
### <input> Input file to read.
### <output> Output file to write. Use '-' for stdout.
@jed
jed / how-to-set-up-stress-free-ssl-on-os-x.md
Last active February 25, 2024 17:35
How to set up stress-free SSL on an OS X development machine

How to set up stress-free SSL on an OS X development machine

One of the best ways to reduce complexity (read: stress) in web development is to minimize the differences between your development and production environments. After being frustrated by attempts to unify the approach to SSL on my local machine and in production, I searched for a workflow that would make the protocol invisible to me between all environments.

Most workflows make the following compromises:

  • Use HTTPS in production but HTTP locally. This is annoying because it makes the environments inconsistent, and the protocol choices leak up into the stack. For example, your web application needs to understand the underlying protocol when using the secure flag for cookies. If you don't get this right, your HTTP development server won't be able to read the cookies it writes, or worse, your HTTPS production server could pass sensitive cookies over an insecure connection.

  • Use production SSL certificates locally. This is annoying