Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Alex Burghardt aal89

🎯
Focusing
View GitHub Profile
@aal89
aal89 / pba.cs
Created Jul 30, 2019
Print byte array in c#
View pba.cs
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 / 420.swift
Last active Jul 23, 2019
A pure functional way to blaze some sick clouds in Swift.
View 420.swift
// Higher order functions, being curried. Considered pure functional, because they don't have any side effects
// (mutate any given data). They just derive data from data.
let plus = { (first: Int) in { (second: Int) in first + second } }
let multiplesOf = { (first: Int) in { (second: Int) in second % first != 0 } }
// Just a simple first class function, not per se functional. Usable to reduce a collection of integers into the total.
let total: (Int, Int) -> Int = { $0 + $1 }
let calculation = (1...30)
.map(plus(2))
@aal89
aal89 / kbtxtgenerator.js
Created Jul 18, 2019
Generates text files with random numbers of a particular size. Size is given in kb's as first parameter, defaults to 100.
View kbtxtgenerator.js
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 / 1mb.txt
Created Jul 18, 2019
1mb in text
View 1mb.txt
This file has been truncated, but you can view the full file.
19063699041183922230424640119986913758023341770758751642047601347737139606611941581352175797681575117149435847472379921576378
82010873314125910417098681679467651061196703036344503828425038021866296075656578591024747456403918197240660392231867709196530
05547299081771122978128893134012025555840439838755861696435926779779011155301553716406948852775421829267789075611169229413304
42028620073205237675530442721666962286683534927131293735270935475331266785352417198234822645786435208887529004886675157771888
87716254578233139050956841337551473116293899780647416270305365091493516756140179109318676578254373967658333126619554398248807
73901335039931398874577719039802288956276828455645089612214856059038950787855805249688802161731552101060793394882144824301838
80013352318345613661078428780673839967965501913764666716551387847921893809223464453567368379243079836222406059944397498046708
72409291568897359376555992566277167049359808026761803186968491038946326201866824309514704973489863815255632689038911077381036
@aal89
aal89 / 1kb.txt
Created Jul 18, 2019
1kb in text
View 1kb.txt
66125646655438184824034357503490176636099264991633465762201498014519123891859268733983653039388726432642995143358504569007771
58598693402496866943402835041634570224118066330404568236483221494076492917098844866249914290879929866424562331479470484929530
47981071980750177177087538144356263522627349597567256092672809627220185268573884037546233149941048425721886017397002493771038
59789493522946388742872159309483907924798646897590296799087138432035293041592297258616156208443607672462374144231313952523825
41214722436789521357506910806784385239131212667915286065697223577192349536631069819291852420161751071280762096700317526464632
90928765621229518421461199169418959317189370377096223039048075197848769839858594855143546758093458201630388955491473164903161
19029733685356457419092050823362333977133993758927393621966880365414110809808625711116204972494708604941468381375412202718800
30757276143464395289644876909915866493212206250053550400385293673376701537468360960764657913786708380781323834871961191069325
5294339716425075
@aal89
aal89 / 100kb.txt
Last active Jul 18, 2019
100kb in text
View 100kb.txt
90008179737137449057850374296041230231448818231836430412891860501369559957934170566478171795337452573291424987820066966816786
11421932734664050282853577818350442368737025841021682351565157149258626742693172908157392514275953021340373789403811298198112
98078491418506031705393320777252539769380080434092015114759613380134199900073766190656627700475488778765198284763526475740644
27316250203873295755542616481830176762741844790191881961666387319684382599128392790817587468185935956109594742996822851456430
69484825595272003071580933663162309410919484264168162456415987660087356646694839288039098048397766765190012006438103559476605
88069969501403804546943579852833051109937002040256969349389081744254318024154760523379227341047257631357870025582656575655762
80287299653975203684260833623532172260301953877104948974634491969795223647429108528213960088039791160860481243853022341993839
24991718535415280310113584497118196223057217585054424117851185779066465713336737557959912721815816999403404005977799509009387
9410563589763257
@aal89
aal89 / batchqueue.js
Created Jul 4, 2019
Batch queue javascript
View batchqueue.js
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 / optional.ts
Last active Jul 4, 2019
Optional class to default out variables when they do not exist.
View optional.ts
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 / DataRequest.d.ts
Created Apr 29, 2019
Declaration merging. Swift like extensions for TypeScript. Extending an Express Request object per example.
View DataRequest.d.ts
// tslint:disable
declare namespace Express {
export interface Request {
locals: {
data: unknown;
}
}
}
@aal89
aal89 / filter06.js
Last active Nov 2, 2018
A Javascript regex to filter all dutch cellphone numbers from a particular text and filter for uniqueness. Works for no mathces, one match and multiple matches.
View filter06.js
var text = `
the text containing a couple of 0612345678 numbers. like so: 0612345678 and so:
0687654321
and
another
example
0674839201
`;
// Approach one: returns an ES6 Set.