Skip to content

Instantly share code, notes, and snippets.

@mamu7211
mamu7211 / scan.sh
Last active February 15, 2024 05:33
Scan script for scanning multiple documents
#!/bin/bash
echo ""
set -e
mkdir -p ./scan_target
scanner_name="Canon"
target_paths=('/home/$USER/Tools/paperless/paperless-ngx/consume')
usb_address=$(lsusb | grep $scanner_name | sed -E "s/Bus ([0-9]+) Device ([0-9]+): .+/\1:\2/g")
@mamu7211
mamu7211 / ms-outlook-fetch-mail.vba
Last active June 26, 2020 07:25
Fetch Mail Addresses from MS-Outlook
Option Explicit
Sub MailFetchTest()
Dim addresses() As String
Dim ns As Outlook.NameSpace
Dim cnt As Integer
Set ns = GetNamespace("MAPI")
@mamu7211
mamu7211 / postgres-cheatsheet.md
Created November 5, 2019 08:00 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
#!/bin/bash
fileName=$1
scanimage -d "genesys:libusb:002:003" --resolution 300 --brightness 50 --mode Color --format tiff > $1.scan.tiff
tiff2pdf -o $fileName.scan.pdf $fileName.scan.tiff
ocrmypdf -q -l deu $fileName.scan.pdf $fileName.pdf
pdftotext $fileName.pdf
cat $fileName.txt
@mamu7211
mamu7211 / adfafruit-hello-server-access-point.c
Last active January 24, 2018 22:54
Adafruit Hello Server with Soft Access Point Mode
#include <ESP8266WiFi.h>
#include <ESP8266WebServer.h>
#include <ESP8266mDNS.h>
#include <FS.h>
IPAddress local_IP(192,168,4,22);
IPAddress gateway(192,168,4,9);
IPAddress subnet(255,255,255,0);
ESP8266WebServer server(80);
@mamu7211
mamu7211 / MaterialColors.java
Last active December 12, 2017 21:17
AWT Material(ized) Design Color Set
import java.awt.*;
/**
* Color Codes taken from http://materializecss.com/color.html
*
* LICENSE ----------------------------------------------------------------------
*
* The MIT License (MIT)
*
* Copyright (c) 2014-2017 Materialize
@mamu7211
mamu7211 / mvnts.sh
Created August 17, 2017 14:55
Prepend Maven Output with timestamp
#!/bin/bash
#
# Prepends a date string in front of the Maven output.
# A workaround for http://jira.codehaus.org/browse/MNG-519 "Timestamps on messages"
[ -z "${AWK}" ] && AWK="$(which gawk 2>/dev/null)" || AWK="$(which awk 2>/dev/null)" || { echo "Error: Could not find AWK tool."; exit 1; }
"${AWK}" 'BEGIN { print strftime("%Y-%m-%d %H:%M:%S"); }' 2>&1 > /dev/null || { echo "Error: your AWK version does not support strftime() function." && exit 1; }
mvn "${@}" 2>&1 |"${AWK}" '{ print strftime("%Y-%m-%d %H:%M:%S"), $0; fflush(); }'
# see comp.unix.shell FAQ: (http://cfajohnson.com/shell/cus-faq-2.html)
@mamu7211
mamu7211 / save-all.vbs
Created August 1, 2017 08:23
Save All XLS Worksheets as CSV
Sub SaveAll()
Dim count As Integer
Dim i As Integer
count = ActiveWorkbook.Worksheets.count
For i = 1 To count
SaveAsCsv (ActiveWorkbook.Worksheets(i).Name)
Next i
End Sub
Sub SaveAsCsv(sheetname As String)
@mamu7211
mamu7211 / CreatePayload.groovy
Created June 17, 2017 05:57
Create large file with random content.
def random = new Random()
def sizeInMB = 10
def size = 1024 * 1024 * sizeInMB
def chars = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',
'1','2','3','4','5','6','7','8','9','0',
'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z',
'!','"','§','$','%','&','/','(',')','=','?','`',';',':','_','\'','*','"','~','\\','[',']','{','}','|'
,'<','>',';',':','-','\n']
@mamu7211
mamu7211 / ssh-into.sh
Last active August 11, 2017 11:57
Small bash menu script for SSH'ing into some servers.
#!/bin/bash
prompt="Choose a Server, or 'q' for quit"
ipRegex="[a-zA-Z\.]+@(([0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3})|([a-zA-Z\.\-]+))"
sshTimeout=2
printHelp() {
echo "Usage: $0 <-d|-t|-p|-a> [-h]"
echo " -d : list development servers"
echo " -t : list test servers"