Skip to content

Instantly share code, notes, and snippets.

View jonnyhtw's full-sized avatar
💭
eating cheese

Jonny Williams jonnyhtw

💭
eating cheese
  • Reading Uni
  • Reading, UK
  • 08:29 (UTC -12:00)
View GitHub Profile
@Benbb96
Benbb96 / color_contrast.py
Last active July 19, 2022 12:53
Original PHP script from this stackoverflow question : https://stackoverflow.com/a/42921358/8439435 then updated to Python and following the WCAG 2.0 - G18.
BLACK_COLOR = "#000000"
WHITE_COLOR = "#FFFFFF"
def get_contrast_color(background_color: str) -> str:
"""
Util function to determine what's the best color between black or white to choose for a text
depending on the background color given in parameter.
Based on algorythm from WCAG 2.0 explained here : https://www.w3.org/TR/WCAG20-TECHS/G18.html#G18-tests
:param background_color: the background color in HEX format (eg: #9D412B)
@keithweaver
keithweaver / create-folder.py
Created March 10, 2017 03:42
Create a folder with Python
import os
def createFolder(directory):
try:
if not os.path.exists(directory):
os.makedirs(directory)
except OSError:
print ('Error: Creating directory. ' + directory)
@facundofarias
facundofarias / mutt_on_osx.sh
Created January 3, 2017 10:55
Installing and configuring Mutt on OSX
# Install mutt using brew
$ brew install mutt
# Configure mutt
$ vim ~/.muttrc
# Put the following on the mutt config file (.muttrc)
set imap_user = “YOUR_USERNAME@GMAIL_OR_YOUR_DOMAIN.com”
set imap_pass = “YOUR_PASSWORD”
set smtp_url = “smtp://YOUR_USERNAME@[email protected]:587/”
@jrziviani
jrziviani / mutt.txt
Last active September 5, 2022 16:30
mutt cheat sheet
Mutt
http://www.mutt.org/doc/manual/manual.html
Select (tag) messages: shift+t (T)
= (string)
~ (expression)
~b expr (message with expr in body)
[b]body
@JohannesBuchner
JohannesBuchner / rsyncprogress.py
Last active June 18, 2023 18:51
Progress bar for rsync
"""
Progress bar for rsync
========================
Shows file progress and total progress as a progress bar.
Usage
---------
Run rsync with -P and pipe into this program. Example::
@TiddoLangerak
TiddoLangerak / getCurrentWindowCWD.sh
Last active February 19, 2022 08:07
Script to get the CWD of the current active window, with support for shells running tmux. This can be used to launch new terminals in the same cwd as the current one.
#!/bin/bash
# i3 thread: https://faq.i3wm.org/question/150/how-to-launch-a-terminal-from-here/?answer=152#post-id-152
# Inspired by https://gist.github.com/viking/5851049 but with support for tmux
CWD=''
# Get window ID
ID=$(xdpyinfo | grep focus | cut -f4 -d " ")
# Get PID of process whose window this is
@lestoni
lestoni / gist:8c74da455cce3d36eb68
Last active November 14, 2024 10:37
vim folding cheatsheet

via (https://www.linux.com/learn/tutorials/442438-vim-tips-folding-fun)

  • zf#j creates a fold from the cursor down # lines.
  • zf/string creates a fold from the cursor to string .
  • zj moves the cursor to the next fold.
  • zk moves the cursor to the previous fold.
  • zo opens a fold at the cursor.
  • zO opens all folds at the cursor.
  • zm increases the foldlevel by one.
  • zM closes all open folds.
@kidpixo
kidpixo / jupyter_shortcuts.md
Last active September 21, 2024 14:26
Keyboard shortcuts for ipython notebook 3.1.0 / jupyter

Warning This is SEVERELY outdated, the current jupyter version is > 6.X, please refer to your current jupyter notebook installation!

Disclaimer : I just copied those shortcuts from Jupyter Menú > Help > Keyboard Shortcuts, I didn't wrote them myself.

Check your current shortcuts in your Help, shortcuts coule have been modified by extensions or your past self.

Toc

Keyboard shortcuts

@bellbind
bellbind / complex.py
Last active March 10, 2023 19:14
[python3] Calc Riemann Zeta function
# complex arith for programming with other languages
# - required functions: exp(f), log(f), sin(f), cos(f), atan2(f), pow(f1, f2)
import math
# [equality for complex]
def ceq(a, b):
return a.real == b.real and a.imag == b.imag
# [add, sub, mul for complex]
@jakevdp
jakevdp / discrete_cmap.py
Last active August 26, 2024 01:46
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"""