Skip to content

Instantly share code, notes, and snippets.

View lrq3000's full-sized avatar
๐ŸŽต

Stephen Karl Larroque lrq3000

๐ŸŽต
View GitHub Profile
@angstwad
angstwad / dict_merge.py
Last active December 22, 2024 16:02
Recursive dictionary merge in Python
import collections
def dict_merge(dct, merge_dct):
""" Recursive dict merge. Inspired by :meth:``dict.update()``, instead of
updating only top-level keys, dict_merge recurses down into dicts nested
to an arbitrary depth, updating keys. The ``merge_dct`` is merged into
``dct``.
:param dct: dict onto which the merge is executed
:param merge_dct: dct merged into dct
@Zulko
Zulko / rapunzel_moviepy.py
Last active May 1, 2023 21:22
Tangled + MoviePy
"""
This creates the following GIF, where the text appears to be "embedded"
in the video and "disappears" behind rapunzel.
http://i.imgur.com/gxEHfLX.gif
"""
from moviepy.editor import *
import numpy as np
import skimage.morphology as skm
@tiarno
tiarno / PDF-Testing.md
Last active February 17, 2017 13:33
PDF Checking

PDF Testing Gist

These two files, pdf_linkchecker.py and pdf_fontchecker.py are code examples to go along with a blog article: http://reachtim.com/articles/PDF-Testing.html

See the article for details on how to test your PDFs for broken internal and external links and for unembedded fonts.

@jakevdp
jakevdp / discrete_cmap.py
Last active January 12, 2025 13:24
Small utility to create a discrete matplotlib colormap
# By Jake VanderPlas
# License: BSD-style
import matplotlib.pyplot as plt
import numpy as np
def discrete_cmap(N, base_cmap=None):
"""Create an N-bin discrete colormap from the specified input map"""
@arlukin
arlukin / Result.txt
Last active July 28, 2016 08:26
Benchmark of merging dicts in python.
time 1.6452050209 --- d4 = d1.copy(); d4.update(d2), d4.update(d3)
time 1.69228887558 --- d4 = dict(d1, **d2); d4.update(d3)
time 1.78650903702 --- d4 = {}; d4.update(d1); d4.update(d2), d4.update(d3)
time 1.92449307442 --- d4 = {} for d in (d1, d2, d3): d4.update(d)
time 2.00036215782 --- d4 = dict(d1, **d2); d5=dict(d4, **d3)
time 2.04427695274 --- d4 = dict(d1) for d in (d2, d3): d4.update(d)
time 2.68033099174 --- d4 = reduce(lambda x,y: dict(x, **y), (d1, d2, d3))
time 3.72226691246 --- d4 = dict(chain(*[d.iteritems() for d in (d1, d2, d3)]))
time 4.01872420311 --- d4 = dict(d1.items() + d2.items() + d3.items())
time 4.07779598236 --- d4 = dict(chain.from_iterable(d.iteritems() for d in (d1, d2, d3)))
@syllog1sm
syllog1sm / gist:10343947
Last active September 19, 2024 23:54
A simple Python dependency parser
"""A simple implementation of a greedy transition-based parser. Released under BSD license."""
from os import path
import os
import sys
from collections import defaultdict
import random
import time
import pickle
SHIFT = 0; RIGHT = 1; LEFT = 2;
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active May 13, 2025 09:47
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

$files = ls -Recurse | where {!$_.PsIsContainer}
$files | foreach {
$destinationFolder = $_.Directory.FullName -replace "SrcFolderName", "SrcFolderName_converted"
emf2sf.bat $_.FullName --out-dir $destinationFolder
if($LastExitCode -eq 2)
{
copy $_.FullName $destinationFolder
}
}
@huyng
huyng / .numpy-site.cfg
Last active March 14, 2017 19:36
Place the following in your home directory at ~/.numpy-site.cfg in order to install numpy with openblas support
# Place the following in your home directory at ~/.numpy-site.cfg
# in order to install numpy with openblas support
[openblas]
libraries = openblas
library_dirs = /usr/local/opt/openblas/lib
include_dirs = /usr/local/opt/openblas/include
@rxaviers
rxaviers / gist:7360908
Last active May 17, 2025 07:56
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: ๐Ÿ˜„ :smile: ๐Ÿ˜† :laughing:
๐Ÿ˜Š :blush: ๐Ÿ˜ƒ :smiley: โ˜บ๏ธ :relaxed:
๐Ÿ˜ :smirk: ๐Ÿ˜ :heart_eyes: ๐Ÿ˜˜ :kissing_heart:
๐Ÿ˜š :kissing_closed_eyes: ๐Ÿ˜ณ :flushed: ๐Ÿ˜Œ :relieved:
๐Ÿ˜† :satisfied: ๐Ÿ˜ :grin: ๐Ÿ˜‰ :wink:
๐Ÿ˜œ :stuck_out_tongue_winking_eye: ๐Ÿ˜ :stuck_out_tongue_closed_eyes: ๐Ÿ˜€ :grinning:
๐Ÿ˜— :kissing: ๐Ÿ˜™ :kissing_smiling_eyes: ๐Ÿ˜› :stuck_out_tongue: