Inspired by "Parsing CSS with Parsec".
Just quick notes and code that you can play with in REPL.
By @kachayev
#!/usr/bin/env python | |
"""This is a demonstration of sharing file descriptors across processes. | |
It uses Tornado (need a recent post-2.0 version from github) and the | |
multiprocessing module (from python 2.6+). To run it, start one copy | |
of fdserver.py and one or more copies of testserver.py (in different | |
terminals, or backgrounded, etc). Fetch http://localhost:8000 and | |
you'll see the requests getting answered by different processes (it's | |
normal for several requests to go to the same process under light | |
load, but under heavier load it tends to even out). |
#!/usr/bin/env bash | |
# bash 4.1.5(1) Linux Ubuntu 10.04 Date : 2019-01-02 | |
# | |
# _______________| noise : ambient Brown noise generator (cf. white noise). | |
# | |
# Usage: noise [minutes=59] [band-pass freq center=1786] [wave] | |
# ^minutes can be any positive integer. | |
# Command "noise 1" will display peak-level meter. | |
# | |
# Dependencies: play (from sox package) |
package com.nascency.incipit | |
import com.twitter.finagle.{Service, SimpleFilter} | |
import org.jboss.netty.handler.codec.http._ | |
import org.jboss.netty.handler.codec.http.HttpResponseStatus._ | |
import org.jboss.netty.handler.codec.http.HttpVersion.HTTP_1_1 | |
import org.jboss.netty.buffer.ChannelBuffers.copiedBuffer | |
import org.jboss.netty.util.CharsetUtil.UTF_8 | |
import com.twitter.util.Future | |
import java.net.InetSocketAddress |
#! /usr/bin/python2.6 | |
# I COULD ONLY GET IT TO RUN IN PYTHON2.6 | |
# Running it in python2.7, installed from homebrew results in a segfault. | |
# I haven't been able to investigate why. | |
# Code translated from http://osxbook.com/book/bonus/chapter2/alterkeys/ | |
# License: http://ljos.mit-license.org/ | |
from Quartz import ( | |
CGEventGetIntegerValueField, CGEventSetIntegerValueField, | |
kCGKeyboardEventKeycode, | |
kCGEventKeyDown, kCGEventKeyUp, |
# I needed to print out ascii tables from data in the form: | |
# [ ('column 0 title', 'column 1 title' ..), | |
# ('row 0, column 0 data', 'row 0, column 1 data' ...) ...] | |
# | |
# and surprisingly it got complicated because of variable lengths of the data. | |
# I googled for 'standard' ways of doing this and I found suggestions like: | |
# http://stackoverflow.com/questions/5909873/python-pretty-printing-ascii-tables | |
# ...which were a bit dated and hard to read or full scale modules like: | |
# | |
# http://pypi.python.org/pypi/texttable/ |
#!/usr/bin/env python | |
# | |
# gexiv2 image Exif date fixer. | |
# Corey Goldberg, 2014 | |
"""Recursively scan a directory tree, fixing dates | |
on all jpg/png image files. | |
Each file's Exif metadata and atime/mtime are all |
import asyncio | |
import aiohttp | |
import bs4 | |
import tqdm | |
@asyncio.coroutine | |
def get(*args, **kwargs): | |
response = yield from aiohttp.request('GET', *args, **kwargs) | |
return (yield from response.read_and_close(decode=True)) |
@implementation UIImage (scale) | |
/** | |
* Scales an image to fit within a bounds with a size governed by | |
* the passed size. Also keeps the aspect ratio. | |
* | |
* Switch MIN to MAX for aspect fill instead of fit. | |
* | |
* @param newSize the size of the bounds the image must fit within. | |
* @return a new scaled image. |
Inspired by "Parsing CSS with Parsec".
Just quick notes and code that you can play with in REPL.
By @kachayev
#printf | |
RUN printf '#!/bin/bash\n\ | |
echo hello world from line 1\n\ | |
echo hello world from line 2'\ | |
>> /tmp/hello | |
#echo | |
RUN echo -e '#!/bin/bash\n\ | |
echo hello world from line 1\n\ | |
echo hello world from line 2'\ |