Skip to content

Instantly share code, notes, and snippets.

View mortezakarimi's full-sized avatar
👨‍💻
= 🥣 Eat ⤍ 😴 Sleep ⤍ ‍💻 Code

Mortie mortezakarimi

👨‍💻
= 🥣 Eat ⤍ 😴 Sleep ⤍ ‍💻 Code
View GitHub Profile
@st-f
st-f / Download_X_Lorem_Pixel_Images.sh
Last active December 6, 2019 09:36
Download X random images from lorempixel.com
# usage : sh download.sh 100
# will download 100 pics
START=1
for i in $(eval echo "{$START..$1}")
do
curl "http://lorempixel.com/index.php?generator=1&x=640&y=480&cat=" -o temp.html && cat temp.html | sed -n 's/.*<img src="\([^" ]*\)".*/\1/p' | awk '{print "http://lorempixel.com/"$1}' | xargs curl -o $i.jpg
done
@stecman
stecman / monday-for-week.php
Last active October 1, 2024 13:26
Reliable PHP function to return Monday for week (pre-PHP 7.1)
<?php
/**
* Find the starting Monday for the given week (or for the current week if no date is passed)
*
* This is required as strtotime considers Sunday the first day of a week,
* making strtotime('Monday this week') on a Sunday return the adjacent Monday
* instead of the previous one.
*
* @param string|\DateTime|null $date
@chrisroos
chrisroos / gpg-import-and-export-instructions.md
Created September 9, 2011 10:49
Instructions for exporting/importing (backup/restore) GPG keys

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/

or, instead of backing up trustdb...