This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| """Show current wheather in Moscow, Russia in terminal and web browser. | |
| http://weather.yandex.ru | |
| http://stackoverflow.com/q/20308901 | |
| """ | |
| import xml.etree.ElementTree as etree | |
| from urllib.request import urlopen | |
| # https://github.com/emacsmirror/yandex-weather/blob/master/yandex-weather.el |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| """Start command, sleep until specified local time, send input. | |
| Bash analog: | |
| $ rm -f pipe; mkfifo pipe | |
| $ at TIMESPEC <<< 'echo -n INPUT >pipe' | |
| $ COMMAND <pipe | |
| Usage: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** Emulate `cmd1 | cmd2 | more` pipeline using recursion. | |
| http://stackoverflow.com/questions/20434124/recursive-piping-in-unix-environment | |
| */ | |
| #include <signal.h> | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <unistd.h> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| """Retrieve json using t.w.c.getPage(). | |
| http://stackoverflow.com/questions/20460352/python-json-decoder-error | |
| """ | |
| import json | |
| import sys | |
| import urllib | |
| from twisted.internet import reactor | |
| from twisted.python.util import println |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python | |
| """Print symlinks in the $PATH that point to `*.py` files.""" | |
| import os | |
| seen = set() | |
| for dirpath in os.environ.get('PATH', '').split(os.pathsep): | |
| if not os.path.isdir(dirpath): # this follows symlinks | |
| continue # visit only directories | |
| # visit "each" directory only once |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python3 | |
| """Show server's certificate as json. | |
| Usage: | |
| $ %(prog)s HOST [PORT] | |
| """ | |
| import json | |
| import socket | |
| import ssl | |
| import sys |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** Find least common multiple (LCM) of series of numbers. | |
| It accepts input on stdin (one integer per line) and writes the | |
| final result to stdout. | |
| Result is always positive. | |
| It uses gmplib (-lgmp) to support arbitrary precision integer arithmetic. | |
| http://stackoverflow.com/questions/20581925/how-to-avoid-overflow-error-when-finding-lcm-for-series-of-large-integers |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NAME := $(patsubst %.c,%,$(wildcard *.c)) | |
| CC := gcc -std=c89 | |
| CFLAGS = -pedantic -Wall \ | |
| -Wno-missing-braces -Wextra -Wno-missing-field-initializers -Wformat=2 \ | |
| -Wswitch-default -Wswitch-enum -Wcast-align -Wpointer-arith \ | |
| -Wbad-function-cast -Wstrict-overflow=5 -Wstrict-prototypes -Winline \ | |
| -Wundef -Wnested-externs -Wcast-qual -Wshadow -Wunreachable-code \ | |
| -Wlogical-op -Wfloat-equal -Wstrict-aliasing=2 -Wredundant-decls \ | |
| -Wold-style-definition -Werror \ | |
| -ggdb3 \ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env python2.6 | |
| """Fill textarea. | |
| http://stackoverflow.com/q/20621751 | |
| """ | |
| import cgi | |
| text = u'the text <that> you want & "to" put into textarea \u263a' | |
| html_safe_text = cgi.escape(text, quote=True) # < > & " -> < > & " | |
| textarea_html = u'<textarea placeholder="{0}"></textarea>'.format( |