Skip to content

Instantly share code, notes, and snippets.

@yekm
Last active August 29, 2015 14:06
Show Gist options
  • Save yekm/59686a4f262ad3ea9571 to your computer and use it in GitHub Desktop.
Save yekm/59686a4f262ad3ea9571 to your computer and use it in GitHub Desktop.
pastebin
import cv2, sys
import numpy
image = cv2.imread(sys.argv[1])
image = image[318:812,468:1156,:]
template = cv2.imread(sys.argv[2])
#template = image[30:40,30:40,:]
#cv2.imshow('image', image)
result = cv2.matchTemplate(image, template, cv2.TM_CCOEFF_NORMED)
#cv2.imshow('res', result)
nimg = numpy.asarray(result)
amax = numpy.amax(nimg)
argmax = numpy.argmax(nimg)
x,y = numpy.unravel_index(argmax, nimg.shape)
#print "amax {}".format(amax)
#print "argmax {}".format(argmax)
#print "shape {}".format(nimg.shape)
#print "x,y {} {}".format(x, y)
if amax < 0.6:
exit(-1)
print "{} {}".format(y+468, x+318)
#val, result = cv2.threshold(result, amax-0.05, 255, cv2.THRESH_BINARY)
#cv2.imshow('threshold', result)
#print result.shape
#nimg = numpy.asarray(result)
#ii = numpy.argwhere(nimg == 255)
#print "{} {}".format(ii[0][1]+468, ii[0][0]+318)
#else:
# exit(-1)
#while cv2.waitKey(33) != ord('q'):
# True
#cv2.destroyAllWindows()
TARGET = netup
LIBS = -lm
CC = gcc
CXX = g++
CFLAGS = -g -Wall
CXXFLAGS = -g -Wall -std=c++0x -Wextra
.PHONY: default all clean
default: $(TARGET)
all: default
OBJECTS = $(patsubst %.c, %.o, $(wildcard *.c))
OBJECTS += $(patsubst %.cpp, %.o, $(wildcard *.cpp))
HEADERS = $(wildcard *.h)
HEADERS += $(wildcard *.hpp)
%.o: %.c $(HEADERS)
$(CC) $(CFLAGS) -c $< -o $@
%.o: %.cpp $(HEADERS)
$(CXX) $(CXXFLAGS) -c $< -o $@
.PRECIOUS: $(TARGET) $(OBJECTS)
$(TARGET): $(OBJECTS)
$(CXX) $(OBJECTS) -Wall $(LIBS) -o $@
clean:
-rm -f *.o
-rm -f $(TARGET)
#!/usr/bin/env python3
import os, time, datetime, re
import praw
import saxo
subreddit_r = re.compile('[a-z0-9]+')
@saxo.command()
def r(arg):
if not arg:
return "Fetch links from reddit"
if not saxo.env("base"):
return "Sorry, this command requires an IRC instance"
if not subreddit_r.match(arg):
return "Sorry, subreddit name must match " + subreddit_r.pattern
sname = arg
path = os.path.join(saxo.env("base"), "database.sqlite3")
with saxo.database(path) as db:
c = db.connection.cursor()
if not "reddit_stat" in db:
db['reddit_stat'].create(("name", "text unique"), ("value", str))
tname = "reddit_%s" % sname
if not tname in db:
db[tname].create(('url', 'text unique'), ('req_by', str))
url = c.execute("select url from %s where req_by = ''" % tname).fetchone()
if url == None:
rtime = c.execute("select value from reddit_stat where name = ?", [tname]).fetchone()
if rtime != None and rtime[0] == str(datetime.date.today()):
return "No more %s for today" % sname
reddit = praw.Reddit(user_agent='irc_pic_bot')
s = reddit.get_subreddit(sname).get_hot(limit=32)
for x in s:
if x.url.endswith(('.jpg', '.jpeg', '.gif', '.png')):
c.execute("replace into %s values(?, '')" % tname, [x.url])
db.commit()
c.execute("replace into reddit_stat values (?, ?)", [tname, str(datetime.date.today())])
db.commit()
url = c.execute("select url from %s where req_by = ''" % tname).fetchone()
if url == None:
return "No more urls. Maybe reddit is down."
c.execute("replace into %s values (?, ?)" % tname, [url[0], saxo.env("nick")])
db.commit()
return url[0]
# russian wordlist generator from any text
sed -e 's/[^йцукенгшщзхъфывапролджэячсмитьбюё]/ /gi; s/ \+/ /g; s/ /\n/g; s/.*/\L&/' | TMPDIR=. TMP=. sort -u
# keyboard translation
perl -C -pe "use utf8; y/йцукенгшщзхъфывапролджэячсмитьбюё/qwertyuiop[]asdfghjkl;'zxcvbnm,.t/"
# cap2hccap
nets=$(wpaclean wpa_clean.cap wpa.cap | grep Net | cut -f 2-3 -d\ ); echo "$nets" | while read mac name; do aircrack-ng wpa_clean.cap -b $mac -J $mac-$name; done
#!/bin/bash
LC_ALL=C
for f in *; do
s=$(stat -c %s $f)
if tail -c 27 $f | grep MD5CHANGE_; then
echo "updating $f $s"
date '+%F %R' | dd of=$f bs=1 seek=$(( $s - 17 )) &>/dev/null
else
echo "modifying $f $s"
echo "MD5CHANGE_$(date '+%F %R')" | dd of=$f bs=1 seek=$s &>/dev/null
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment