Skip to content

Instantly share code, notes, and snippets.

using System.Security.Cryptography;
namespace MediaMetadata.Contribs.damieng
{
/// <summary>
/// Crc32 Implementation by damieng, http://damieng.com/blog/2006/08/08/calculating_crc32_in_c_and_net
/// </summary>
public class Crc32 : HashAlgorithm
{
public const uint DefaultPolynomial = 0xedb88320;
@aynurin
aynurin / SeekStream.cs
Last active October 23, 2022 13:28
SeekStream allows seeking on non-seekable streams by buffering read data. The stream is not writable yet.
using System;
using System.IO;
namespace Contribs.aynurin
{
/// <summary>
/// SeekStream allows seeking on non-seekable streams by buffering read data. The stream is not writable yet.
/// </summary>
public class SeekStream : Stream
{
{
"countries":[
{
"name":"Afghanistan",
"phoneCode":"93",
"iso":"AF"
},
{
"name":"Albania",
"phoneCode":"355",
@aynurin
aynurin / gist:fc1613ddf631e861276b
Last active March 16, 2022 20:27
Sorting big files
## {{{ http://code.activestate.com/recipes/576755/ (r3)
# based on Recipe 466302: Sorting big files the Python 2.4 way
# by Nicolas Lehuen
# fixed merge(key=None, *iterables): LeaChim, http://stackoverflow.com/questions/10665925/how-to-sort-huge-files-with-python
import os, sys
from tempfile import gettempdir
from itertools import islice, cycle
from collections import namedtuple
import heapq
@aynurin
aynurin / SmallDate.cs
Created November 26, 2015 14:30
SmallDate - A C# class for a short (UInt16) date (work in progress)
/// <summary>
/// A UInt16 date with hour-precision. Not valid for dates far away from today.
/// </summary>
public struct SmallDate
{
private const long TicksInHour = 36000000000;
private readonly ushort _value;
public SmallDate(DateTime datetime) : this (datetime, DateTime.UtcNow)
@aynurin
aynurin / findJsPath.js
Created February 28, 2017 16:43
Find a member path by name within a JS object
function findJsPaths(ob, name, cache) {
cache = cache || [];
var res = [];
for (var key in ob) {
var value = ob[key];
if (key == name) {
return [key];
} else if (typeof value === 'object' || value != null) {
if (cache.indexOf(value) == -1) {
cache.push(value);
@aynurin
aynurin / Fuji X-T10 EXIF Metadata.xml
Last active October 20, 2019 18:01
An EXIF metadata extracted from a picture taken on a Fujifilm X-T10 with a 27mm F2.8 lens
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.6-c140 79.160451, 2017/05/06-01:08:21 ">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about="" xmlns:xmp="http://ns.adobe.com/xap/1.0/" xmlns:aux="http://ns.adobe.com/exif/1.0/aux/" xmlns:exifEX="http://cipa.jp/exif/1.0/" xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/" xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:tiff="http://ns.adobe.com/tiff/1.0/" xmlns:exif="http://ns.adobe.com/exif/1.0/">
<xmp:CreatorTool>Digital Camera X-T10 Ver1.20</xmp:CreatorTool>
<xmp:ModifyDate>2019-10-20T09:11:19</xmp:ModifyDate>
<xmp:CreateDate>2019-10-20T09:11:19</xmp:CreateDate>
<xmp:MetadataDate>2019-10-20T09:11:19</xmp:MetadataDate>
<aux:LensInfo>2700/100 2700/100 280/100 280/100</aux:LensInfo>
<aux:Lens>XF27mmF2.8</aux:Lens>
<aux:LensSerialNumber>51A01453</aux:LensSer
@aynurin
aynurin / stay-at-home-by-gov.csv
Last active April 6, 2020 17:19
Dates when governors of US states and territories issued Stay At Home orders during COVID-19 pandemic along with some decision making parameters
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 6.
State,"Stay-at-home in effect since, local timezone",COVID-19 Day-0,COVID-19 10 Cases,COVID-19 100 Cases,Responsible Title,Responsible Person,Responsible Person Party,Responsible Person Born,Responsible Person Age,Responsible Person Prior public experience,Responsible Person Inauguration,Responsible Person End of term
Alabama,2020-04-03 17:00:00,2020-03-13,2020-03-14,2020-03-20,Governor,Kay Ivey,Republican,1944-10-15,75,"Lieutenant Governor, Treasurer",2017-04-10,2023
Alaska,2020-03-28 00:00:00,2020-03-13,2020-03-20,2020-03-28,Governor,Mike Dunleavy,Republican,1961-05-05,58,Alaska Senate,2018-12-03,2022
American Samoa,#N/A,#N/A,#N/A,#N/A,Governor,Lolo Matalasi Moliga,Democratic,1947-08-12,72,"American Samoa Senate, American Samoa House",2013-01-03,2021
Arizona,2020-03-31 17:00:00,2020-03-07,2020-03-14,2020-03-21,Governor,Doug Ducey,Republican,1964-04-09,55,Treasurer,2015-01-05,2023
Arkansas,#N/A,2020-03-11,2020-03-14,2020-03-20,Governor,Asa Hutchinson,Republican,1950-12-03,69,"Under Secretary of Homeland Secu