Skip to content

Instantly share code, notes, and snippets.

@jahands
jahands / file-layout-spec.md
Last active October 19, 2015 20:15
File layout spec for storing/backing up/archiving files.

File layout spec 2015

General rules

  • Top level folders are upper-case.
  • Windows computer names are upper-case.
  • Linux computer names are lower-case.
  • Computer names:
    • DT10: My desktop with Windows 10 on it.
    • PB10: My laptop (HP Probook) with Windows 10 on it.
@jahands
jahands / important-gists.md
Last active October 16, 2015 21:45
List of important gists for easy access.
@jahands
jahands / odrive-symbolic-links.ps1
Created October 26, 2015 21:03
Add symbolic links for odrive
@jahands
jahands / purge_cloudflare.sh
Last active October 31, 2015 18:19
Clear cache of CloudFlare resources when they are updated.
# Usage: purge_cloudflare.sh <public folder where hugo is hosted from> <base url of website>
# Example:
# purge_cloudflare.sh /var/www/ "https://example.com/"
key="<api_key>"
id="<zone_id>"
email="<email>"
inDir=$1 # eg. example.com
baseUrl=$2 # eg. example.com
@jahands
jahands / gitwf.sh
Created November 12, 2015 16:26
WorkFlowy -> Git -> Rendered HTML
#!/bin/bash
# Don't want to do a few things if DEBUG=="debug"
DEBUG=$1
# CD to the directory containing the notes repo.
cd /home/gitworkflowy/gitwf
if [ "$DEBUG" != "debug" ]; then
./main # Source: https://github.com/jacobhands/gitworkflowy/blob/master/main.go
fi
cd notes # The repo where we keep the notes including WorkFlowy.md
# Generate new file name.
@jahands
jahands / docker-clean.sh
Created December 18, 2015 15:59
Remove all the extra docker things
docker rm -v $(docker ps -a -q -f status=exited)
docker rmi $(docker images -f "dangling=true" -q)
docker run -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/docker:/var/lib/docker --rm martin/docker-cleanup-volumes
@jahands
jahands / gogs-postgres-docker.sh
Last active December 30, 2015 17:46
Use gogs and posgres via docker
sudo docker run --name gogs-postgres \
-e POSTGRES_USER=git \
-e POSTGRES_PASSWORD=Passw0rd \
-e POSTGRES_DB=gogs \
-d postgres
sudo docker run --name=gogs \
-p 10022:22 \
-p 10080:3000 \
-v /var/gogs:/data \
--link gogs-postgres:postgres \
@jahands
jahands / Twitch.ps1
Last active January 23, 2016 18:33
A wrapper for livestreamer which adds looping functionality
[CmdletBinding()]
Param(
[Parameter(Mandatory=$true,Position=1)]
[string]$StreamName,
[Parameter(Position=2)]
[int]$Quality=1,
[Parameter()]
[bool]$Retry=$true,
[Parameter()]
[int]$RetryTimeout=10
@jahands
jahands / WebLinkScraper.ps1
Created February 2, 2016 23:36
Basic web scraper.
$urlRegex="https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)"
$links=@()
function Scrape([string]$Url){
(wget $Url).Links.href | Where-Object {$_ -match $urlRegex -and -not $global:links.Contains($_)} | ForEach-Object{
$global:links+=$_
echo $($global:links.Count.ToString() + " : " + $_)
Scrape -Url $_
}
}
Scrape -Url "https://technet.microsoft.com/en-us/magazine/2007.11.powershell.aspx"
@jahands
jahands / strart-backup.sh
Created February 6, 2016 18:40
My backup script
#!/bin/bash
PATH=$PATH:/usr/local/bin
H=/home/git
GOGS=$H/gogs
# run postgres dump
docker exec gogs-postgres pg_dump -U gogs -Fc gogs -f /var/pgbackup/gogs.dump
sleep 600
hb backup \
-c /home/git/hb \
-D1g \