Skip to content

Instantly share code, notes, and snippets.

View jperras's full-sized avatar
💨
what what is this where am I

Joël Perras jperras

💨
what what is this where am I
View GitHub Profile
@jperras
jperras / flake.nix
Created August 29, 2024 16:53
Simple nix flake for Rust project
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
with nixpkgs.legacyPackages.${system}; {
packages.foo = rustPlatform.buildRustPackage {
@jperras
jperras / flake.nix
Created August 29, 2024 16:03
Rust project flake template
{
# This is our input set, it contains the channels we will construct the flake from.
inputs = {
# Flake-utils allows us to easily support multiple architectures.
flake-utils.url = "github:numtide/flake-utils";
# Naersk is a zero-configuration zero-codegen solution to packaging Rust.
naersk.url = "github:nix-community/naersk";
# Nixpkgs is the main package repo for Nix, we will use it to bring in all of our
# libraries and tools.
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
@jperras
jperras / flake.nix
Created August 29, 2024 15:36
Old Rustlings flake.nix
{
description = "Small exercises to get you used to reading and writing Rust code";
inputs = {
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
@jperras
jperras / .vimrc
Last active September 10, 2020 15:12
Useful vim plugins
scrooloose/nerdcommenter
jreybert/vimagit
tpope/vim-fugitive
airblade/vim-gitgutter
tpope/vim-abolish
tpope/vim-unimpaired
sbdchd/neoformat
junegunn/fzf
junegunn/fzf.vim
sheerun/vim-polyglot

Keybase proof

I hereby claim:

  • I am jperras on github.
  • I am jperras (https://keybase.io/jperras) on keybase.
  • I have a public key ASCVivxJMcbrFE90EG9HP9m-8n2c6R4QT9RupAR8allhRgo

To claim this, I am signing this object:

Keybase proof

I hereby claim:

  • I am jperras on github.
  • I am jperras (https://keybase.io/jperras) on keybase.
  • I have a public key ASA-OCKAnBMfI7bTurWTNXXubHO0YbTY91T5W_OH6mir6wo

To claim this, I am signing this object:

@jperras
jperras / approximate_subset_sum.py
Last active December 16, 2017 13:17
Approximate Subset Sum
# -*- coding: utf-8 -*-
import itertools
import operator
def trim(data, delta):
"""Trims elements within `delta` of other elements in the list."""
output = []
@jperras
jperras / slugify.py
Created July 10, 2013 15:34
Generate an ASCII-only slug based off of a unicode string.
from unidecode import unidecode
# Regular expression to match most "punctuation"
punctuation_re = re.compile(r'[\t !"#$%&\'()*\-/<=>?@\[\\\]^_`{|},.]+')
def slugify(text, delimiter=u'-'):
"""Generates an ASCII-only slug."""
result = []
for word in punctuation_re.split(text.lower()):
import re
version_pattern = re.compile(r"/v(?P<version>[0-9a-z\-\+\.]+)", re.IGNORECASE)
class VersionedAPIMiddleware(object):
"""
Allows a Werkzeug/Flask application to have a versioned API.
This middleware will extract out the API version specification in a URL
@jperras
jperras / deb-control.sh
Created May 14, 2012 18:17
For when you need to dive into a .deb and edit the control file.
#!/bin/bash
if [[ -z "$1" ]]; then
echo "Syntax: $0 debfile"
exit 1
fi
DEBFILE="$1"
TMPDIR=`mktemp -d /tmp/deb.XXXXXXXXXX` || exit 1
OUTPUT=`basename "$DEBFILE" .deb`.modified.deb