Skip to content

Instantly share code, notes, and snippets.

@lunarplasma
lunarplasma / CG_May.ahk
Created May 1, 2021 10:19
AHK I created to sell stuff to science and research contacts
#NoEnv
#Persistent
#UseHook
setkeydelay, 22, 50
NavigateSelect(keys)
{
Send, % keys
Send {space}
Sleep, 200
@lunarplasma
lunarplasma / password_bat.bat
Last active April 26, 2021 13:14
Batch File password
:: This batch file demonstrates how to use a powershell command to do password entry. The password entry part
:: is done as a batch file function.
:: As ever, call it with
:: CALL :Func param1, param2
@ECHO OFF
CALL :GET_PASSWORD "Enter password", PASSWORD
ECHO Password was: %PASSWORD%
EXIT /b 0
@lunarplasma
lunarplasma / getRelPath.py
Created February 21, 2020 16:03
Finding relative path using python
"""
These steps and the little bit of code below will allow you to quickly get the relative path to another directory.
PREREQUISITES:
- Python installed and accessible from the command line.
STEPS:
1. Open the command line in the path your want the result to be relative FROM.
2. Run py.exe
3. Run the code below. Replace `your_path` with the path you want to get a relative path TO.
@lunarplasma
lunarplasma / Dixit_2player_variant.md
Last active February 14, 2026 03:14
[Board Games] Dixit 2-player cooperative variant

2 Player Rules Variant for Dixit

Original sauce: Brian M https://boardgamegeek.com/thread/676496/2-player-co-op-dixit-variant

Having just picked up Dixit, Lisa and I wanted to play it right away. But there are only two of us. We would be very silly to try to play it with only two players.

We are, of course, very silly.

I can't think of a way to play competitively and still give clues, so we went for a cooperative game instead.

@lunarplasma
lunarplasma / OptionalFieldIfEqualTo.py
Created November 27, 2019 12:59
WTForms Optional Field only if another field is a certain value
# ALL CREDIT goes to dwedwards on PySlackers
class OptionalIfFieldEqualTo(Optional):
# a validator which makes a field optional if
# another field has a desired value
def __init__(self, other_field_name, value, *args, **kwargs):
self.other_field_name = other_field_name
self.value = value
super(OptionalIfFieldEqualTo, self).__init__(*args, **kwargs)
def __call__(self, form, field):
@lunarplasma
lunarplasma / Now8601.cpp
Created October 17, 2019 09:29
Get windows system time ISO8601
#include <sstream>
#include <iomanip>
#include <string>
#include <windows.h>
std::string Now8601()
{
SYSTEMTIME st;
GetSystemTime(&st);
std::stringstream formatted_date_time;
@lunarplasma
lunarplasma / get_environment_info.py
Last active September 20, 2019 10:32
Get the current Python environment info
# Credit: Cody Kochmann on PySlackers.com
import sys
for waffle in dir(sys):
syrup = getattr(sys, waffle)
if not isinstance(syrup, dict) and not callable(syrup) and not waffle.startswith('__'):
print('[{}] - {}\n'.format(waffle, syrup))
@lunarplasma
lunarplasma / getPodcasts.js
Created February 27, 2019 13:37
This script downloads all podcasts from a BBC podcasts page
// Press F12 to get the Developer Console, then paste these 3 lines into the console:
var jq = document.createElement('script');
jq.src = "https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js";
document.getElementsByTagName('head')[0].appendChild(jq);
// Next, paste these two lines in to start the download.
x = 0;
$('a[href*="download/"]').each(function(){setTimeout(_ => this.click(), x); x = x + 5000;});
/*
@lunarplasma
lunarplasma / passwordConfirm.py
Created January 15, 2019 11:35
Flask-WTF password confirmation
""" Originally by S. Dahlgren: http://sebastiandahlgren.se/2013/06/14/password-confirmation-in-wtforms/ """
class UserForm(model_form(models.User)):
""" Extend the ModelForm from MongoEngine """
password = wtf.PasswordField(
'Password',
[
wtf.validators.Length(min=2),
wtf.Required(),
wtf.EqualTo('confirm', message='Passwords must match')