Skip to content

Instantly share code, notes, and snippets.

using System;
using System.IO;
using System.IO.Compression;
using CommandLine;
namespace Decompression
{
static class Program
{
private static void Main(string[] args)
@aegoroff
aegoroff / Compression.cs
Created November 23, 2021 21:18
Compression concept
using System;
using System.IO.Compression;
using CommandLine;
namespace Compression
{
static class Program
{
private static void Main(string[] args)
{
@aegoroff
aegoroff / xml_decoder.go
Last active January 27, 2021 05:10
XML parsing Golang
package cmd
import (
"encoding/xml"
"fmt"
"io"
)
// XMLDecoder defines XML decoder that works as SAX parser
type XMLDecoder struct {
@aegoroff
aegoroff / main.rs
Last active January 27, 2021 04:29
XML parsing RUST
let now = Instant::now();
let path = matches.value_of("FILE").unwrap_or("");
let file = File::open(path).unwrap();
let file = BufReader::new(file);
let parser = EventReader::new(file);
let mut open = 0;
let mut close = 0;
@aegoroff
aegoroff / EdgeExtensions.cs
Last active April 27, 2017 18:01
String edges lengths array calculation
public static int[] EdgeLengths(this string text)
{
var result = new int[text.Length];
for (var i = 0; i < text.Length - 1; i++)
{
var b = result[i];
while (b > 0 && text[i + 1] != text[b])
{
b = result[b];
}
class Deadlock
{
~Deadlock()
{
System.Threading.Monitor.Enter(this);
}
static void Main()
{
Deadlock d = new Deadlock();
System.Threading.Monitor.Enter(d);
@aegoroff
aegoroff / grok.c
Created September 7, 2016 21:12
main_try_compile_as_wildcard
BOOL main_try_compile_as_wildcard(const char* pattern) {
char* drive = (char*)apr_pcalloc(main_pool, sizeof(char) * MAX_PATH);
char* dir = (char*)apr_pcalloc(main_pool, sizeof(char) * MAX_PATH);
char* filename = (char*)apr_pcalloc(main_pool, sizeof(char) * MAX_PATH);
char* ext = (char*)apr_pcalloc(main_pool, sizeof(char) * MAX_PATH);
char* full_dir_path;
char* file_pattern;
apr_status_t status;
apr_dir_t* d = NULL;
apr_finfo_t info = { 0 };
@aegoroff
aegoroff / ticks.cs
Last active September 17, 2015 16:42
Ticks from DateTime
static long Ticks(DateTime dt)
{
var year = dt.Year;
var month = dt.Month;
var day = dt.Day;
var hour = dt.Hour;
var min = dt.Minute;
var sec = dt.Second;
var days = 0;
@aegoroff
aegoroff / gist:ea060e46667b98003cbc
Created July 31, 2015 15:03
Find all files using mask
hc -C "for file f from dir '.' where f.name ~ '^[$]' do find withsubs;"
@aegoroff
aegoroff / external.py
Created March 9, 2015 22:12
External file sorting using Python
import argparse
import os
import sys
import datetime
def sort_and_write(lines, ix):
lines.sort()
tempFile = "d:\\_tmp_{0}.txt".format(ix)
with open(tempFile, "w") as f: