Skip to content

Instantly share code, notes, and snippets.

View Jwink3101's full-sized avatar

Justin Winokur Jwink3101

View GitHub Profile
@daladim
daladim / run-as-cron.sh
Last active November 6, 2023 09:42
Run a command or a script as cron would
#!/bin/bash
# Run as if it was called from cron, that is to say:
# * with a modified environment
# * with a specific shell, which may or may not be bash
# * without an attached input terminal
# * in a non-interactive shell
# This scripts supports cron jobs run by any user, just run it as the target user (e.g. using sudo -u <username>)
# An up-to-date version of this script may be available at https://github.com/daladim/run-as-cron
@htr3n
htr3n / macos-ramdisk.md
Last active May 1, 2024 10:16
Creating RAM disk in macOS

Built-in

diskutil erasevolume HFS+ 'RAM Disk' `hdiutil attach -nobrowse -nomount ram://XXXXX`

where XXXXX is the size of the RAM disk in terms of memory blocks.

Notes:

@arjunkomath
arjunkomath / push.java
Last active January 2, 2022 00:44
Push by Techulus
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;
import org.junit.Test;
import java.io.IOException;
import static com.jayway.jsonpath.matchers.JsonPathMatchers.hasJsonPath;
@dfur
dfur / Python pathlib guide.md
Last active November 19, 2022 06:33
A brief tour of all the properties and methods in the python standard library 'pathlib' module which provides easy, object oriented file handling in modern python.

Easy object-oriented file handling in modern python

A brief tour of all the properties and methods in the pathlib module.

The pathlib module is part of the Python stardard library (as of v. 3.4) and can be used can do file handling tasks previously done by multiple libraries. Instead of using mere strings to represent filepaths, pathlib uses objects that have many useful properties and methods.

For example, pathlib can replace (amongst others):

os - .rename(), .sep(), .walk(), .chmod(), .mkdir(), .stat()
os.path - .join(), .split(), .exists(), .basename()

@fay59
fay59 / icloud-album-download.sh
Last active May 1, 2024 21:02
Download entire iCloud shared albums
#!/bin/bash
# requires jq
# arg 1: iCloud web album URL
# arg 2: folder to download into (optional)
function curl_post_json {
curl -sH "Content-Type: application/json" -X POST -d "@-" "$@"
}
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active April 25, 2024 02:01
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

@bradmontgomery
bradmontgomery / dummy-web-server.py
Last active April 15, 2024 14:27
a minimal http server in python. Responds to GET, HEAD, POST requests, but will fail on anything else.
#!/usr/bin/env python
"""
Very simple HTTP server in python (Updated for Python 3.7)
Usage:
./dummy-web-server.py -h
./dummy-web-server.py -l localhost -p 8000
Send a GET request: