Skip to content

Instantly share code, notes, and snippets.

Chris Warrick Kwpolska

Block or report user

Report or block Kwpolska

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View babel_locale_tester.py
#!/usr/bin/env python3
from __future__ import print_function
import sys
import datetime
try:
import babel.dates
except ImportError:
print("Failed to import Babel. Did you run `pip install Babel`?")
sys.exit(1)
@Kwpolska
Kwpolska / # macvim - 2018-04-16_21-57-32.txt
Created Apr 16, 2018
macvim on macOS 10.13.4 - Homebrew build logs
View # macvim - 2018-04-16_21-57-32.txt
Homebrew build logs for macvim on macOS 10.13.4
Build date: 2018-04-16 21:57:32
View socket_in_use.py
import socket
s1 = socket.socket()
s2 = socket.socket()
s1.bind(('0.0.0.0', 1234))
s2.bind(('0.0.0.0', 1234))
# Traceback (most recent call last):
# File "socket_in_use.py", line 4, in <module>
# s1.bind(('0.0.0.0', 1234))
# OSError: [Errno 48] Address already in use
@Kwpolska
Kwpolska / 01_WRITEUP.md
Created Sep 21, 2017
Gynvael’s Mission 15 (en): a writeup by Chris Warrick
View 01_WRITEUP.md

Gynvael’s Mission 15 (en): A writeup by Chris Warrick

(Spoilers ahead!)

the chart

I started solving the mission by opening the chart with GIMP and measuring the first few lines. I found out that the first red bars are:

 60 63 112 104 112 10 10
@Kwpolska
Kwpolska / sep_unique.py
Created Aug 30, 2017
Split dict of lists into dict of values
View sep_unique.py
def sep_unique(d):
newdict = {}
for key, val in d.items():
if len(val) > 1:
for n, i in enumerate(val, 1):
newdict[key if n == 1 else f"{key}{i}"] = i
else:
newdict[key] = val[0]
return newdict
@Kwpolska
Kwpolska / line-continuation.py
Last active Jul 15, 2017
PEP8-compatible line continuation
View line-continuation.py
if 1 == 1:
pass
elif 1 == 1 or \
1 == 2: # backslash continuation is very ugly
pass
elif (1 == 1 or # parentheses work better
1 == 2):
pass
elif (1 == 1 or # and they look best with 8 spaces
1 == 2):
View memorywastetest.c
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include <sys/resource.h>
#define MSIZE 10000
int main() {
int* a[MSIZE];
struct rusage usage;
View typing-union.py
from typing import Dict, Union, NewType
Foo = NewType("Foo", str)
Bar = NewType("Bar", int)
def get_data() -> Dict[str, Union[Foo, Bar]]:
return {"foo": Foo("one"), "bar": Bar(2)}
def process(foo_value: Foo, bar_value: Bar) -> None:
pass
@Kwpolska
Kwpolska / ext4-unusable.py
Created Jun 6, 2017
ext4 is currently unusable with most non-English languages
View ext4-unusable.py
# https://eclecticlight.co/2017/04/06/apfs-is-currently-unusable-with-most-non-english-languages/
# ↑ is bullshit
In [1]: e = 'é'
In [2]: len(e)
Out[2]: 1
In [3]: import unicodedata
View ask_int.py
def ask_int(question):
"""Ask a question and return an integer."""
while True:
try:
return int(input(question))
except ValueError:
print("Not a number, please try again.")
You can’t perform that action at this time.