Skip to content

Instantly share code, notes, and snippets.

View theAkito's full-sized avatar
💭
Never complain, never explain.

Akito theAkito

💭
Never complain, never explain.
View GitHub Profile
@aanandshekharroy
aanandshekharroy / ParameterizedUnitTest.kt
Created February 10, 2018 11:04
Used JUnitParams to create parametrized unit test in Kotlin
import junitparams.JUnitParamsRunner
import junitparams.Parameters
import org.junit.Test;
import org.junit.Assert.*;
import org.junit.Before
import org.junit.runner.RunWith
import org.junit.runners.Parameterized
import java.util.*
@shannah
shannah / batsh.php
Created February 4, 2021 18:50
A simple PHP script for compiling Batsh scripts to bash and windows bat scripts. This is a thin wrapper around the hosted batsh compiler at https://batsh.org
<?php
/**
Copyright (c) 2021 Steve Hannah
Permission is hereby granted, free of charge,
to any person obtaining a copy of this software and
associated documentation files (the "Software"), to
deal in the Software without restriction, including
without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell
@fish2000
fish2000 / iphonebackupdb-by-markus-stenberg.py
Created October 28, 2012 12:00
Python scripts for pillaging data from iOS backup files
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# -*- Python -*-
#
# http://www.employees.org/~mstenber/iphonebackupdb.py
#
# $Id: iphonebackupdb.py,v 1.2 2010/05/28 08:30:38 mstenber Exp $
#
# Author: Markus Stenberg <fingon@iki.fi>
#
@adaRn
adaRn / etc logrotate.d openvpn
Created August 15, 2019 14:33
This is logrotate configuration for OpenVPN. It prevents you from huge OpenVPN log files. `copytruncate` option here is very important - OpenVPN doesn't want to close the logfile it's writing to, so this file is automatically truncated after copying its contents.
/var/log/openvpn.log {
daily
rotate 12
compress
copytruncate
delaycompress
missingok
notifempty
}
@mreichelt
mreichelt / KotlinMapIntersection.kt
Created August 13, 2018 11:25
Kotlin: Intersect maps with different value types on their keys
/**
* Intersect two maps with same keys, but different data types. Preserves the order of the first map.
* Returns a list of the combined type provided by the transformation.
*/
inline fun <Key, Value1, Value2, T> Map<Key, Value1>.intersectWith(
other: Map<Key, Value2>,
transformationFunction: (Value1, Value2) -> T): List<T> {
return flatMap { oldEntry ->
other.filterKeys { it == oldEntry.key }
.map { transformationFunction(oldEntry.value, it.value) }
@deeagle
deeagle / repair-debian-lib-XCRYPT_2.0.sh
Last active April 15, 2023 23:27
Simple fix for a debian linux upgrade to bullseye. Some packages will show an error message like `/usr/bin/perl: /lib64/libcrypt.so.1: version `XCRYPT_2.0' not found (required by /usr/bin/perl` and you have to link the new spot of the library. Update: I have to run it before installs and upgrades and everything is fine.
#!/bin/bash
# Needed for debian upgrade
# atm from buster to bullseye the linked libs are broken
# see: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=951880
LIB="libcrypt.so.1"
# Checks if the executer has super user permissions.
#
@ygoe
ygoe / ManagedUnixCrypt.cs
Created August 30, 2020 17:48
A managed implementation of the Unix C library crypt function. Supports MD5, SHA-256 and SHA-512.
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
namespace YourApp.Util
{
/// <summary>
/// A managed implementation of the Unix C library crypt function. It supports the MD5, SHA-256
/// and SHA-512 algorithms.
@Arham4
Arham4 / data.yaml
Last active September 20, 2023 01:26
Easy Jackson YAML Parsing with Kotlin
username: "Test"
password: "123456"
@josdejong
josdejong / merge.kt
Last active October 24, 2023 09:30
Merge two data classes in Kotlin
import kotlin.reflect.full.declaredMemberProperties
import kotlin.reflect.full.primaryConstructor
/**
* Merge two data classes
*
* The resulting data class will contain:
* - all fields of `other` which are non null
* - the fields of `this` for the fields which are null in `other`
*
@jonpacker
jonpacker / gist:2107554
Created March 19, 2012 10:59
Force unmount a nonresponsive SSHFS
kill -9 <sshfs pid>
fusermount -u <mountpoint>