Skip to content

Instantly share code, notes, and snippets.

@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
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):
#!/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
@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:
// Ennek a fájlnak a letöltési linkje:
// https://gist.github.com/hdf/2a4f01f24c1f74bd48252ee297ed53b2
// Felfedezendő terület vizuális paraméter generáló: https://gist.github.com/hdf/63f5f088d11039972778
// Linux alatti építés és futtatás (ha nincs fönt g++: "sudo apt-get install g++"):
// g++ -O3 -fopenmp RKF7_4D_heterokl_Dll.cpp -o judit1
// chmod +x ./judit1
// ./judit1 -MMM 10 -t 1300 -o eredmeny.txt
// less ./eredmeny.txt
// (less -ből való kilépéshez nyomd meg a q billentyűt.)
@hdf
hdf / Form1.Designer.cs
Last active February 5, 2017 14:37
RenderDLL
namespace ProgressViewer {
partial class Form1 {
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
@hdf
hdf / expNand.txt
Last active December 6, 2019 15:30
Thought experiment. NAND logic gate (and others) with only exponentiation.
//NAND logic gate (and others) with only exponentiation.
/*
Exponentiation: 13
0^0 1
0^1 0
1^0 1
1^1 1
NAND: 7
@hdf
hdf / string_score_closest.js
Last active July 6, 2018 15:14
Extension project for: https://github.com/joshaven/string_score/ adding functionality to find closest matches. See: https://github.com/joshaven/string_score/issues/28
// Extension project for: https://github.com/joshaven/string_score/
// See: https://github.com/joshaven/string_score/issues/28
/**
* Gives back an array of indexes of the unique closest matches,
* on a string array to a string.
* 'Hello World'.closest(['el', 'll', 'o', 'll']); //=> [ 0, 1 ]
*/
String.prototype.closest = function(words, fuzziness, one2many) {
'use strict';
@hdf
hdf / random_map.html
Created April 11, 2016 10:21
js random to canvas image
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Random Map</title>
</head>
<body>
<canvas id="map" style="border: solid 1px black;"></canvas>
<script>
var canvas = document.getElementById('map');
@hdf
hdf / .bashrc
Last active March 1, 2016 16:43
bash aliases for myself
alias b='unset HISTFILE'
alias c='sudo apt-get autoremove && sudo apt-get autoclean'
alias i='sudo apt-get install'
alias u='sudo apt-get purge'
alias ..='cd ..'