Skip to content

Instantly share code, notes, and snippets.

@hdf
hdf / sort.js
Created August 9, 2014 19:16
incremental regex replace in nodejs
var fs = require('fs');
var file = 'EoCApp.CT';
if (process.argv.length > 2)
file = process.argv[2];
var f = fs.readFileSync(file, 'utf8');
var i = 0;
f = f.replace(/<ID>\d+<\/ID>/gm, function () {return '<ID>' + i++ + '</ID>'});
@hdf
hdf / sort.py
Created August 9, 2014 19:17
incremental regex replace in python
import os, sys, re
pattern = re.compile("<ID>\d+<\/ID>", re.I | re.M)
file = 'EoCApp.CT'
if len(sys.argv) > 1:
file = sys.argv[1]
f = open(file, 'r')
s = f.read()
@hdf
hdf / GetAoBAddresses.cs
Created August 14, 2014 21:09
C# console app to get addresses from aobscan patterns (Cheat Engine) (Uses Patcher.dll from: https://github.com/hdf/patcher2)
using Patcher2; // Uses Patcher.dll from: https://github.com/hdf/patcher2
using System;
using System.Diagnostics;
using System.IO;
using System.Runtime.InteropServices;
using System.Text.RegularExpressions;
namespace GetAoBAddresses
{
internal class Program
@hdf
hdf / crc32.js
Created September 4, 2014 22:46
Add crc32 function to Strings.
// Bookmarklet:
//javascript:(function(){var genCRCTable=function(){var c;var r=[];for(var n=0;n<256;n++){c=n;for(var k=0;k<8;k++)c=((c&1)?(0xEDB88320^(c>>>1)):(c>>>1));r[n]=c;}return r;};if(!window.crcTable)window.crcTable=genCRCTable();String.prototype.crc32=function(s){s=s||this.toString();if(s.length<1)return"00000000";var t=window.crcTable||(window.crcTable=genCRCTable());var c=0^(-1);for(var i=0;i<s.length;i++)c=(c>>>8)^t[(c^s.charCodeAt(i))&0xFF];c=((c^(-1))>>>0).toString(16).toUpperCase();return(c.length%2>0)?c+"0":c;};}());
// Usage:
//"test".crc32();
var genCRCTable = function () {
var c;
var r = [];
for (var n = 0; n < 256; n++) {
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Mandelbrot with GLSL</title>
<style>
html, body {margin: 0; padding: 0;}
canvas {position: absolute; width: 100%; height: 100%;}
</style>
</head>
@hdf
hdf / CubeMaker.cs
Created May 18, 2015 20:39
Unity Desktop Test
using UnityEngine;
using System.Collections;
public class CubeMaker : MonoBehaviour {
GameObject c, p;
public static ReflectionProbe Probe1;
// Use this for initialization
void Start() {
c = GameObject.CreatePrimitive(PrimitiveType.Cube);
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Map Selector</title>
<style>
html, body {margin: 0; padding: 0; width: 1058px;}
canvas {border: 1px dashed black;}
div, div > div, input[type=text] {float: right; padding: 0px 4px 0px 4px;}
div > div {padding: 0px;}
@hdf
hdf / index.js
Created November 25, 2015 23:31
Node.js Package Dependency Generator
var fs = require('fs'),
https = require('https');
ignore_dirs = ['node_modules', '.git', 'coverage', '.', '..'];
ignore_modules = ['assert',
'buffer',
'child_process',
'cluster',
'crypto',
'dgram',
@hdf
hdf / MoveAbout.ahk
Created February 1, 2016 19:48
AutoHotKey scripts
Gui, Color, FFFFFF
Gui, Font, S14 CDefault Bold, Verdana
Gui, Add, Text, x0 y0 w70 h20, Active
Gui, +AlwaysOnTop -SysMenu -Caption +ToolWindow +LastFound
WinSet, TransColor, FFFFFF
WinSet, ExStyle, ^0x00000020
SetTitleMatchMode, 2
WindowTitle := "World of Warcraft"
Return
@hdf
hdf / test.c
Last active February 15, 2016 13:38
call dll from c
// gcc -O3 test.c -o test
#include <windows.h>
#include <stdio.h>
typedef int (CALLBACK* dll_main)(int, char**);
int main(int argc, char* argv[]) {
void* handle = LoadLibrary("judit1.dll");
printf("handle: %ld\n", handle);