Skip to content

Instantly share code, notes, and snippets.

Avatar

Vladimir Parfinenko cypok

View GitHub Profile
@cypok
cypok / wtf.py
Created Apr 21, 2018
Am I too old for all these dynamic stuff?..s
View wtf.py
import gettext
lang = gettext.translation("wtf")
_ = lang.gettext
print(_("Program started")) # prints translated message
def work_hard():
print(_("Working hard")) # raises UnboundLocalError: local variable '_' referenced before assignment
#
@cypok
cypok / Tree.java
Created Nov 10, 2016
IDEA inspection is not correct
View Tree.java
import java.util.Iterator;
import java.util.NoSuchElementException;
final class Tree<T> {
private final T elem;
private final Tree<T> parent;
private Tree(T elem, Tree<T> parent) {
this.elem = elem;
@cypok
cypok / bst.c
Created Oct 31, 2016
Simple BST with no copy & paste
View bst.c
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <stdbool.h>
typedef enum eChildKind {
LEFT,
RIGHT,
} ChildKind;
@cypok
cypok / merge_pdf_2on1.sh
Created Dec 9, 2015
Simple script to place two PDF pages on single page with separator
View merge_pdf_2on1.sh
if [[ -z "$1" ]]; then
echo No input file
exit
fi
input=$1
middle=`mktemp -t pdf_2on1`.pdf
if [[ -z "$2" ]]; then
name="${input%.*}"
@cypok
cypok / watch.bat
Last active Aug 29, 2015
Analog of watch (GNU command-line tool) for Windows
View watch.bat
@echo OFF
REM watch is a GNU command-line tool that runs the specified command repeatedly
REM and displays the output on stdout so you can watch it change over time.
REM By default, the command is run every two seconds, although this is adjustable with the -n secs argument.
if x%1==x (call :usage %0 %* && exit /b 1)
if x%1==x-n (
if x%2==x (call :usage %0 %* && exit /b 1)
@cypok
cypok / toggle_extension.sh
Last active Nov 14, 2016
OS X Automator service that toggles extension showing
View toggle_extension.sh
for f in "$@"
do
if [ "`GetFileInfo -ae "$f"`" == "0" ]
then
SetFile -a E "$f"
else
SetFile -a e "$f"
fi
done
@cypok
cypok / gist:bb6979fa535f3ab10874
Last active Aug 29, 2015
OpenOffice.org Calc macro ConcatenateIf: mix of CountIf and Concatenate
View gist:bb6979fa535f3ab10874
REM Usage example:
REM
REM | A | B |
REM --+-----+-----+
REM 1 | 111 | aaa |
REM 2 | 222 | bbb |
REM 3 | 222 | ccc |
REM 4 | 333 | ddd |
REM 5 | 333 | eee |
View rotating_squares.c
// Solution for http://haskell98.blogspot.ru/2014/10/blog-post_10.html
// Results at http://haskell98.blogspot.ru/2014/10/blog-post_20.html
#include <stdlib.h>
#include <stdio.h>
#include <stdbool.h>
typedef unsigned long long int bigint;
@cypok
cypok / issue.md
Last active Jan 3, 2016
Speaker Deck: lack of support for cyrillic fonts
View issue.md

The problem was fixed in less than a day after publication of this page.

The problem

Speaker Deck uses nice OpenSans font. However some characters are rendered using other fonts, e.g. cyrillic characters.

So if you mix in description both latin and cyrillic characters it looks bad. Latin characters are rendered using [lite 300 OpenSans