Skip to content

Instantly share code, notes, and snippets.

# -*- coding: utf-8 -*-
# Works on the `output.xml` generated by running `pdf2txt.py -o output.xml FILE`,
# where FILE is the programme of Science Festival in Warsaw in PDF.
#
# Required libraries:
#
# * vobject <http://vobject.skyhouseconsulting.com/>
# * lxml <http://codespeak.net/lxml/>
#
# Script `pdf2txt.py` is part of package PDFMiner <http://www.unixuser.org/~euske/python/pdfminer/index.html>.
# Required libraries:
#
# * vobject <http://vobject.skyhouseconsulting.com/>
#
# Copyright (C) 2011 Marek Stepniowski <marek@stepniowski.com>
#
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
@mstepniowski
mstepniowski / wyprawy.pro
Last active September 25, 2015 22:48
Trip planner in Prolog
%#!/usr/bin/env swipl -q -g main -s
%
% ^ Uncomment the line above and make this file executable
% to turn it into a valid SWI Prolog script
%
% (c) Marek Stepniowski, 222149 <marek@stepniowski.com>
:- dynamic edge/5.
% -----------------------
% Application entry point
@mstepniowski
mstepniowski / javascript.el
Created June 17, 2011 13:30
node-jslint configuration for flymake
(require 'flymake)
(defun flymake-jslint-init ()
(let* ((temp-file (flymake-init-create-temp-buffer-copy
'flymake-create-temp-inplace))
(local-file (file-relative-name
temp-file
(file-name-directory buffer-file-name))))
;; Change it to path of the jslint.js executable file on your system
(list "/Users/zuber/node_modules/jslint/bin/jslint.js" (list local-file))))
@mstepniowski
mstepniowski / fullscreen-lion.diff
Created July 20, 2011 22:19
Add Lion-based fullscreen mode to Emacs 24
diff --git a/lisp/term/ns-win.el b/lisp/term/ns-win.el
index 447d7fd..27bba4a 100644
--- a/lisp/term/ns-win.el
+++ b/lisp/term/ns-win.el
@@ -929,6 +929,11 @@ See the documentation of `create-fontset-from-fontset-spec' for the format.")
(add-to-list 'window-system-initialization-alist '(ns . ns-initialize-window-system))
+(declare-function ns-toggle-fullscreen-internal "nsfns.m" ())
+(defun ns-toggle-fullscreen ()
@mstepniowski
mstepniowski / getReversed.js
Created July 30, 2011 13:05
getReversed - A solution to one of the problems on meet.js Warsaw
function getReversed (str) {
var i, idx, result = [];
for (i = 0; i < str.length; ++i) {
idx = (i % 2) ? (str.length - Math.ceil((i + 1) / 2)) : Math.ceil(i / 2);
result.push(str[idx]);
}
return result.join('');
}
@mstepniowski
mstepniowski / letterpress.py
Created October 28, 2012 10:34
Python helps you play Letterpress
"""
Python helps you play `Letterpress <http://www.atebits.com/letterpress/>`_.
Requires `NLTK library <http://nltk.org/>`_ and cmudict corpus.
You can install the latter by executing the following two lines in Python shell:
>>> import nltk
>>> nltk.download()
I'd consider it cheating, though!
@mstepniowski
mstepniowski / results.txt
Last active December 10, 2015 22:31
Script showing top 25 talk proposals for DjangoCon Europe 2013
# 25 best talk proposals as of Saturday, 19th of January at 11:59 PM UTC
# ----------------------------------------------------------------------
# Calculated by votes.py from 15383 votes of 790 people.
1. (411) Asynchronous code in Django.
2. (398) How to combine JavaScript & Django in a smart way
3. (375) Website security in Django
4. (364) Advanced PostgreSQL in Django
5. (359) Designing a good API: Lessons Learned
6. (344) Let’s bankrupt Heroku: make your Django run fast
@mstepniowski
mstepniowski / adventure.py
Created January 20, 2013 00:32
My little Python helper for http://adventure.cueup.com/
#########
# LEVEL 1
#########
RANDOM_SEQ = [6, 19, 16]
def vax_mth_random(seed):
"""VAX's MTH$RANDOM is a linear congruential generator.
@mstepniowski
mstepniowski / _hackercup_2013_qualifications.rst
Last active April 23, 2020 21:51
Solutions to Facebook Hacker Cup 2013 Qualification Round problems (in Python)

Beautiful strings

When John was a little kid he didn't have much to do. There was no internet, no Facebook, and no programs to hack on. So he did the only thing he could... he evaluated the beauty of strings in a quest to discover the most beautiful string in the world.

Given a string s, little Johnny defined the beauty of the string as the sum of the beauty of the letters in it.

The beauty of each letter is an integer between 1 and 26, inclusive, and no two letters have the same beauty. Johnny doesn't care about whether letters are uppercase or lowercase, so that doesn't affect the beauty of a letter. (Uppercase 'F' is exactly as beautiful as lowercase 'f', for example.)

You're a student writing a report on the youth of this famous hacker. You found the string that Johnny considered most beautiful. What is the maximum possible beauty of this string?