Skip to content

Instantly share code, notes, and snippets.

@kokimame
kokimame / change_tuple.py
Created September 15, 2020 16:07
Good and bad way to change tuple values
tex_strings = tuple(self.hyphenation(ts) for ts in tex_strings)
# tex_strings = list(tex_strings)
# for i, s in enumerate(tex_strings):
# tex_strings[i] = self.hyphenation(s)
# tex_strings = tuple(tex_strings)
@kokimame
kokimame / whitespaces.py
Last active May 6, 2020 22:25
Remember there are many different whitespaces. 'NARROW NO-BREAK SPACE' gave me a hard time about debugging.
# On Chrome, most of them are recognized as 'SPACE' but Python differentiates this.
chars = [
(' ', 'CHARACTER TABULATION'),
(' ','SPACE'),
(' ','NO-BREAK SPACE'),
(' ', 'CGHAM SPACE MARK'),
(' ', 'EN QUAD'),
(' ', 'EM QUAD'),
(' ','EN SPACE'),
(' ', 'EM SPACE'),
@kokimame
kokimame / pyqt5_docs.py
Created September 17, 2017 14:13
Write PyQt5 docs into PDF
import requests
import pdfkit
from bs4 import BeautifulSoup
HOME_URL = "http://pyqt.sourceforge.net/Docs/PyQt5/"
SAVE_DIR = "./pyqt5-doc/"
r = requests.get(HOME_URL)
data = r.text
@kokimame
kokimame / README.md
Created July 23, 2017 13:44
mini project to submit as HW

Smart Lighting Simulation

This simulation's goal is to make lighting provide a desirable light to each user.

Currently the optimization only uses a simple heuristic because it seems hard to apply other smart algorithms to this system.

Demo

In the demo below, the users at the desks (shown in purple rectangles) have their own request for the amount of light (illuminance; lx) on their desks, and then they all set it to 500 lx at the halfway along the demo. As the users chenge their request, 12 light sources (show in dark and bright yellow circles) adjust its luminous intensity (candela: cd) to meet the users' demand.

@kokimame
kokimame / floating.py
Created July 9, 2017 04:42
floating point arithmetic error in python
>>> 1.1 + 2.2