Skip to content

Instantly share code, notes, and snippets.

require 'formula'
class Phash < Formula
homepage 'http://www.phash.org/'
url 'http://www.phash.org/releases/pHash-0.9.5.tar.gz'
#sha1 '9710b8a1d4d24e7fc3ac43c33eac8e89d9e727d7'
sha1 '87ce165b344bb859f5fdaf7c1776b556db3d8a15'
depends_on 'cimg' unless build.include? "disable-image-hash" and build.include? "disable-video-hash"
depends_on 'ffmpeg' unless build.include? "disable-video-hash"
@luchuan
luchuan / gist:4343611
Last active May 27, 2021 19:04
hack HomeBrew for installing phash and its python binding under Mac OS 10.7.5
cd /usr/local/Library/Formula
vim phash.rb 将内容改为 https://gist.github.com/4343605 所示
brew install phash --disable-video-hash --disable-audio-hash
git clone https://github.com/luchuan/py-phash.git
cd py-phash; python setup install
@luchuan
luchuan / gist:4343636
Created December 20, 2012 07:54
Mac OS 10.7.5 brew安装phash错误
luc:python-packages luc631$ brew install pHash
==> Installing phash dependency: cimg
==> Downloading http://downloads.sourceforge.net/cimg/CImg-1.5.2.zip
######################################################################## 100.0%
/usr/local/Cellar/cimg/1.5.2: 442 files, 33M, built in 51 seconds
==> Installing phash dependency: fftw
==> Downloading http://www.fftw.org/fftw-3.3.2.tar.gz
######################################################################## 100.0%
==> ./configure --enable-single --enable-sse --enable-shared --prefix=/usr/local/Cellar/fftw/3.3.2 --enable-threads
==> make install
vagrant@vagrant:~/PyDoubanFM$ python fm.py
Playing: 12 Etudes - No 7. Pour les degres chromatiques
** (fm.py:11935): WARNING **: Command line `dbus-launch --autolaunch=3923027668d604d7c9a04edc0000011e --binary-syntax --close-stderr' exited with non-zero exit status 1: Autolaunch error: X11 initialization failed.\n
** (fm.py:11935): WARNING **: Command line `dbus-launch --autolaunch=3923027668d604d7c9a04edc0000011e --binary-syntax --close-stderr' exited with non-zero exit status 1: Autolaunch error: X11 initialization failed.\n
** (fm.py:11935): WARNING **: Command line `dbus-launch --autolaunch=3923027668d604d7c9a04edc0000011e --binary-syntax --close-stderr' exited with non-zero exit status 1: Autolaunch error: X11 initialization failed.\n
** (fm.py:11935): WARNING **: Command line `dbus-launch --autolaunch=3923027668d604d7c9a04edc0000011e --binary-syntax --close-stderr' exited with non-zero exit status 1: Autolaunch error: X11 initialization failed.\n
#!/usr/bin/env python
# Copyright (c) 2011 Adam Pingel
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
@luchuan
luchuan / spy.py
Created May 13, 2013 05:53
pypcap example
# coding:utf-8
import pcap
import dpkt
from datetime import datetime
pc = pcap.pcap()
pc.setfilter('tcp port 80')
for ptime, pdata in pc:
print datetime.fromtimestamp(ptime).strftime('%Y-%m-%d %H:%M:%S')#, pdata
p = dpkt.ethernet.Ethernet(pdata)
@luchuan
luchuan / Makefile
Created June 5, 2013 16:06
avr-gcc Makefile template
# ----------------------------------------------------------------------------
# Makefile based on WinAVR Makefile Template written by Eric B. Weddington,
# Jörg Wunsch, et al.
#
#----------------------------------------------------------------------------
# On command line:
#
# make all = Make software.
#
# make clean = Clean out built project files.
// Playground - noun: a place where people can play
import Cocoa
func main() {
func _fib(x: Int, y: Int, i: Int) -> Int {
if i == 1 || i == 0 {
Process: Xcode [46662]
Path: /Applications/Xcode6-Beta.app/Contents/MacOS/Xcode
Identifier: com.apple.dt.Xcode
Version: 6.0 (6194.21)
Build Info: IDEFrameworks_KLONDIKE-6194021000000000~12
Code Type: X86-64 (Native)
Parent Process: launchd [901]
Responsible: Xcode [46662]
User ID: 501
# coding:utf-8
from random import randint, sample
from collections import Counter
from itertools import combinations
def gen_carts(items, n_cart):
n_items = len(items)
carts = []
with open('carts.txt', 'w') as f: