Skip to content

Instantly share code, notes, and snippets.

View Alanaktion's full-sized avatar
:shipit:
Working on too many things.

Alan Hardman Alanaktion

:shipit:
Working on too many things.
View GitHub Profile
@Alanaktion
Alanaktion / opensql-pro.desktop
Last active August 2, 2017 22:53
Desktop file for PyGObject app
[Desktop Entry]
Version=1.0
Type=Application
Name=OpenSQL Pro
Comment=A powerfully simple database client
Icon=office-database
Exec=python .
Path=/home/alan/GitHub/opensql-pro
Categories=Development;
StartupNotify=true
@Alanaktion
Alanaktion / ticker.sh
Created June 27, 2017 22:55
Cryptocurrency exchange rate ticker
#!/bin/bash
btc=$(curl -s https://api.coinbase.com/v2/prices/BTC-USD/buy | json data.amount)
eth=$(curl -s https://api.coinbase.com/v2/prices/ETH-USD/buy | json data.amount)
ltc=$(curl -s https://api.coinbase.com/v2/prices/LTC-USD/buy | json data.amount)
echo 'BTC $'$btc' ETH $'$eth' LTC $'$ltc
@Alanaktion
Alanaktion / gnome2xfce.sh
Last active June 16, 2017 20:42
Convert Antergos Gnome to Xfce (assuming gdm)
# This will convert an Antergos Gnome installation to Xfce
# GDM will be replaced with LightDM with the GTK greeter
# It keeps a few Gnome utilities around and installs Xfce4's WhiskerMenu plugin
# Don't continue on errors, since we can really screw up a system if we do
set -e
# Kill existing sessions
sudo systemctl stop gdm
@Alanaktion
Alanaktion / xfce2gnome.sh
Last active June 16, 2017 20:27
Convert Antergos Xfce installation to Gnome Shell
# This will convert an Antergos Xfce installation to Gnome
# LightDM will be replaced with GDM
# Don't continue on errors, since we can really screw up a system if we do
set -e
# Common packages
# evince
# file-roller
# gnome-calculator
@Alanaktion
Alanaktion / englike.go
Last active January 12, 2018 16:31
Generate English-like random paragraphs
package main
import (
"fmt"
"math/rand"
"strings"
"time"
)
func main() {
@Alanaktion
Alanaktion / settings.json
Created May 3, 2017 16:40
Micro editor settings
{
"autoclose": true,
"autoindent": true,
"autosave": false,
"colorcolumn": 80,
"colorscheme": "monokai",
"cursorline": true,
"eofnewline": true,
"ignorecase": false,
"indentchar": " ",
@Alanaktion
Alanaktion / arch-setup.sh
Created March 7, 2017 23:56
Antergos Xfce setup
#!/bin/bash
# This script is meant to be run on a fresh install of Antergos with Xfce
function prompt() {
echo -n "$1 [y/n] "
read prompt_response
if [ $prompt_response == 'y' ]; then
return 0
else
return 1
@Alanaktion
Alanaktion / blurImg.php
Created December 15, 2016 23:33
Updated blur.php for PHP's gd library with full RGB
<?php
/**
* Blur values in both directions
* @param resource $src
* @param integer $radius
* @return resource
*/
function blur($src, $radius) {
return bVert(bHoriz($src, $radius), $radius);
@Alanaktion
Alanaktion / linkReplace.js
Last active September 17, 2018 12:02
Replace URLs with links via JS
/**
* Replace URLs with hyperlinks in an element
*
* @param {string} selector
* @return {void}
*/
var linkReplace = function(selector) {
var element = document.querySelector(selector);
var text = element.innerHTML;
text = text.replace(/(https?:\/\/|www\.)[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)/g, function(match) {
@Alanaktion
Alanaktion / markov.php
Last active October 17, 2017 03:28
Generate pseudo-random phrases from Markov chains
#!/usr/bin/env php
<?php
if (empty($argv[1]) || $argv[1] == '-h') {
exit ("Usage: markov <input file> [words] [prefix] [minWords]\n");
}
$text = file_get_contents($argv[1]);
$map = map($text);
$words = $argv[2] ?? 20;
$minWords = $argv[4] ?? 10;