Skip to content

Instantly share code, notes, and snippets.

View pstaender's full-sized avatar
👾
extra terrestrial

Philipp Staender pstaender

👾
extra terrestrial
  • Cologne, Germany
View GitHub Profile
@pstaender
pstaender / simple_json_anonymizer.mjs
Created February 10, 2023 15:02
Usage: node simple_json_anonymizer.mjs data.json > anonymized.json
import { faker } from '@faker-js/faker/locale/de';
import {readFile} from 'node:fs/promises';
// https://fakerjs.dev/api/
let fields = [
[
/email/i, faker.internet.email,
],
[
/nachname/i, faker.name.lastName,
@pstaender
pstaender / change_wallpaper.sh
Created September 28, 2018 12:44
Change wallpaper in Linux Mint (cinnamon) according to daytime with MacOS Mojave wallpapers
#!/bin/bash
wallpaper=`ruby get_wallpaper_url.rb`
# https://stackoverflow.com/questions/10374520/gsettings-with-cron#19666729
PID=$(pgrep -fo cinnamon-session)
export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-)
gsettings set org.cinnamon.desktop.background picture-uri "file://${wallpaper}"
@pstaender
pstaender / png2pdf.sh
Last active September 27, 2022 04:26
OpenSource OCR for Mac OS
#!/bin/bash
# For Macs:
# brew install tesseract --with-all-languages
echo "Hint: Prepare all png images as valid OCR input before starting convert process"
if [[ "$1" != "" ]]; then
files="$1"
else
@pstaender
pstaender / using_php_built-in-server_with_silverstripe.md
Last active September 20, 2022 07:15
Using the PHP built-in-server with SilverStripe v4+

Using the PHP built-in-server with SilverStripe v4+

In your SilverStripe project (the original module can be found here):

  $ composer require pstaender/silverstripe-serve

Just start now the server with:

@pstaender
pstaender / list.py
Created November 23, 2014 21:24
List google scholar search results for csv usage: ./list.py > list.csv
#! /usr/bin/env python
"""
scholar.py -c 1 --txt --phrase "Upper Echelons - The Organization as a Reflection of Its Top Managers"
"""
import os
import re
import subprocess
directory = os.path.dirname(os.path.abspath(__file__))
@pstaender
pstaender / update_hetzner_home_dns.rb
Created February 20, 2022 14:40
Updates your domain via hetzner dns api; like dyndns but without any limitations
require 'json'
require 'httparty'
class HetznerDNS
include HTTParty
base_uri 'https://dns.hetzner.com'
def initialize
@options = {
headers: {
__BEGIN__
*vimtips.txt* For Vim version 7.3.
------------------------------------------------------------------------------
" new items marked [N] , corrected items marked [C]
" *best-searching*
/joe/e : cursor set to End of match
3/joe/e+1 : find 3rd joe cursor set to End of match plus 1 [C]
/joe/s-2 : cursor set to Start of match minus 2
/joe/+3 : find joe move cursor 3 lines down
/^joe.*fred.*bill/ : find joe AND fred AND Bill (Joe at start of line)
require 'digest'
require 'json'
require 'shellwords'
def command?(name)
`which #{name}`
$?.success?
end
unless command?('sips')
# alias cd to modern cd with auto ls
alias ls='exa -l --git --header'
function cd_and_ls {
cd $1 && ls
}
alias cd=cd_and_ls
@pstaender
pstaender / remove_pdf_password.sh
Created November 11, 2013 12:07
Remove password from protected PDF file with GhostScript
gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=unencrypted.pdf -c .setpdfwrite -f encrypted.pdf