Skip to content

Instantly share code, notes, and snippets.

View VictorWesterlund's full-sized avatar
🐧
Noot noot

Victor Westerlund VictorWesterlund

🐧
Noot noot
View GitHub Profile
import json
import os
from pathlib import Path
ALBUM_DIR = ""
def add_to_album(file, root, album):
album = bytes(album, "utf-8").decode("unicode-escape")
album_path = f"{ALBUM_DIR}/{album}"
@VictorWesterlund
VictorWesterlund / manifester.py
Created November 7, 2021 09:26
Script used to generate the template Monkeydo manifest for VictorWesterlund/still-alive
import json
# Create a Monkeydo-compatible JSON
def compile(tasks,name):
manifest = {
"tasks": tasks
}
with open(f"../still-alive/monkeydo_{name}.json","w") as f:
json.dump(manifest,f)
@VictorWesterlund
VictorWesterlund / csv-to-mysql.php
Last active October 15, 2021 08:16
Import a large CSV file to MySQL table
<?php
// Quick n' dirty script to import a CSV to MySQL
// -- BEGIN CONFIG --
$file = ""; // Path to CSV file
$host = "";
$user = "";
$pass = "";
// Hacky code to display a license box for the product SIGN-I09 on deltaco.se/deltaco.fi
window.addEventListener("AsyncAppReady",() => {
if(av && av.page == "lgt-121" && av.auth) {
const l = {
"se": [
"ctl00_SPWebPartManager1_g_dbe96560_9460_4c5c_ad2f_ae3be3f25708_csr1_Itemtabs-1",
"<div style=\"display: flex;align-items: center;padding: 15px;background: #f1f1f1;border-radius: 6px;margin-bottom: 10px;\"><p style=\"margin: 0;margin-left: 5px;\">Vid köp behöver du ansöka om licensnycklar</p><a href=\"https://forms.office.com/Pages/ResponsePage.aspx?id=3IWmeTfPJkWZkKhVmPw6-NOVGN1I1iZGmkmpsV2rzkJUNkRCMTYwUDRDTjhIUEFYVlg0RU9MSDBJRiQlQCN0PWcu\" target=\"_blank\" style=\"display: contents;\"><img src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIwAAAAoCAYAAAAsTRLGAAAGXklEQVR4nO2cfUyVVRzHv5iICZmkaSA5xasiim/hTXGiNF2C5mpay6yVaa3Ymmtu2ab1R8NN3Fp/tFmZzFm+bK3WkoTZWhosMTXREjBF8IUkTQJUFF+K9j2cc3nuvefe59G4INzz2Z7dc5+X+5zf73zP7/ye8zz3iYAP67HKd5UvPQDMADAXwBQALgCxAHrZHWi4a7gJ4G8AlQD2ASgAsAfAv8EqmI016HkbFnDflwG
@VictorWesterlund
VictorWesterlund / craps.py
Created February 8, 2021 16:18
Python Craps
# https://colab.research.google.com/drive/1TOeASp1DeDlkNxEqpgnK3Rf8_q495GD9?usp=sharing
# Craps is a dice game usually found at casinos. This python script tries to generate
# the largest possible sequence of psudo-random dice rolls before "sevening out".
# The world record is currently held by Patricia Demauro, with a score of 154.
import random
from functools import reduce
longest = 0
@VictorWesterlund
VictorWesterlund / cga-palette.css
Created February 3, 2021 00:41
Full CGA 16-color palette in CSS
.cga-palette {
/* low intensity */
--black: #000000;
--blue: #0000AA;
--green: #00AA00;
--cyan: #00AAAA;
--red: #AA0000;
--magenta: #AA00AA;
--brown: #AA5500;
--light-gray: #AAAAAA;
@VictorWesterlund
VictorWesterlund / Code.gs
Last active February 3, 2021 00:45
Create Dynamics AX compatible spreadsheet from Akeneo PIM export
// Convert Akeneo Excel to AX Import
// <p>
function AXFORMAT_PARAGRAPH(input) {
function wrap(value) {
return `<p>${value}</p>`;
}
return Array.isArray(input) ? input.map(row => row.map(cell => {
if(!cell) {
@VictorWesterlund
VictorWesterlund / crtjs_sample.py
Last active January 26, 2021 00:31
Generate a signed HEX video tape for crtjs using random RGB values
import random
def rand():
dec = random.randint(0,255)
tohex = str(hex(dec).split("x")[-1])
if(dec < 16):
tohex = "0" + tohex
return tohex
@VictorWesterlund
VictorWesterlund / waybackup.py
Last active January 27, 2021 05:22 — forked from wcaleb/waybackup.py
Quick script to save URL to Wayback Machine with Python 3
#!/usr/bin/python3
import sys, requests
# Usage: Pass URL to script, get back URL to Wayback Machine snapshot
base_url = 'http://web.archive.org'
try:
r = requests.get(f"{base_url}/save/{sys.argv[1]}")
@VictorWesterlund
VictorWesterlund / labylib-christmas.py
Last active December 2, 2020 09:26
Christmas cape image sequencer for LabyMod
import time
from labylib import Cape
cookie = input("Paste your PHPSESSID here:\n")
vis = Cape.Visibility(cookie)
temp = Cape.Template(cookie)
i = False