Skip to content

Instantly share code, notes, and snippets.

@ericbrandwein
ericbrandwein / print-slither.py
Created May 28, 2021 03:59
Print a slitherlink puzzle from puzzle-loop.com
#!/usr/bin/env python
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from sys import argv
def print_puzzle(number):
driver = webdriver.Firefox()
driver.get('https://www.puzzle-loop.com/specfic.php')
size_dropdown = driver.find_element_by_name('size')
@ericbrandwein
ericbrandwein / teg.py
Last active December 28, 2019 18:48
Script que calcula la distribución y esperanza de los ejércitos ganados en un combate de TEG
# Programa para calcular la esperanza de ganancia de países en un
# combate del TEG.
import sys
def generar_tirada(dados=1, anteriores=None, caras=6):
if not anteriores:
return [1] * dados
@ericbrandwein
ericbrandwein / cuis-launcher.py
Created December 12, 2019 20:16
A really simple launcher script for https://github.com/Cuis-Smalltalk/Cuis-Smalltalk-Dev that lets you select the image to run among the ones in the current directory.
#! /usr/bin/env python3
import os
# Change the SQUEAK_PATH if squeak is located elsewhere.
script_file_dir = os.path.dirname(os.path.abspath(__file__))
SQUEAK_PATH = '{}/../cogspur/squeak'.format(script_file_dir)
def get_image_filenames():
enum class TipoPiso { Compacto, Poroso };
class LunarRover {
Brazo brazo;
Sensor sensor;
public:
void Excavar(TipoPiso tipoPiso) const {
if (tipoPiso == TipoPiso::Compacto) {
@ericbrandwein
ericbrandwein / i3-focused-borders.py
Created June 26, 2017 19:20
Makes windows have borders only when they are focused in i3wm. Uses i3ipc-python - http://i3ipc-python.readthedocs.io/en/latest/
#!/usr/bin/env python
import i3ipc
# Create the Connection object that can be used to send commands and subscribe
# to events.
i3 = i3ipc.Connection()
def on_window_focus(self, e):
focused = i3.get_tree().find_focused()
@ericbrandwein
ericbrandwein / i3-smarttitles.py
Last active May 26, 2022 14:24
Hide or show titles in i3wm windows depending on if the Workspace has more than one window. Requires [i3ipc-python](https://github.com/acrisci/i3ipc-python) to be installed.
#!/usr/bin/env python
import i3ipc
# Create the Connection object that can be used to send commands and subscribe
# to events.
i3 = i3ipc.Connection()
def change_titles(windows):
if len(windows) > 1: