Skip to content

Instantly share code, notes, and snippets.

View stekhn's full-sized avatar

Steffen Kühne stekhn

View GitHub Profile
@stekhn
stekhn / update-git-remote.sh
Last active April 3, 2018 10:03
Change Git remote url for all directories in path. Useful, if you have migrated multiple repositories to a new organisation or user.
#!/bin/bash
# Change Git remote url for all directories in current path
old_org="[email protected]:old-organisation"
new_org="[email protected]:new-organisation"
for d in ./*; do
echo "$d"
if [ -d "$d" ]; then
cd "$d"
@stekhn
stekhn / gist:ca1a785a63808d30294a052f207372f8
Created March 29, 2018 09:37
Clone all repositories from a user or organisation (https://stackoverflow.com/a/32833411/2037629)
curl "https://api.github.com/orgs/br-data/repos?page=1&per_page=100" |
grep -e 'git_url*' |
cut -d \" -f 4 |
xargs -L1 git clone
@stekhn
stekhn / gist:073065c5dce45ce4ce86c332f6a7187c
Created January 31, 2018 15:19
Batch resize images to 100 pixel thumbnails with decent quality
mogrify -strip -resize 100x100 -interlace Plane -quality 85% -path . *.jpg
@stekhn
stekhn / gist:22382c039409e68e62bfb73b794fa104
Created December 14, 2017 13:26
Get filename from URL or path in Excel or Google Spreadsheets
=TRIM(RIGHT(SUBSTITUTE(A1;"/";REPT(" ";100));100))
@stekhn
stekhn / print-line-by-line.sh
Created December 8, 2017 16:01
Bash script to print any document or file line by line with a small, random delay. Nice to fake a "hacking" screen.
#!/bin/bash
while IFS='' read -r line || [[ -n "$line" ]]; do
sleep $(( ( RANDOM % 1 ) + 1 ))
echo "$line"
done < "$1"
@stekhn
stekhn / count-pages.sh
Last active December 8, 2017 15:59
Bash script to count the total number of pages of multiple PDFs in a folder.
#!/bin/bash
sum=0
if [ "$1" != "" ]
then
dir=$1
else
dir=.
fi
@stekhn
stekhn / shareTheLove.js
Last active December 8, 2017 14:46
Infinite recursion with the sole purpose of sharing love
(function shareTheLove(♥) {
if (♥ < Infinity) {
shareTheLove(++♥)
}
})(0);
@stekhn
stekhn / gist:c50df43c32c063ddbdb3cf3be2c199fd
Created October 2, 2017 13:44
Generate alpha(numeric) IDs from aa to zz in Excel
=CHAR((ROW(A1)-1)/26+97)&CHAR(MOD(ROW(A1)-1;26)+97)
@stekhn
stekhn / form.html
Created May 27, 2017 15:24
Change URL location and parameters with a simple a HTML form. The query strings gets constructed on form submit. No JavaScript required.
<form action="search">
<fieldset>
<legend>Search string</legend>
<input type="search" name="query" value="" placeholder="Enter text">
</fieldset>
<fieldset>
<legend>Search for</legend>
<input type="radio" name="type" value="name" checked="checked">
@stekhn
stekhn / merkel-terminkalender.json
Created January 30, 2017 10:31
Sitemap configuration for scraping Angela Merkel's calender using the webscrape.io Chrome extension
{
"selectors": [
{
"parentSelectors": [
"_root"
],
"type": "SelectorLink",
"multiple": true,
"id": "month",
"selector": "div.calendar-switcher.months ul li a",