Inspired by "Parsing CSS with Parsec".
Just quick notes and code that you can play with in REPL.
By @kachayev
import Foundation | |
var i: CInt = 0 | |
var device_list: UnsafeMutablePointer<UnsafeMutablePointer<Int8>> = nil | |
idevice_get_device_list(&device_list, &i) | |
print("number of devices: \(i)") | |
let array = Array(UnsafeBufferPointer(start: device_list, count: Int(i))) |
from inspect import getattr_static | |
class dep: | |
name = None | |
def __init__(self, type): | |
self.type = type |
#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'\ |
Inspired by "Parsing CSS with Parsec".
Just quick notes and code that you can play with in REPL.
By @kachayev
@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. |
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)) |
#!/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 |
# 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/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, |
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 |