Skip to content

Instantly share code, notes, and snippets.

View michalcs's full-sized avatar

Michal Csanaky michalcs

View GitHub Profile
#!/bin/bash
# Change the date under CUTOFF_DATE to change how far back you want to delete
# Install the GitHub CLI tool by following the instructions in the official documentation: https://cli.github.com/manual/installation
# Make sure you auth first to github with 'gh auth login'
REPO_OWNER="OWNER"
REPO_NAME="REPO_NAME"
CUTOFF_DATE=$(date --date='30 days ago' +'%Y-%m-%dT%H:%M:%SZ')
PAGE=1
@jacobobryant
jacobobryant / bookmarklet.js
Last active February 2, 2024 16:53
How to make your own airtable bookmark bookmarklet
// 1. Create a table on Airtable, and make URL/text columns with these names:
// URL, Title, Description, Image, Feed
//
// 2. Add a Form view. Click "Open form", then copy the URL. Set `airtable_form_url`
// below to that URL.
//
// 3. Create a new bookmark in your web browser, and paste in the code below. Whenever
// you're on a page you want to save, click the bookmark ("bookmarklet", technically).
// You'll go to the airtable form, and the columns listed above will be prefilled.
//
@m-radzikowski
m-radzikowski / script-template.sh
Last active July 13, 2024 13:20
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]
@emmahsax
emmahsax / circleci-config-to-ignore-branch.md
Last active June 15, 2023 11:41
CircleCI configuration to completely ignore a specific branch

CircleCI Configuration to Ignore a Branch

This file live in the .circleci/ directory of your project, named config.yml:

version: 2.1
jobs:
  skip:
    working_directory: ~/PROJECT_DIRECTORY # If we leave this out, the build will break with missing required arguments
 docker: [ image: circleci/ruby:2.6.5 ] # This doesn't really matter, but just choose any docker image
@MuhsinFatih
MuhsinFatih / fix-macos-python.md
Last active July 22, 2024 20:45
How to recover from messed up python installation on mac, and never have to mess with apple's shitty python confusion factory

I am assuming you are here because like me, you installed a bazillion different python interpreters on mac and the whole thing is a spagetti. Today, I finally fixed my python installation. Whatever I install for python2 or python3 using pip JUST.WORKS.. My god! finally.

What the hell?

Here is what I had messed up, which you also probably did:

  • I had too many different python interpreters
  • Too many different symlinks which I lost track of
  • almost no package I installed with pip worked without a headache
  • any attempt to fix using online resources made it worse.
@pysysops
pysysops / roman2number.sh
Last active June 25, 2023 18:32
Convert roman numerals to a number in BASH
#!/bin/bash
set -eu -o pipefail
roman_numerals=$(echo $1 | tr a-z A-Z)
# Test that it is valid
[[ "${roman_numerals//[IVXLCDM]/}" == "" ]] || \
{ echo Roman numerals ${roman_numerals} contains invalid characters ; \
exit 1 ;}
@scf37
scf37 / simulate_scanned_PDF.md
Created April 11, 2018 11:49
Simulate a scanned PDF with ImageMagick

Simulate a scanned PDF with ImageMagick

  1. Download and install Ghostscript and ImageMagick + Convert Module
  2. Execute the following command in the console (change the filename)
$ convert -density 200 INPUT.pdf -rotate 0.3 +noise Multiplicative -format pdf  -quality 85 -compress JPEG -colorspace gray OUTPUT.pdf

Description of the options

  • -density: set the input DPI to 200
  • -rotate: set Page rotation to 0.3 degrees
@glimpsed
glimpsed / Selective VPN traffic routes.txt
Last active April 27, 2023 09:22
How to route network traffic through a VPN (OpenVPN/TunnelBlick) ONLY for specific websites/IPs only on macOS / OS X (static routing)
Add the following line at the top of your .ovpnfile to prevent it from routing all network traffic on your Mac through
the VPN:
route-nopull
Next add the following line to allow the VPN to reroute traffic ONLY for a given IP address / domain (if you need to enable it
for a domain you can use its IP address):
route 1.2.3.4
@ogrrd
ogrrd / dnsmasq OS X.md
Last active July 22, 2024 08:36
Setup dnsmasq on OS X

Never touch your local /etc/hosts file in OS X again

To setup your computer to work with *.test domains, e.g. project.test, awesome.test and so on, without having to add to your hosts file each time.

Requirements

Install

@xeoncross
xeoncross / gitstats.sh
Created November 5, 2012 21:35
Git - calculate how many lines of code were added/changed by someone
# Run this in the project repo from the command-line
# http://stackoverflow.com/a/4593065/99923
git log --shortstat --author "Xeoncross" --since "2 weeks ago" --until "1 week ago" | grep "files changed" | awk '{files+=$1; inserted+=$4; deleted+=$6} END {print "files changed", files, "lines inserted:", inserted, "lines deleted:", deleted}'