Skip to content

Instantly share code, notes, and snippets.

@laserpez
laserpez / enumerate.cs
Created June 27, 2022 09:29
Python's "enumerate" C# implementation
using System;
using System.Collections.Generic;
using System.Linq;
public static class IEnumerableExtension
{
public static IEnumerable<(int index, T valuee)> Enumerate<T>(this IEnumerable<T> coll)
{
return coll.Select((T val, int i) => (i, val));
}
@laserpez
laserpez / pwrecovery.html
Last active February 4, 2020 09:46
Password recovery for HeidiSQL
<!doctype html>
<html>
<body>
<script>
function heidiDecode(hex) {
var str = '';
var shift = parseInt(hex.substr(-1));
hex = hex.substr(0, hex.length - 1);
for (var i = 0; i < hex.length; i += 2) {
str += String.fromCharCode(parseInt(hex.substr(i, 2), 16) - shift);
@laserpez
laserpez / history-example.html
Last active August 29, 2015 14:08
history pushState/onpopstate example
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
</head>
<title>History</title>
<body>
<button id='btn'>Click</button>
<span id='txt'></span>
</body>
#! /usr/bin/python
# Dispatch - synchronize two folders, the "left" being the source and the "right" being the target.
# Synchronization works only left to right.
import os
import filecmp
import shutil
from stat import *
class Dispatch:
import logging
import zmq
class ZmqClient (object):
def __init__(self, socket, logger):
super(ZmqClient, self).__init__()
self._logger = logger
self._socket = socket