Skip to content

Instantly share code, notes, and snippets.

View aal89's full-sized avatar
🎯
Focusing

Alex Burghardt aal89

🎯
Focusing
View GitHub Profile
@aal89
aal89 / optional.ts
Last active July 4, 2019 09:01
Optional class to default out variables when they do not exist.
class Optional<T> {
private value: T | null = null;
private constructor(value: T | null) {
this.value = value;
}
public static some<T>(value: T): Optional<T> {
return new Optional(value);
@aal89
aal89 / batchqueue.js
Created July 4, 2019 09:53
Batch queue javascript
function BatchQueue(concurrentTasks) {
this.concurrency = concurrentTasks;
this.running = 0;
this.queue = [];
}
BatchQueue.prototype.pushTask = function(task, callback) {
this.queue.push(task);
this.next();
}
@aal89
aal89 / 100kb.txt
Last active April 25, 2024 20:49
100kb in text
90008179737137449057850374296041230231448818231836430412891860501369559957934170566478171795337452573291424987820066966816786
11421932734664050282853577818350442368737025841021682351565157149258626742693172908157392514275953021340373789403811298198112
98078491418506031705393320777252539769380080434092015114759613380134199900073766190656627700475488778765198284763526475740644
27316250203873295755542616481830176762741844790191881961666387319684382599128392790817587468185935956109594742996822851456430
69484825595272003071580933663162309410919484264168162456415987660087356646694839288039098048397766765190012006438103559476605
88069969501403804546943579852833051109937002040256969349389081744254318024154760523379227341047257631357870025582656575655762
80287299653975203684260833623532172260301953877104948974634491969795223647429108528213960088039791160860481243853022341993839
24991718535415280310113584497118196223057217585054424117851185779066465713336737557959912721815816999403404005977799509009387
9410563589763257
@aal89
aal89 / 10kb.txt
Created July 18, 2019 08:49
10kb in text
89075337635954647102216077828334038179638965680796041208684221958292459041499210220101176726750119361506928946801115768179724
42244632672758898527798766326186965189573496725417576843236332384515325066967967084729236662659424427203830789178855960389888
59671607161000645588293584669984665020199777828148967747970527020608102921980556435899241646582421992569038754973449362160805
31239955776017464552148435666505635723861800404618684226812752076597749931057757306056294943547000781262839809899923354086591
58421004045160720410218892782153917915938163263152750197199304506126821048289291640271668334925747202569241057032162874410383
13229406649061136455569503589840650992763870062625721531357020224282471379189564485235429826481871222615972206141109473569331
50068277012583532229033541176707338889365478924968936854152065761173915111644345900669149625078722916074227614326832708754591
53533652284306970616530322571286936751979637851359030657540649747647283544275697965879550870371044054664298592239900461215946
7600905955755449
@aal89
aal89 / 1kb.txt
Created July 18, 2019 08:50
1kb in text
66125646655438184824034357503490176636099264991633465762201498014519123891859268733983653039388726432642995143358504569007771
58598693402496866943402835041634570224118066330404568236483221494076492917098844866249914290879929866424562331479470484929530
47981071980750177177087538144356263522627349597567256092672809627220185268573884037546233149941048425721886017397002493771038
59789493522946388742872159309483907924798646897590296799087138432035293041592297258616156208443607672462374144231313952523825
41214722436789521357506910806784385239131212667915286065697223577192349536631069819291852420161751071280762096700317526464632
90928765621229518421461199169418959317189370377096223039048075197848769839858594855143546758093458201630388955491473164903161
19029733685356457419092050823362333977133993758927393621966880365414110809808625711116204972494708604941468381375412202718800
30757276143464395289644876909915866493212206250053550400385293673376701537468360960764657913786708380781323834871961191069325
5294339716425075
@aal89
aal89 / 1mb.txt
Created July 18, 2019 08:51
1mb in text
This file has been truncated, but you can view the full file.
19063699041183922230424640119986913758023341770758751642047601347737139606611941581352175797681575117149435847472379921576378
82010873314125910417098681679467651061196703036344503828425038021866296075656578591024747456403918197240660392231867709196530
05547299081771122978128893134012025555840439838755861696435926779779011155301553716406948852775421829267789075611169229413304
42028620073205237675530442721666962286683534927131293735270935475331266785352417198234822645786435208887529004886675157771888
87716254578233139050956841337551473116293899780647416270305365091493516756140179109318676578254373967658333126619554398248807
73901335039931398874577719039802288956276828455645089612214856059038950787855805249688802161731552101060793394882144824301838
80013352318345613661078428780673839967965501913764666716551387847921893809223464453567368379243079836222406059944397498046708
72409291568897359376555992566277167049359808026761803186968491038946326201866824309514704973489863815255632689038911077381036
@aal89
aal89 / kbtxtgenerator.js
Created July 18, 2019 08:52
Generates text files with random numbers of a particular size. Size is given in kb's as first parameter, defaults to 100.
const fs = require("fs");
const lineLength = 126;
const sizeInKb = process.argv[2] || 100;
let data = "";
for(var i = 0; i < sizeInKb * 1024; i++) {
if (i && i % lineLength === 0) {
data += "\n";
} else {
@aal89
aal89 / pba.cs
Created July 30, 2019 22:35
Print byte array in c#
public void PrintByteArray(byte[] bytes)
{
var sb = new StringBuilder("new byte[] { ");
foreach (var b in bytes)
{
sb.Append(b + ", ");
}
sb.Append("}");
Console.WriteLine(sb.ToString());
}
@aal89
aal89 / faketypes.cs
Last active April 23, 2023 14:11
UInt128 and UInt256 data types in c# to compare string hashes with one and another.
using System;
using System.Globalization;
using System.Text.RegularExpressions;
namespace FakeTypes
{
// All types within this namespace are considered fakes. A UInt128 is a struct
// containing two ulongs, their primary reason for existence is for quick calculation
// and comparisons of hash strings as numbers. Allocation should be on the stack.
@aal89
aal89 / currying.swift
Last active September 26, 2019 09:13
Examples whereby we curry an arithmetic operator over a collection of natural numbers and curry a greetings functions over a collection of strings, in Swift.
// ========================== Generic (limited) curry function:
func curry<A, B, C>(_ f: @escaping (A, B) -> C) -> (A) -> (B) -> C {
return { a in { b in f(a, b) }}
}
// ========================== Example 1:
let add = curry((+) as ((Int, Int) -> Int))
let add2 = add(2)