Skip to content

Instantly share code, notes, and snippets.

import tkinter as tk
from tkinter import messagebox
# We can make a "virtual" game board as a list of lists. The list contains 3 other lists (rows).
# Each row list contains 3 string values representing spaces. The spaces will be populated with
# either "X" or "O", but we start with empty strings to denote an empty space.
#
# We can access a space on the board using row and column indexes. For example, the top-left space
# is `board[0][0]`, the center space is `board[1][1]`, and the bottom-right space is `board[2][2]`.
@bendavis78
bendavis78 / chromeos-recovery.md
Created December 20, 2018 04:06
Chrome OS recovery images manual download
@bendavis78
bendavis78 / capslock_super_esc.md
Last active October 25, 2023 22:11
Mapping Caps Lock to simultaneous Esc and Super (Mod4)

Mapping Caps Lock to simultaneous Esc and Super (Mod4)

The CAPS key can be mapped to an escape key when pressed once, and a super (mod4) key when used in combination with other keys.

Create the file /usr/share/X11/xkb/symbols/custom_opts with the following:

// Make Caps an additional Escape
hidden partial modifier_keys
xkb_symbols "super_esc" {

key { [ Escape ] };

class Course(models.Model):
name = models.CharField(max_length=128)
class Session(models.Model):
course = models.ForeignKey(Course)
date = models.DateField()
from datetime import datetime, timedelta
class Person:
def __init__(self, birth_date):
self.birth_date = birth_date
def get_age(self):
return (datetime.now() - self.birth_date) // timedelta(days=365.2425)
>>> class Person:
... def __init__(self, first_name, last_name):
... self.first_name = first_name
... self.last_name = last_name
...
... @property
... def full_name(self):
... return self.first_name + ' ' + self.last_name
...
>>> me = Person('Ben', 'Davis')
@bendavis78
bendavis78 / person1.py
Last active September 15, 2018 21:18
Python @Property decorator example
>>> class Person:
... def __init__(self, first_name, last_name):
... self.first_name = first_name
... self.last_name = last_name
...
... def get_full_name(self):
... return self.first_name + ' ' + self.last_name
...
>>> me = Person('Ben', 'Davis')
>>> me.get_full_name()
@bendavis78
bendavis78 / get-authorized-keys.py
Created August 31, 2018 04:27
Python script for sshd's AuthorizedKeysCommand to get pubkeys from ldap
#!/usr/bin/env python3
import ldap
import os
import pwd
import sys
HOST = 'ldap://ldap.example.com'
BASE = 'dc=example,dc=ocom'
# Set a short timeout since this should be run on localhost
TIMEOUT = 5.0