Skip to content

Instantly share code, notes, and snippets.

View ScoreUnder's full-sized avatar

score ScoreUnder

View GitHub Profile
@ScoreUnder
ScoreUnder / bad-pythons.sh
Created June 26, 2023 06:18
Find bad Python AUR packages on Arch Linux
#!/bin/sh
# Find bad Python AUR packages on Arch Linux
# Simply run the script and it should show you what needs updating
# Non-destructive. Arch Linux only. Will show incorrect results when multiple Python versions are installed side by side.
# Intended to provide tech support to people updating complex python projects from the AUR
real_python_dir=$(pacman -Ql python | grep /usr/lib/python | head -1 | cut -d/ -f-4 | cut -d' ' -f2)
set -- /usr/lib/python3.*
for d do
if [ -e "$d" ] && [ "$d" != "$real_python_dir" ]; then
set -- "$@" "$d"
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
int chday(int day, int month, int year);
int chmonth(int month);
int chyear(int year);
int leapYear(int y);
int day_of_year(int d, int m, int y);
int chday(int day, int month, int year) {
@ScoreUnder
ScoreUnder / lowstate_dep_graph.py
Created November 22, 2017 13:29
Convert salt lowstate to graphviz format
#!/usr/bin/env python3
import itertools
import yaml
import sys
class MultiDict(dict):
def add(self, key, value):
if key not in self:
self[key] = []
self[key].append(value)
@ScoreUnder
ScoreUnder / discord.js
Last active April 6, 2017 09:25 — forked from kuntau/discord.js
Hide Discordapp channel sidebar
//ref: http://andrewhfarmer.com/hide-discord-sidebar/
var cmd$ = $;
document.addEventListener('keydown', function(event) {
if (event.metaKey && event.keyCode === 220) {
// Toggle visibility of the channel and guilds columns
var channelWrap = cmd$('.flex-vertical.channels-wrap');
var guildsWrap = cmd$('.guilds-wrapper');
var titleWrap = cmd$('.title-wrap');
if (channelWrap.getAttribute('style') === 'display: none') {
channelWrap.setAttribute('style', '');
@ScoreUnder
ScoreUnder / fw.py
Last active March 28, 2017 08:43 — forked from Ravenslofty/fw.py
What is this "readability" you speak of?
for l in __import__('fileinput').input():print(*[((c,chr(ord(c)+65248))[ord(c)<127]," ")[c==" "]for c in l[:-1]],sep='')
@ScoreUnder
ScoreUnder / fw
Last active May 2, 2017 11:58
Halfwidth-to-fullwidth text converter
perl -CS -Mutf8 -pe'y/ !-~/ !-~/'
@ScoreUnder
ScoreUnder / osrs-ping.pl
Created September 26, 2016 23:29
OSRS world ping checker
@worlds = 1..94;
for (@worlds) {
# This would probably work on Windows with "-c1" changed to "-n 1"
open $pings[$_], '-|', qw/ping -c1/, "oldschool$_.runescape.com";
}
undef $/;
for (@pings[@worlds]) {
if (<$_> =~ /time=([\d.]+ ?ms)/) {
$_ = $1;
@ScoreUnder
ScoreUnder / lock.sh
Created September 22, 2016 08:24
Lock entire computer on linux with vlock
sudo openvt -s -- sh -c "sudo -u charles -- vlock -a; chvt $(fgconsole)"
@ScoreUnder
ScoreUnder / hash
Created September 19, 2016 09:08
Naive hash code functions for creating terminal colours
#!/bin/busybox sh
# Original code, slow, not sh-compatible
hashcode() {
local hash=0
local str="$1"X
while [ -n "$str" ]; do
ch="${str:0:1}"
hash=$(( ($hash * 173 + $(printf '%d' "'$ch")) % 256 ))
str="${str:1}"
done
@ScoreUnder
ScoreUnder / git-log1
Created March 9, 2016 17:35
"git log1" script
#!/bin/sh
exec git log --oneline --graph --format='%C(yellow)%h %C(bold blue)%an %C(reset)%s %C(green)%GG%C(yellow)%D' "$@"