Skip to content

Instantly share code, notes, and snippets.

View hlfbt's full-sized avatar
🤔

Alexander Schulz hlfbt

🤔
View GitHub Profile
@hlfbt
hlfbt / pythoneval.py
Created January 21, 2012 20:16 — forked from kylef/pyeval.py
Python Evaluate for ZNC modpython
# pythoneval.py
import sys
import re
from code import InteractiveInterpreter
import znc
class pythoneval(znc.Module, InteractiveInterpreter):
# module_types makes it unable to load
@hlfbt
hlfbt / n2dissite.sh
Created February 6, 2012 04:08
Nginx-to-ensite and Nginx-to-dissite - Two simple scripts that enable and disable Nginxs virtualhost VHOST. Adapt VHOSTEN and VHOSTAV accordingly, place in /usr/sbin and enjoy.
#!/bin/bash
# Author: Alexander Schulz
VHOSTEN="/etc/nginx/sites-enabled/"
if [[ $1 == "-h" ]] || [[ $1 == "--help" ]]
then
echo 'Usage: n2dissite VHOST'
echo 'Disables Nginxs virtualhost VHOST.'
@hlfbt
hlfbt / ab_notifications.beta.user.js
Last active May 1, 2017 00:37
Shows toasty notifications for various things on AnimeBytes! See the comments for screenshots!
// ==UserScript==
// @name AnimeBytes Notifications
// @author potatoe
// @version 2.6.3.X.4.11
// @description AnimeBytes SUPER Notifications! super! s-...super..? || Shows toasty notifications for various things!
// @icon https://animebytes.tv/favicon.ico
// @include https://animebytes.tv/*
// @match https://animebytes.tv/*
// @downloadURL https://ab.nope.bz/userscripts/notifications/ab_notifications.beta.user.js
// @updateURL https://ab.nope.bz/userscripts/notifications/ab_notifications.beta.user.js
@hlfbt
hlfbt / select.js
Last active September 7, 2016 12:07
A stupid simple framework just like jquery that mainly grew out of procrastination. I use this wherever the jquery way is much more elegant/easier but there is no jquery available (i.e. in a userscript before the page completely loaded). May be expanded every now and then as I deem fit.
/*/
* This simulates JQuery's constructor functionality as best as easiest possible
* Some minor things that I never really use (like calling select() without arguments,
* or some ambiguous css paths not being interpreted by querySelectorAll correctly)
* might not really work, but I personally don't see much need to make it more complicated
* to work around them currently.
/*/
var select = function (s, c) {
if (!c || c == null)
c = document;
@hlfbt
hlfbt / cache.js
Last active August 29, 2015 14:19
A simple cache for javascript. Useful to have a simple interface to share variables over between pageloads.
function Cache () {
"use strict";
if (this.constructor != Cache) throw new TypeError("Constructor Cache requires 'new'");
/*
A dumb, simple cache, to make access to cross-pageload variables easy and manageable.
All cache times are in milliseconds.
*/
var storage = window['localStorage'];
@hlfbt
hlfbt / twig-repl.php
Last active September 21, 2016 15:11 — forked from arnaud-lb/twig-repl.php
Twig REPL
<?php
/**
* Twig REPL hack
*
* Arnaud Le Blanc <arnaud.lb@gmail.com>
*/
require 'vendor/twig/twig/lib/Twig/Autoloader.php';
Twig_Autoloader::register();
@hlfbt
hlfbt / object_search.js
Last active February 22, 2017 15:28
Searches through an object for an identifier
/*
* Recurses through an object to search for an identifier.
* Identifier is a RegExp.
* Returns either the first match or false.
*/
function search (obj, term) {
for (var k in obj) {
if (obj.hasOwnProperty(k)) {
if (k == term) return k;
@hlfbt
hlfbt / objectify.js
Last active February 5, 2018 13:57
Generic object class construction
/**
* GenericObject / objectify.js
*
* Creating new objects with neat setters and getters over again is annoying, so let's automate it.
*
* @author Alexander Schulz (alex@nope.bz)
*/
var Objectify = (function () {
"use strict";
@hlfbt
hlfbt / guid.js
Created September 16, 2018 17:31
Generate random GUIDs usable as element IDs (first character is always a letter)
(function () {
var S4 = function (n, d) {
return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1) + (n > 1 ? (d || '') + S4(n - 1, d) : '');
};
return (String.fromCharCode(97 + Math.floor(Math.random() * 26)) + S4().substring(1) + S4(5, '-') + S4(2));
})();
@hlfbt
hlfbt / amazon_total_tally.js
Created October 14, 2018 00:48
Does a tally of amount spent, orders and items ordered on amazon. To be executed on any amazon order history page.
function fetchPage(link, callback) {
var xhr = new XMLHttpRequest();
xhr.open('get', link);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == 200)
callback.call(xhr, xhr);
};
xhr.send();