Skip to content

Instantly share code, notes, and snippets.

View Kwpolska's full-sized avatar

Chris Warrick Kwpolska

View GitHub Profile
@Kwpolska
Kwpolska / TOTAL.txt
Created January 6, 2016 11:29
Maximum possible Tweets
Number of possible Tweets:
2868513354526138351407402564945861731731005186915717589769254397463276683163203298522386175435067066958792271327488714432896971981518848067815802826764578314176430719164231725446781228542281846835921140900372515606054742528858870652271191584206494744035508367793906549616020382152196971997218356669597217304785341643872919850147115150287191515516258324927271095740742828344182312891311419924845191353438901845576928588390406061209794329185459076476633533391875230899849872522641042982005901047456653310879377771596590664307804353344139947817581001647557030360134924469462262860594238258098296605294032355050337489605964714267595439011340999725517693896868930623459726044836784152715489100756831103245348481274700
186.00 KiB
205.00 KiB
5.49 MiB
5.47 MiB
631.00 KiB
634.00 KiB
6328.00 KiB
167.00 KiB
12.73 MiB
999.00 KiB
@Kwpolska
Kwpolska / -
Created December 23, 2015 17:21
def parse_sc(data):
"""Parse shortcode arguments into a tuple.
>>> import pprint
>>> pprint.pprint(parse_sc('hello world Nikola abc=def foo="bar baz" backslashes=work\\ too'))
('hello',
(['world', 'Nikola'],
{'abc': 'def', 'backslashes': 'work too', 'foo': 'bar baz'}))
"""
elements = data.split(' ', 1)
import datetime
fweekdays = {}
for i in range(1, 8):
d = datetime.datetime(2015, 9, i)
fweekdays[d.weekday()] = d
dates = {}
for weekday, d in fweekdays.items():
dates[weekday] = []
while d <= datetime.datetime.now():
@Kwpolska
Kwpolska / pylint.txt
Created December 17, 2015 15:38
pylint misadventures
Messages
--------
+-------------------------------+------------+
|message id |occurrences |
+===============================+============+
|invalid-name |449 | Complaints about Python 2 compatibility names or one-letter variables (in loops). Useless.
+-------------------------------+------------+
|line-too-long |402 | We do not adhere to this.
+-------------------------------+------------+
************* Module nikola.utils
E: 62, 0: No name 'HtmlFormatter' in module 'pygments.formatters' (no-name-in-module)
E: 98,18: Undefined variable 'unicode' (undefined-variable)
E: 99,14: Undefined variable 'reload' (undefined-variable)
E:515, 4: An attribute defined in json.encoder line 159 hides this method (method-hidden)
E:1181,21: Module 'calendar' has no 'TimeEncoding' member (no-member)
E:1248, 4: Explicit return in __init__ (return-in-init)
E:1396,54: Class 'ns' has no 'F' member (no-member)
E:1396,69: Class 'ns' has no 'IC' member (no-member)
E:1862, 8: function already defined line 1853 (function-redefined)
@Kwpolska
Kwpolska / idna-punycode.pycon
Created December 10, 2015 19:11
IDNA vs Punycode
Python 3.5.1 (default, Dec 7 2015, 12:58:09)
Type "copyright", "credits" or "license" for more information.
IPython 4.0.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
In [1]: 'ąbc.pl'.encode('punycode')
import glob
import os
import jinja2
env = jinja2.Environment(loader=jinja2.FileSystemLoader('.'))
for f in glob.glob('*.jinja2'):
t = env.get_template(f)
newf = os.path.splitext(f)[0] + '.yaml'
with open(newf, 'w') as fh:
foo, bar = 7
if (foo + 1 >=
bar):
print("hello")
@Kwpolska
Kwpolska / calculator.md
Created October 4, 2015 09:18
Calculator-based Python learning plan

Calculator-based Python learning plan

(Python 3: replace raw_input() with input())

Step 1

1st number: 7
2nd number: 3
Operation (+-*/%): +

7 + 3 = 10