Skip to content

Instantly share code, notes, and snippets.

View nst's full-sized avatar

Nicolas Seriot nst

View GitHub Profile
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.colors import LinearSegmentedColormap
clist=[(1,1,1),(1,0,0)]
cm = LinearSegmentedColormap.from_list('wr',clist)
plt.register_cmap(cmap=cm)
clist=[(0,0,1),(1,1,1)]
@nst
nst / kovach_pycairo.py
Last active February 27, 2023 07:10
Reproducing Benjamin Kovach's art with pycairo
#!/usr/bin/env python
# Author: Nicolas Seriot
# Date: 2018-03-17
# Description: Reproducing Benjamin Kovach's art with pycairo
# https://www.kovach.me/Generating_artwork_with_Haskell.html
# Output: http://seriot.ch/visualization/kovach_pycairo.png
# Gist: https://gist.github.com/nst/3dc5378399678be7eb297ef18580025e
import cairo
@0xced
0xced / ActuallyLocalizedStringForStatusCode.m
Created November 15, 2017 15:40
Get a *localized* string for a given HTTP status code
#import <Foundation/Foundation.h>
static NSString * _Nonnull ActuallyLocalizedStringForStatusCode(NSInteger statusCode)
{
static NSBundle *cfNetworkBundle;
static dispatch_once_t once;
dispatch_once(&once, ^{
cfNetworkBundle = [NSBundle bundleForClass:NSHTTPURLResponse.class];
});
NSString *httpError = [NSHTTPURLResponse localizedStringForStatusCode:statusCode];
anonymous
anonymous / xcode.sh
Created November 9, 2017 17:20
#!/bin/bash
# Exit the script immediately on error
set -e
# We'll work in /tmp
cd /tmp
# Clone mach_override unless we already have it
if [ ! -d ~/mach_override ]; then
@marcan
marcan / gamma_trick.sh
Last active December 10, 2023 22:06
Two images in one using the PNG gamma header trick.
#!/bin/sh
# PNG Gamma trick (by @marcan42 / marcan@marcan.st)
#
# This script implements an improved version of the gamma trick used to make
# thumbnail images on reddit/4chan look different from the full-size image.
#
# Sample output (SFW; images by @Miluda):
# https://mrcn.st/t/homura_gamma_trick.png
# https://www.reddit.com/r/test/comments/6edthw/ (click for fullsize)
# https://twitter.com/marcan42/status/869855956842143744
@wojteklu
wojteklu / clean_code.md
Last active May 2, 2024 23:25
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

@s4y
s4y / editor.md
Last active April 14, 2018 10:45
A tiny little text editor that you can type as a URL

Simplest

data:text/html,<body contenteditable>

Monospace font, spell checking off

data:text/html,<body spellcheck=false style="font: 16px monospace" contenteditable>

URL updates as you type

//: Playground - noun: a place where people can play
import UIKit
protocol Foo {
}
protocol Bar {

Turning Off Github Issues

My friend Michael Jackson turned off github issues on one of his smaller projects. It got me thinking...

Maintainers getting burned out is a problem. Not just for the users of a project but the mental health of the maintainer. It's a big deal for both parties. Consumers want great tools, maintainers want to create them, but maintainers don't want to be L1 tech support, that's why they

@numist
numist / plot.swift
Last active March 14, 2016 14:23
A function that plots (as a string) a function of (Double) -> Double
import Darwin // Provides: sin/cos/tan
// memoize function from https://gist.github.com/berkus/8a9e104f8aac5d025eb5
func memoize<T: Hashable, U>( body: ( (T)->U, T )->U ) -> (T)->U {
var memo = Dictionary<T, U>()
var result: ((T)->U)!
result = { x in
if let q = memo[x] { return q }
let r = body(result, x)
memo[x] = r