Skip to content

Instantly share code, notes, and snippets.

View dirkarnez's full-sized avatar
💪
want a lot of sleep...

Dirk Arnez dirkarnez

💪
want a lot of sleep...
  • Freelance
  • Hong Kong
View GitHub Profile
@dirkarnez
dirkarnez / build.gradle
Created July 16, 2020 08:42 — forked from TurekBot/build.gradle
Gradle Shadow Example
group 'com.github.yourusername'
version '1.0-SNAPSHOT'
//These are dependencies that have to do with just the build. See: https://stackoverflow.com/a/23627293/5432315
buildscript {
repositories {
jcenter()
}
dependencies {
//This is necessary to use the gradle shadow plugin
@dirkarnez
dirkarnez / alias.cmd
Created April 21, 2020 08:33 — forked from benjamine/alias.cmd
Aliases for windows command line
::
:: Aliases for windows command line
::
:: Installation:
::
:: - create a folder for your aliases (eg: ```c:\cmd-aliases```)
:: - add that folder to your PATH variable
:: - save this script as setalias.cmd on that folder
:: - run "alias" to see usage
::
@dirkarnez
dirkarnez / Dockerfile
Created February 19, 2020 14:44 — forked from PurpleBooth/Dockerfile
Create a static binary in go and put it in a from scratch docker container
FROM golang:1.9
WORKDIR /go/src/github.com/purplebooth/example
COPY . .
RUN go build -ldflags "-linkmode external -extldflags -static" -a main.go
FROM scratch
COPY --from=0 /go/src/github.com/purplebooth/example/main /main
CMD ["/main"]
@dirkarnez
dirkarnez / Makefile
Created September 6, 2019 20:05 — forked from hibariya/Makefile
Calling c function from x86-64 assembly code (System V AMD64 ABI)
OBJECTS = func.o main.o
CC = gcc
CFLAGS = -std=c11 -m64 -Wall -Wextra -Werror -c
AS = nasm
ASFLAGS = -f elf64
all: $(OBJECTS)
gcc -m64 $(OBJECTS) -o main
run: all
@dirkarnez
dirkarnez / export.bat
Created August 23, 2019 06:46
Export file / directory list
dir /B /S > "dir.txt"
@dirkarnez
dirkarnez / string-hash.js
Created August 20, 2019 07:08
JavaScript get hash code from string, copied from stackoverflow
String.prototype.hashCode = function() {
var hash = 0, i, chr;
if (this.length === 0) return hash;
for (i = 0; i < this.length; i++) {
chr = this.charCodeAt(i);
hash = ((hash << 5) - hash) + chr;
hash |= 0; // Convert to 32bit integer
}
return hash;
};
@dirkarnez
dirkarnez / arraybuffer-to-base64.ts
Created August 1, 2019 10:50
ArrayBuffer To Base64
function arrayBufferToBase64(data: ArrayBuffer) {
var binary = "";
var bytes = new Uint8Array(data);
for (var len = bytes.byteLength, i = 0; i < len; i++) {
binary += String.fromCharCode(bytes[i]);
}
return window.btoa(binary);
}
@dirkarnez
dirkarnez / 0_main.cxx
Created July 10, 2019 08:41 — forked from xiongjia/0_main.cxx
A simple sample of Boost DLL #boost #devsample
/**
* A simple sample of Boost DLL
*/
#include <iostream>
#include "boost/shared_ptr.hpp"
#include "boost/function.hpp"
#include "boost/dll/import.hpp"
#include "1_plugin.hxx"
@dirkarnez
dirkarnez / win-syscall.go
Created April 23, 2019 02:50
syscall on Windows DLL
syscall.MustLoadDLL("user32.dll").MustFindProc("MessageBeep").Call(0xffffffff)
@dirkarnez
dirkarnez / mask.js
Created April 18, 2019 09:02
Mask a string with asterisks
functiob mask(str, start) {
return str.split("").map((v, i) => i >= start ? "*" :v).join("");
}