Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am wpettersson on github.
  • I am wpettersson (https://keybase.io/wpettersson) on keybase.
  • I have a public key whose fingerprint is D77F 0853 D6A4 EE71 02A3 9D46 F785 6D2B 0911 E367

To claim this, I am signing this object:

@WPettersson
WPettersson / highs-tester.py
Created March 4, 2024 16:01
Testing HiGHS in pulp
import pulp
import highspy
import numpy as np
prob = pulp.LpProblem("hi")
x = pulp.LpVariable("x", 0, 3)
y = pulp.LpVariable("y", 0, 3)
prob += x + y
prob += x <= y
@WPettersson
WPettersson / regina.patch
Created March 9, 2022 15:57
(Don't apply!) fixing compilation issue with Regina
diff -Naur regina-normal-regina-95b1a26/engine/enumerate/hilbertprimal-impl.h regina-new/engine/enumerate/hilbertprimal-impl.h
--- regina-normal-regina-95b1a26/engine/enumerate/hilbertprimal-impl.h 2021-12-18 09:27:19.000000000 +0000
+++ regina-new/engine/enumerate/hilbertprimal-impl.h 2022-03-09 15:49:24.924398783 +0000
@@ -47,7 +47,6 @@
#include "enumerate/hilbertprimal.h"
#include "enumerate/maxadmissible.h"
#include "enumerate/validityconstraints.h"
-#include "libnormaliz/cone.h"
#include "maths/vector.h"
#include "progress/progresstracker.h"
@WPettersson
WPettersson / heating.yaml
Last active November 2, 2021 22:08 — forked from miguelcouteirorodrigues/heating.yaml
Home Assistant Blueprint For Heating
blueprint:
name: Heating Control
description: Control your heating with options for person home, if temp is below a specific value, set temp, and heating between specific times.
domain: automation
input:
heating:
name: Climate Device
description: The climate device to use.
selector:
entity:
#!/home/enigma/.virtualenvs/gpx_clean/bin/python
import datetime
import os
import os.path
import sys
import numpy as np
import gpxpy
@WPettersson
WPettersson / 10-xppen.hwdb
Created December 22, 2020 12:13
hwdb entry for my Deco 1 V2
evdev:input:b*v28BDp0905*
KEYBOARD_KEY_d0045=332
KEYBOARD_KEY_700e0=fn
KEYBOARD_KEY_700e2=fn
KEYBOARD_KEY_70015=prog1
KEYBOARD_KEY_70018=prog2
KEYBOARD_KEY_7001c=prog3
KEYBOARD_KEY_7003c=prog4
KEYBOARD_KEY_7002d=f14
KEYBOARD_KEY_70026=f15
diff --git a/splatmoji b/splatmoji
index f795bd3..4cf0e85 100755
--- a/splatmoji
+++ b/splatmoji
@@ -39,11 +39,13 @@ main() {
# Determine history file, and create if not exists and history length > 0
local history_file
if [ -n "${config['history_file']}" ] && [ "${config['history_length']}" -gt 0 ]; then
+ echo "Getting history_file from config as \"${config['history_file']}\"" 1>&2
history_file="${config['history_file']}"
@WPettersson
WPettersson / mv_xopp_pdf_here.sh
Created July 8, 2020 08:37
Takes a Xournalpp xopp file, finds the embedded PDF location, copies the embedded pdf to `pwd`, and updates the xopp file
#!/bin/bash
set -e
XOPP_RAW=$(mktemp)
gunzip -c "$1" > ${XOPP_RAW}
PDF_LOC=$(awk -F\" '/domain="absolute" filename/ {print $6}' ${XOPP_RAW})
cp ${PDF_LOC} .
NEW_LOC="$(pwd)/$(basename ${PDF_LOC})"
echo ${NEW_LOC}
import got
with open("my_file.txt", "w") as myfile:
tweetCriteria = got.manager.TweetCriteria().setUsername('barackobama').setMaxTweets(10)
for tweet in got.manager.TweetManager.getTweets(tweetCriteria):
my_file.write("%s\n" % tweet.text)
my_file.write("%s\n" % tweet.date)
@WPettersson
WPettersson / brute.py
Created January 25, 2018 22:03
Brute forcing some vigenere cipher
#!/usr/bin/env python3
def main():
words = {}
with open("words", "r") as wordfile:
for line in wordfile:
if len(line.rstrip()) in [2, 3, 4, 5]:
words[line.rstrip()] = True
cipher = [[7, 16], [24, 26], [3, 8, 19, 5], [5, 24, 25, 13],