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 / Celeste Dark.sublime-color-scheme
Last active February 16, 2024 03:27
Celeste Dark Sublime Text Theme
{
// Rough modified version of Celeste to darken it up
"name": "Celeste Dark",
"author": "Sublime HQ Pty Ltd",
"variables":
{
// These colors are part of the hashed range
// and should only be used in non-source
"purple": "hsla(260, 50%, 70%, 1)",
"blue": "hsla(200, 70%, 55%, 1)",
@Alanaktion
Alanaktion / compton.conf
Last active June 28, 2021 18:24
Compton configuration
#################################
#
# Backend
#
#################################
# Backend to use: "xrender" or "glx".
# GLX backend is typically much faster but depends on a sane driver.
backend = "glx";
@Alanaktion
Alanaktion / pacman.md
Last active April 21, 2020 14:49
Useful pacman commands and packages

Basic usage

pacman -S <package> # Install a package
pacman -Sy # Update package list
pacman -Su # Update installed packages
pacman -Ss <query> # Search packages
pacman -R <package> # Remove a package
pacman -Rs <package> # Remove a package and it's unneeded dependencies
@Alanaktion
Alanaktion / .gitconfig
Last active September 16, 2019 15:04
Global Git config
[user]
name = Alan Hardman
email = alanaktion@gmail.com
signingkey = 27A79A65774B4AF0
[push]
default = simple
[alias]
ignored = !git ls-files -v | grep ^[[:lower:]]
sync = !sh -c 'git pull --no-edit && git push'
st = status
@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 / timing-attack.php
Last active June 12, 2018 23:00
Silly timing attack POC in PHP
<?php
$iterations = 1e4;
$valid = 'password';
$stored_hash = md5($valid);
$test = $arvg[1] ?? 'notvalid';
echo "$iterations iterations\n";
// Run tests
$v_start = microtime(true);
@Alanaktion
Alanaktion / blur.php
Last active June 8, 2018 20:27
Messing with basic blurs in PHP
<?php
/**
* Output a map
*
* @param array $map
* @param bool $int Round output to integer values
*/
function out(array $map, $int = true) {
foreach($map as $r) {
@Alanaktion
Alanaktion / README.md
Created April 16, 2018 14:12
Pacman hooks to keep kernel modules

These Pacman hooks can be used to keep old kernel modules active without rebooting. This can work around issues like new USB devices and Docker images not working properly after a kernel upgrade, but before a reboot.

Add the files to /etc/pacman.d/hooks to enable the functionality. It works by making a backup of your current kernel's /lib/modules/... directory before the new kernel is installed, and then moving it back to the /lib/modules directory after the installation completes, working around the default behavior of deleting the old modules.

You can manually clean up the files after a reboot if you're concerned about the disk space used.

@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 / magento_url_rewrite.patch
Last active December 5, 2017 18:07 — forked from edannenberg/magento_url_rewrite.patch
Fixes the catalog url rewrite indexer in Magento 1.7.x-1.9.x
diff -rupN mage_org/app/code/core/Mage/Catalog/Model/Url.php src_shop/app/code/core/Mage/Catalog/Model/Url.php
--- mage_org/app/code/core/Mage/Catalog/Model/Url.php 2013-11-19 00:48:25.679009391 +0100
+++ src_shop/app/code/core/Mage/Catalog/Model/Url.php 2013-11-19 00:49:24.188005601 +0100
@@ -643,13 +643,24 @@ class Mage_Catalog_Model_Url
$this->_rewrite = $rewrite;
return $requestPath;
}
+
+ // avoid unnecessary creation of new url_keys for duplicate url keys
+ $noSuffixPath = substr($requestPath, 0, -(strlen($suffix)));