Skip to content

Instantly share code, notes, and snippets.

View irvanherz's full-sized avatar
😀

Muhammad Irvan Hermawan irvanherz

😀
View GitHub Profile
@irvanherz
irvanherz / sync-vs-async.cs
Created July 15, 2023 04:09
Task.WaitAll()
using RestSharp;
using System.Threading;
async Task<string> getResponse(string url)
{
var start = DateTime.Now;
var client = new RestClient();
var request = new RestRequest(url);
@irvanherz
irvanherz / jaura.cpp
Last active March 5, 2023 08:41
C++ HTTP Server prove of concept
#include <malloc.h>
#include <microhttpd.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <cstring>
#include <functional>
#include <iostream>
@irvanherz
irvanherz / multer-sharp-minio-storage.ts
Last active October 30, 2022 21:16
Streaming multer storage engine with Sharp image transformation for Minio
/* global Express */
import { Request } from 'express'
import { Client, ClientOptions, ItemBucketMetadata } from 'minio'
import multer from 'multer'
import path from 'path'
import sharp from 'sharp'
type TransformerType = {
id: string
sharp: sharp.Sharp
@irvanherz
irvanherz / multer-minio-storage.ts
Created October 30, 2022 10:47
Streaming multer storage engine for Minio
/* global Express */
import { Request } from 'express'
import { Client, ClientOptions, UploadedObjectInfo } from 'minio'
import multer from 'multer'
import path from 'path'
type FilenameCallbackType = (req: Request, file: Express.Multer.File) => string
type HandleFileCallbackInfoType = Partial<Express.Multer.File> & { objectinfo?: UploadedObjectInfo }
type HandleFileCallbackType = (error?: any, info?: HandleFileCallbackInfoType) => void
const defaultFilenameCallback:FilenameCallbackType = (_req, file) => {
@irvanherz
irvanherz / eval_with_args.js
Created October 26, 2022 09:15
Evaluate function with arguments
const addFun = `
const [a, b] = arguments
return a + b
`
var func = new Function(addFun);
const ret = func.call(null, 1, 2);
console.log(ret)