Skip to content

Instantly share code, notes, and snippets.

@magks
magks / scrollListItems.js
Created February 22, 2024 12:41
Auto Scroll Upward or Downward Through HTML list items children of some element (E.g. Discord web app DM chat)
const ScrollDirection = {
UP: 'UP',
DOWN: 'DOWN'
};
function scrollListItems(elementSelector, scrollDirection) {
let parentElement = document.querySelector(elementSelector);
if (parentElement) {
let listItems = parentElement.querySelectorAll('li');
@magks
magks / gist:f0a566caba74fd08036a94f90b6f67a1
Created October 2, 2023 07:01
curl unescape percent encoded characters before writing file
Hi Daniel, I saw this comment thread and added the feature to decode the filename before writing similar to wget's behavior. Thus option -W seemed fitting and was available.
so it can be used exactly like -O and -J:
`curl -W https://www.example.com/new%20pricing.htm`
> 'new pricing.htm'
curl -WJ http://test.greenbytes.de/tech/tc2231/attwithfnrawpctenca.asis
> foo-A.html
@magks
magks / minimalAI.py
Created November 2, 2018 04:46
minimal ai scores -10 on average
from Agent import Agent
from collections import deque
from enum import Enum
class MyAI ( Agent ):
class Action (Enum):
CHECK_FOR_GOLD = 1
#include "String.h"
struct ListNode
{
char* info;
ListNode * next;
ListNode( char *newInfo, ListNode * newNext )
: info(newInfo), next( newNext )
{
String file contents
@magks
magks / .Xmodmap
Created April 25, 2018 06:38
This .Xmodmap dotfile switches maps capslock key to be escape and <shift>+<esc> to be caps_lock <esc> is still escape.
keycode 8 =
!keycode 9 = Escape NoSymbol Escape
keycode 10 = 1 exclam 1 exclam exclamdown onesuperior
keycode 11 = 2 at 2 at masculine twosuperior
keycode 12 = 3 numbersign 3 numbersign ordfeminine threesuperior
keycode 13 = 4 dollar 4 dollar cent sterling
keycode 14 = 5 percent 5 percent EuroSign yen
keycode 15 = 6 asciicircum 6 asciicircum hstroke Hstroke
keycode 16 = 7 ampersand 7 ampersand eth ETH
keycode 17 = 8 asterisk 8 asterisk thorn THORN
wget https://www.python.org/ftp/python/3.4.5/Python-3.4.5.tgz
tar -zxvf Python-3.4.5.tgz
cd Python-3.4.5/
./configure --with-pydebug --prefix=/home/<USERNAME>/<LOCALPROGRAMDIR>
make altinstall -s -j<CPU_CORES--CHECK_WITH_NPROC_TO_SEE_HOW_MANY_YOU_HAVE>
ln -s /home/USERNAME/<LOCALPROGRAMDIR>/python3.4 /home/USERNAME/<LOCALPROGRAMDIR>/python3
# DONE -- make sure your path looks in /home/<USERNAME>/<LOCALPROGRAMDIR> first
# e.g. echo "export PATH=/home/<USERNAME>/<LOCALPROGRAMDIR>:$PATH" >> ~/bash_profile
# followed by source ~/bash_profile
@magks
magks / wallfix.py
Last active July 24, 2016 10:58 — forked from coleifer/wallfix.py
automatically resizes and crops an image to make it suitable for use as a wallpaper. -- written by @coleifer
#!/usr/bin/env python
import os
import re
import sys
from PIL import Image
HOME = os.environ['HOME']