Skip to content

Instantly share code, notes, and snippets.

Markus Fisch markusfisch

Block or report user

Report or block markusfisch

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@markusfisch
markusfisch / mkpw.rb
Last active Sep 25, 2015
mkpasswd in ruby
View mkpw.rb
#!/usr/bin/env ruby
c = "abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789!-_".split( // )
(ARGV.length.zero? ? [8] : ARGV).each do |n|
puts (0...n.to_i).map{ c[rand( c.size )] }.join
end
@markusfisch
markusfisch / unpack.sh
Last active Nov 18, 2019
bash script to extract archives always in a directory
View unpack.sh
#!/usr/bin/env bash
# Unpack archive safely (means always in its own directory
#
# @param 1 - name and path of archive to extract
function unpack()
{
local ARCHIVE=$1
local TMP=".unpack-$USER-$$"
local NAME=${ARCHIVE##*/}
@markusfisch
markusfisch / Makefile
Last active Jun 29, 2019
Makefile to generate create/drop/recreate scripts from a bunch of SQL files
View Makefile
CREATE=create.sql
DROP=drop.sql
RECREATE=recreate.sql
all: recreate
recreate: clean create drop
cat $(DROP) $(CREATE) > $(RECREATE)
create:
@markusfisch
markusfisch / refactor.sh
Last active Jan 15, 2016
bash script to exchange a literal in files and file names (can be used to completely rename a Xcode project or to refactor something throughout your whole project, use with caution!)
View refactor.sh
#!/usr/bin/env bash
# Refactor file and directory names as well as words in files
#
# @param 1 - case-sensitive pattern to replace
# @param 2 - replacement string
# @param 3 - working directory (optional)
refactor()
{
local PATTERN=$1
@markusfisch
markusfisch / mkpw.sh
Last active Jun 29, 2019
mkpasswd in bash
View mkpw.sh
#!/usr/bin/env bash
C=${CHARSET:-'abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789!-_'}
P=
for (( N=${1:-8}; N--; ))
do
P=$P${C:$(( RANDOM%${#C} )):1}
done
@markusfisch
markusfisch / vup.sh
Last active Jan 15, 2016
Update version number of a project. Useful for sources with autotools and doxygen.
View vup.sh
#!/usr/bin/env bash
# check for required tools
for X in find grep sed mktemp
do
which $X &>/dev/null || {
echo "error: missing $X" >&2
exit 1
}
done
@markusfisch
markusfisch / latestgreatest.pl
Created Feb 16, 2012
List all files of the given paths sorted by size or time of modification
View latestgreatest.pl
#!/usr/bin/env perl
#
# latestgreatest - list all files of the given paths sorted by size or
# time of modification
#
# I wrote this for demonstration purposes only.
#
# On a sane system, you should use find instead:
#
# To find files that did change since yesterday:
@markusfisch
markusfisch / README.md
Last active Jan 15, 2016
A little script that helps to generate a source archive for CSS/JavaScript files.
View README.md

srcar

Helps you to generate a source archive for your CSS/JavaScript files.

Compressing multiple CSS/JavaScript files in just one archive will speed up your website because it will lower the transfer volume and does minimize the number of requests.

If you're using Makefiles (or anything similar) to automate building

@markusfisch
markusfisch / CheckRange.js
Created Mar 22, 2012
A bookmarklet to check a range of checkboxes
View CheckRange.js
(function( w )
{
if( w.checkRange )
return;
w.checkRange =
{
last: null,
status: false,
@markusfisch
markusfisch / fixcr.sh
Last active Jan 15, 2016
Deal with those needless carriage returns (CR) in text files from/for coworkers/friends on Windows
View fixcr.sh
#!/usr/bin/env bash
readonly CR=$'\r'
# Add CR to given stream
add_cr()
{
while read -r
do
echo "$REPLY"$CR
You can’t perform that action at this time.