Skip to content

Instantly share code, notes, and snippets.

@hdf
hdf / match.py
Created February 24, 2017 17:47
Image matching using OpenCV in Python
from PIL import Image, ImageGrab
import cv2, numpy
img = cv2.cvtColor(numpy.array(ImageGrab.grab()), cv2.COLOR_RGB2BGR)
template = cv2.cvtColor(numpy.array(Image.open('PS/3C.png')), cv2.COLOR_RGB2BGR)
d, w, h = template.shape[::-1]
res = cv2.matchTemplate(img, template, cv2.TM_CCOEFF_NORMED)
#all matches:
#!/bin/bash -i
sudo mount -o remount,rw /cdrom
mount -l|grep /dev/sd
setxkbmap hu
#sudo ifconfig wlan0 up
#sudo wpa_passphrase HDF $(head -c 63 wpa_key.txt) > /tmp/wpa.conf
#sudo iwconfig wlan0 essid HDF
#sudo wpa_supplicant -B -iwlan0 -c /tmp/wpa.conf -Dwext -W
#sudo dhclient wlan0
read -t 10
import os, sys, re
dir = sys.argv[1] if len(sys.argv) > 1 else "files"
find = sys.argv[2] if len(sys.argv) > 2 else "<\?\n"
set_to = sys.argv[3] if len(sys.argv) > 3 else "<?PHP\n"
exts = sys.argv[4] if len(sys.argv) > 4 else "\.php|\.txt"
pattern = re.compile(find, re.I | re.M | re.S)
if not os.path.isdir(dir):
@hdf
hdf / pick.py
Last active July 17, 2018 11:07
import sys
if len(sys.argv) < 2:
print("""Usage:
pick.py data.txt [lines_to_skip = 0] [first_line = 0]""")
sys.exit(0)
file = sys.argv[1]
skip = int(sys.argv[2]) + 1 if len(sys.argv) > 2 else 1
start = int(sys.argv[3]) if len(sys.argv) > 3 else 0
This file has been truncated, but you can view the full file.
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>vis.js Plot</title>
<style>
body {font: 10pt arial;}
#mygraph>div {border: 1px solid black;}
#mygraph,#controlls {display: inline-block; vertical-align: top;}
</style>
@hdf
hdf / bubbleSort.js
Last active December 22, 2018 17:18
function bubbleSort(arr, cmp) {
var len = arr.length, tmp, n;
if (typeof cmp !== 'function')
cmp = function(a, b) {
return a > b;
};
do {
n = 0;
for (var i = 1; i < len; i++) {
if (cmp(arr[i], arr[i-1])) continue;
@hdf
hdf / programozz.txt
Last active September 19, 2018 13:45
Előadás terv javaslat
Mi a programozás?
Megmondani a gépnek hogy mit csináljon. Nagyon szájbarágósan. (Angol tudás elengedhetetlen.)
Számomra a programozás olyan mint a legózás, csak olcsóbb, nem megy tönkre a kezed tőle és sose fogysz ki a darabokból.
Engem azért vonzott a programozás, mert olyan volt mint a varázslás. Mintha pár varázs szó beírásával életet lehelnél az élettelenbe. Viselkedést adhatsz egy tárgynak. És érdekelt, hogy a játékok, meg egyéb programok, amiket használtam hogyan működnek. Illetve az automatizáció is mindig vonzott, mert olyan mint a csalás. Ráveszed a világot, hogy dolgozzon helyetted.
Mihez van szükség hozzá?
Kell egy feladat.
A feladat határozza meg, hogy melyik a megfelelő eszköz (program nyelv) hozzá.
Számítógép internet eléréssel, Google, program nyelv dokumentáció/referencia, fejlesztői környezet: Visual Studio (Code) / Notepad++, idő, érdeklődés.
@hdf
hdf / NthClosest.js
Last active December 22, 2018 20:41
Interview stuff?
// Inspired by:
// https://interviewing.io/recordings/Go-Microsoft-1
function NthClosest(points, match, n) {
if (n < 1 || n > points.length || points[0].length != match.length)
return false;
function distance(p1, p2) { // Works in any dimensions.
let out = 0, d = 0, len = p1.length;
for (let i3 = 0; i3 < len; i3++) {
@hdf
hdf / index.html
Last active November 29, 2018 16:56
Google Drive Demo
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Google Drive Demo</title>
</head>
<body>
<div style="position: absolute; top: 40%; left: 50%; transform: translate(-50%, -40%); text-align: center;">
<a href="https://drive.google.com/open?id=1v1-ApluL9dCGx4znKVSXGKnBf4dFVGuv">Letöltés</a><br><br>
@hdf
hdf / BigO.js
Created December 23, 2018 14:59
Based on the array in question, and the counter value (you have to put the code for that in the function in question yourself), this function will tell us the time complexity of the function.
function BigO(arr, arr3) { // Second array is optional
this.accumulator = 0; // Can be set here, or when calling ClosestMatch
/* function factorial(n, i) {
if (n > 171) // Overflow prevention
return Infinity;
if (typeof i == 'undefined')
i = 1;
if (n < i)
return 1;
if (n === i)