Skip to content

Instantly share code, notes, and snippets.

View renexu's full-sized avatar

Rene Xu renexu

  • eBay
  • Vancouver
  • 13:06 (UTC -07:00)
View GitHub Profile
from argparse import ArgumentParser
from collections import defaultdict
if __name__ == '__main__':
parser = ArgumentParser()
parser.add_argument('input', type=str)
args = parser.parse_args()
from argparse import ArgumentParser
import socket
def dns_lookup(hostname: str) -> str:
return socket.gethostbyname(hostname)
if __name__ == '__main__':
parser = ArgumentParser()
@renexu
renexu / build_libvips.md
Created January 24, 2019 19:46
build latest libvips deb on ubuntu 18.04

These are the steps to build latest libvips (8.7.4) deb package on ubuntu 18.04

##1. install build scripts

# sudo apt install build-essential devscripts

##2. download vips source

@renexu
renexu / train.py
Created December 28, 2017 05:46
Keras HDF5Matrix and fit_generator for huge hdf5 dataset
import threading
from keras.applications.inception_v3 import InceptionV3
from keras.optimizers import Adam
from keras.utils.io_utils import HDF5Matrix
class threadsafe_iter:
"""Takes an iterator/generator and makes it thread-safe by
serializing call to the `next` method of given iterator/generator.
@renexu
renexu / kafka
Last active September 21, 2016 05:21 — forked from superscott/kafka
Simple Kafka Ubuntu init.d Startup Script
#! /bin/sh
### BEGIN INIT INFO
# Provides: kafka
# Required-Start: $remote_fs
# Required-Stop: $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: A high-throughput distributed messaging system.
# Description: Kafka is a distributed, partitioned, replicated commit log service.
@renexu
renexu / iparesign
Last active December 17, 2015 10:49
#!/usr/bin/env bash
if [[ ! ( # any of the following are not true
# 1st arg is an existing regular file
-f "$1" &&
# ...and it has a .ipa extension
"${1##*.}" == "ipa" &&
# 2nd arg is an existing regular file
-f "$2" &&
# ...and it has an .mobileprovision extension