Skip to content

Instantly share code, notes, and snippets.

View gelin's full-sized avatar

Denis Nelubin gelin

View GitHub Profile
@gelin
gelin / Pair.java
Created February 20, 2020 15:44
A Pair of elements
/**
* A pair of any objects with correct equals() and hashCode() overridden.
* @param <T> type of the fist element of the pair
* @param <U> type of the second element of the pair
*/
public final class Pair<T, U> {
private final T first;
private final U second;
@gelin
gelin / snippet.md
Created February 20, 2020 15:43
OpenJDK 8 in Debian 8

You need to add the Backports repository where the OpenJDK 8 package is located.

Add the file /etc/apt/sources.list.d/backports.list with this content:

# Backports repository
deb  http://ftp.debian.org/debian jessie-backports main contrib non-free

(You may replace http://ftp.debian.org/debian with any closer mirror, or even http://httpredir.debian.org/debian.)

@gelin
gelin / java-systemd-jessie.md
Created February 20, 2020 15:40
Java Systemd Service on Debian Jessie

Java Systemd Service on Debian Jessie

Systemd

Make sure systemd is installed.

systemctl

This command should list all installed services.

@gelin
gelin / remove_old_file_from_slack.py
Created February 20, 2020 15:39
Script to delete old files from Slack
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
from urllib.parse import urlencode, urlparse, parse_qs
import webbrowser
import http.server
import socketserver
from datetime import datetime, timedelta
import requests
@gelin
gelin / cue-split.sh
Created February 20, 2020 15:38
Script to split flac/ape CD rips by cue data and encode tracks to ogg vorbis files
#!/bin/sh
# Script to split flac/ape CD rips by cue data and encode tracks to ogg vorbis files.
#
# Put the script to a directory in your PATH.
#
# And then go to a directory containing .cue file and .flac/.ape file and run the command:
# cue-split.sh
#
# Or if the .cue is not in utf-8, decode it providing the -c flag with the original encoding:
@gelin
gelin / UpsertTask.java
Created February 20, 2020 15:37
SOLID Java 8
public class UpsertTask {
private interface Executor {
void execute() throws TaskExecutionException;
}
private Executor executeMethod;
public void prepare() {
if (/*something*/) {
import java.util.HashMap;
import java.util.Map;
public class IocKeySample {
public static class Key<T> {
private final String key;
private Key(String key) {
@gelin
gelin / GenericsTest.java
Created February 20, 2020 15:34
Small test for generic method to return parametrized type
import java.util.HashMap;
import java.util.Map;
// http://stackoverflow.com/questions/3437897/how-to-get-a-class-instance-of-generics-type-t
public class GenericsTest {
public static class MyClass extends Object {
}
@gelin
gelin / cp4prology.py
Created February 20, 2020 15:32
Copy/convert audio files to car audio: convert file to mp3, apply mp3gain, convert tags to ascii
#!/usr/bin/python
# -*- coding: utf-8 -*-
from __future__ import print_function
import sys
import os
import os.path
import shutil
import subprocess
import glob
import org.junit.Test;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;
import static org.junit.Assert.assertEquals;