Skip to content

Instantly share code, notes, and snippets.

View shanehh's full-sized avatar
🏠

SH shanehh

🏠
View GitHub Profile
@craig552uk
craig552uk / basics_of_unix_philosophy
Last active May 10, 2021 09:42
Basics of the Unix Philosophy
Basics of the Unix Philosophy
=============================
Rule of Modularity: Write simple parts connected by clean interfaces
Rule of Clarity: Clarity is better than cleverness
Rule of Composition: Design programs to be connected with other programs
Rule of Separation: Separate policy from mechanism; separate interfaces from engines
@mutsune
mutsune / custom.css
Created February 22, 2017 14:45
Fira Code with Ligature for Jupyter Notebook
@font-face {
font-family: 'Fira Code';
src: url("https://cdn.rawgit.com/dunovank/jupyter-themes/1e851888/jupyterthemes/fonts/monospace/firacode/firacode.otf") format("opentype");
}
.CodeMirror {
font-family: 'Fira Code';
font-variant-ligatures: initial;
}
@kofemann
kofemann / adler32.py
Last active October 15, 2021 07:57
A script to calculate adler32 checksum of given files
#!/usr/bin/env python
'''A script to calculate adler32 checksum of given files'''
BLOCKSIZE=256*1024*1024
import sys
from zlib import adler32
for fname in sys.argv[1:]:
asum = 1
with open(fname,"rb") as f:
@shospodarets
shospodarets / Chrome headless Puppeteer- capture DOM element screenshot using
Last active January 17, 2023 18:52
Chrome headless Puppeteer- capture DOM element screenshot using
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch();
const page = await browser.newPage();
// Adjustments particular to this page to ensure we hit desktop breakpoint.
page.setViewport({width: 1000, height: 600, deviceScaleFactor: 1});
await page.goto('https://www.chromestatus.com/samples', {waitUntil: 'networkidle'});
@frafra
frafra / .pre-commit-config.yaml
Last active November 30, 2023 03:36
Good defaults for a Python project: Poetry + pre-commit + black + flakehell + isort
repos:
- repo: local
hooks:
- id: black
name: black
entry: black
language: system
types: [python]
- repo: local
hooks:
@kmicinski
kmicinski / church.rkt
Created April 6, 2021 04:17
Church numerals in Racket
#lang racket
;; numbers are represented as:
;; (lambda (f) (lambda (x) (f ... (f x))))
;; where there are n calls to f.
(define zero (lambda (f) (lambda (x) x)))
(define one (lambda (f) (lambda (x) (f x))))
(define two (lambda (f) (lambda (x) (f (f x)))))
;; do add1 n times, starting from 0
@hugobowne
hugobowne / scheme.py
Last active December 30, 2023 04:36
Dave Beazley had us implement a mini-scheme like interpreter in Python today: this is what we came up with.
# scheme.py
#
# Challenge: Can you implement a mini-scheme interpreter (program that's running another program) capable of
# executing the following code (now at bottom of file):
def seval(sexp, env):
if isinstance(sexp, (int, float)):
return sexp
elif isinstance(sexp, str): #Symbols
return env[sexp] #Evaluate symbol names in the 'env'
@bynil
bynil / config-git-proxy.txt
Last active January 23, 2024 12:37
Use git over socks5 proxy
Port: 1080
1. Create a file /YOUR PATH/gitproxy.sh with content:
#!/bin/sh
nc -X 5 -x 127.0.0.1:1080 "$@"
2. Edit your ~/.gitconfig
# For git://
@M0r13n
M0r13n / README.md
Last active January 30, 2024 19:35
Logging with Loguru in Flask

This is a simple example of how to use loguru in your flask application

Just create a new InterceptHandler and add it to your app. Different settings should be configured in your config file, so that it is easy to change settings.

Logging is then as easy as:

from loguru import logger

logger.info("I am logging from loguru!")

1. `vim /etc/syslog.conf`
2. Add to end of file: `cron.* /var/log/cron.log`
3.
```
sudo launchctl unload /System/Library/LaunchDaemons/com.apple.syslogd.plist
sudo launchctl load /System/Library/LaunchDaemons/com.apple.syslogd.plist
```
[where-is-the-cron-log-file-in-macosx-lion](http://apple.stackexchange.com/questions/38861/where-is-the-cron-log-file-in-macosx-lion)