Skip to content

Instantly share code, notes, and snippets.

@robsmith1776
robsmith1776 / crosstab.sql
Created September 13, 2020 12:33 — forked from romansklenar/crosstab.sql
PostgreSQL "pivot table" example using tablefunc extension
CREATE EXTENSION tablefunc;
CREATE TABLE sales(year int, month int, qty int);
INSERT INTO sales VALUES(2007, 1, 1000);
INSERT INTO sales VALUES(2007, 2, 1500);
INSERT INTO sales VALUES(2007, 7, 500);
INSERT INTO sales VALUES(2007, 11, 1500);
INSERT INTO sales VALUES(2007, 12, 2000);
INSERT INTO sales VALUES(2008, 1, 1000);
INSERT INTO sales VALUES(2009, 5, 2500);
@ArtisanByteCrafter
ArtisanByteCrafter / Get-GhostBlogStatusCode.ps1
Last active June 9, 2020 06:05
gets the status codes of a ghost blog's public urls
[string] $Site = 'https://www.example.com'
[string] $ApiKey = '123456'
$posts = (Invoke-RestMethod -Uri "$Site/ghost/api/v2/content/posts/?key=$ApiKey").posts.url
$posts | Foreach-Object {
[PSCustomObject]@{
'Url'=$_
'StatusCode'=(iwr -Uri $_).StatusCode
}
@horsepunchkid
horsepunchkid / psql_bash_completion.sh
Created June 5, 2019 20:46
Bash completion for psql services
_complete_psql() {
services=$(egrep -o '^\[.+\]' ~/.pg_service.conf | cut -f2 -d[ | cut -f1 -d] | sort)
if [[ $services ]]
then
COMPREPLY=( $( compgen -W "$services" -- ${COMP_WORDS[COMP_CWORD]}) )
else
echo
echo "(no services)"
echo -n "> ${COMP_WORDS} "
fi
Function Get-OwnedPW {
param(
[string] $test
)
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$a, $b = (Get-FileHash -A 'SHA1' -I ([IO.MemoryStream]::new([Text.Encoding]::UTF8.GetBytes($test)))).Hash -split '(?<=^.{5})'
(((Invoke-RestMethod "https://api.pwnedpasswords.com/range/$a" -UseB) -split '\r\n' -like "$b*") -split ':')[-1] |
Foreach-Object {
Write-Host -ForegroundColor Green "This has been publically cracked $_ times according to api.pwnedpasswords.com"
@JoeyBurzynski
JoeyBurzynski / 55-bytes-of-css.md
Last active April 8, 2025 14:18
58 bytes of css to look great nearly everywhere

58 bytes of CSS to look great nearly everywhere

When making this website, i wanted a simple, reasonable way to make it look good on most displays. Not counting any minimization techniques, the following 58 bytes worked well for me:

main {
  max-width: 38rem;
  padding: 2rem;
  margin: auto;
}
@isopropylcyanide
isopropylcyanide / flink-cancel-all.sh
Created November 2, 2018 07:56
This bash script cancels all the Flink jobs that are submitted to the cluster sequentially.
@fud
fud / replay.py
Created October 24, 2018 02:14
Replay messages from a dead letter queue into main queue. Python + boto3
#!/usr/bin/env python
import boto3
import sys
import json
import time
import argparse
from termcolor import cprint
@rybak
rybak / ps1_notifications-2018-08.sh
Last active September 30, 2024 15:16
PS1 setup with sad smiley for process failure and dangerous bend symbol for README files
#!/bin/bash
# Cleaned up version of ps1_notifications.sh made on 2018-08-05
#
# See rybak/scriptps github repository for the full version
# link: https://github.com/rybak/scripts/blob/master/config/ps1_notifications.sh
# copy of lib/colors.sh instead of calling source "$HOME/scripts/lib/colors.sh"
BLACK_FG="$(tput setaf 0)"
@silent1mezzo
silent1mezzo / fabfile-symlink.py
Created January 4, 2018 21:46
An example deployment using Fabric and Symlinks
@guettli
guettli / [email protected]
Created December 22, 2017 11:40
Reliable persistent SSH-Tunnel via systemd (not autossh)
# Reliable persistent SSH-Tunnel via systemd (not autossh)
# https://gist.github.com/guettli/31242c61f00e365bbf5ed08d09cdc006#file-ssh-tunnel-service
[Unit]
Description=Tunnel for %i
After=network.target
[Service]
User=tunnel
ExecStart=/usr/bin/ssh -o "ExitOnForwardFailure yes" -o "ServerAliveInterval 60" -N tunnel@%i