Skip to content

Instantly share code, notes, and snippets.

@yamin8000
yamin8000 / !CsvFromListMain.kt
Last active August 15, 2022 06:51
Create CSV from a Kotlin List
fun main() {
val firstCategory = Category(0, "Phone")
val secondCategory = Category(1, "Laptop")
val categories = listOf(firstCategory, secondCategory)
val csv = csvOf(
listOf("id", "name"),
categories
) {
listOf(it.id.toString(), it.name)
}
@Mahoney
Mahoney / build.gradle.kts
Created May 6, 2020 12:38
Run xvfb around gradle tests
plugins {
kotlin("jvm")
id("com.github.johnrengelman.processes") version "0.5.0"
}
val handle: Property<com.github.jengelman.gradle.plugins.processes.ProcessHandle> = project.objects.property()
val startXvfb by tasks.registering {
val processHandle = project.procs.fork(closureOf<ExecSpec> {
commandLine("/opt/X11/bin/Xvfb", ":99", "-ac")
@t-io
t-io / xvfb_screen_recording.py
Created November 17, 2017 10:34
ScreenRecording xvfb
from selenium import webdriver
import sys, getopt, time, subprocess, shlex
from xvfbwrapper import Xvfb
def run():
print('Sreencast website animation')
xvfb = Xvfb(width=1280, height=720, colordepth=24)
xvfb.start()
@int128
int128 / RequestAndResponseLoggingFilter.java
Last active January 13, 2024 10:46
Spring Web filter for logging request and response
/*
Copyright 2017 Hidetake Iwata
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@corbanb
corbanb / pre-request-jwt.js
Last active February 21, 2024 14:47
JWT tokenize - Postman Pre-Request Script
function base64url(source) {
// Encode in classical base64
encodedSource = CryptoJS.enc.Base64.stringify(source);
// Remove padding equal characters
encodedSource = encodedSource.replace(/=+$/, '');
// Replace characters according to base64url specifications
encodedSource = encodedSource.replace(/\+/g, '-');
encodedSource = encodedSource.replace(/\//g, '_');