Skip to content

Instantly share code, notes, and snippets.

View kool79's full-sized avatar

Oleksandr Kulychok kool79

  • Astound Commerce
  • Ukraine, Vinnitsa
View GitHub Profile
@kool79
kool79 / ExcelToTable.java
Created August 10, 2023 02:39 — forked from ejwinter/ExcelToTable.java
Turn an Excel (xlsx) file with a single table in it into a Guava table with a header indexed
/**
* This class takes an Excel spreadsheet and converts it into a Guava Table format.
* When other formats of the file are to be supported (like CSV, TSV etc.,) implement the apply method with that format.
*/
@Component
public class ExcelToTableLoader implements TableGenerator<File> {
private static final Logger logger = org.slf4j.LoggerFactory.getLogger(ExcelToTableLoader.class);
@kool79
kool79 / crypto-aes-256-gcm-demo.js
Created February 19, 2021 23:51 — forked from rjz/crypto-aes-256-gcm-demo.js
example using node.js crypto API with aes-256-gcm
const buffer = require('buffer');
const crypto = require('crypto');
// Demo implementation of using `aes-256-gcm` with node.js's `crypto` lib.
const aes256gcm = (key) => {
const ALGO = 'aes-256-gcm';
// encrypt returns base64-encoded ciphertext
const encrypt = (str) => {
// Hint: the `iv` should be unique (but not necessarily random).
@kool79
kool79 / reuse-code.js
Created February 19, 2021 17:02 — forked from JamesMessinger/reuse-code.js
Saving JavaScript code to a variable in Postman
// Save common tests in a global variable
postman.setGlobalVariable("commonTests", () => {
// The Content-Type must be JSON
tests["Content-Type header is set"] = postman.getResponseHeader("Content-Type") === "application/json";
// The response time must be less than 500 milliseconds
tests["Response time is acceptable"] = responseTime < 500;
// The response body must include an "id" property
var data = JSON.parse(responseBody);
@kool79
kool79 / latency.txt
Created February 15, 2019 16:35 — forked from jboner/latency.txt
Latency Numbers Every Programmer Should Know
Latency Comparison Numbers (~2012)
----------------------------------
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns 3 us
Send 1K bytes over 1 Gbps network 10,000 ns 10 us
Read 4K randomly from SSD* 150,000 ns 150 us ~1GB/sec SSD
@kool79
kool79 / Jenkinsfile
Created February 8, 2019 18:37 — forked from jonico/Jenkinsfile
Example for a full blown Jenkins pipeline script with multiple stages, input steps, injected credentials, heroku deploy, sonarqube and artifactory integration, multiple Git commit statuses, PR merge vs branch build detection, REST API calls to GitHub deployment API, stage timeouts, stage concurrency constraints, ...
#!groovy
import groovy.json.JsonOutput
import groovy.json.JsonSlurper
/*
Please make sure to add the following environment variables:
HEROKU_PREVIEW=<your heroku preview app>
HEROKU_PREPRODUCTION=<your heroku pre-production app>
HEROKU_PRODUCTION=<your heroku production app>
@kool79
kool79 / commit-message-guidelines.md
Created September 25, 2018 16:22 — forked from robertpainsi/commit-message-guidelines.md
Commit message guidelines

Commit Message Guidelines

Short (72 chars or less) summary

More detailed explanatory text. Wrap it to 72 characters. The blank
line separating the summary from the body is critical (unless you omit
the body entirely).

Write your commit message in the imperative: "Fix bug" and not "Fixed
bug" or "Fixes bug." This convention matches up with commit messages
@kool79
kool79 / HelloWorld.java
Created May 22, 2018 17:41 — forked from lolzballs/HelloWorld.java
Hello World Enterprise Edition
import java.io.FileDescriptor;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
public class HelloWorld{
private static HelloWorld instance;
public static void main(String[] args){
instantiateHelloWorldMainClassAndRun();
@kool79
kool79 / macOS-in-virtualbox.md
Created February 21, 2018 20:20 — forked from rob-smallshire/macOS-in-virtualbox.md
Notes on getting macOS Sierra running in Virtualbox on a Windows 10 host

On Mac

Download, but don't run, the Sierra installer from the Mac App Store. This places the installer at /Applications/Install\ macOS\ Sierra.app/.

Now run the following commands to build a suitable VM image from the installer:

git clone https://github.com/jonanh/osx-vm-templates
cd osx-vm-templates/packer

sudo ../prepare_iso/prepare_vdi.sh -D DISABLE_REMOTE_MANAGEMENT -o macOS_10.12.vdi /Applications/Install\ macOS\ Sierra.app/ .

@kool79
kool79 / HibernateGenericDAO
Created September 6, 2017 09:14 — forked from mrserverless/HibernateGenericDAO
Hibernate GenericDAO using Class-Mate
class Device {}
class Router extends Device {}
class GenericDAO<T, ID extends Serializable> {
protected Class<T> persistentClass;
protected Class<ID> idClass;
private GenericDAO() {
List <ResolvedType> typeParameters = new TypeResolver().resolve(this.getClass()).typeParametersFor(GenericDAO.class);
this.persistentClass = (Class<T>) typeParameters.get(0).getErasedType();
@kool79
kool79 / Jenkinsfile
Created July 27, 2017 15:09 — forked from JJediny/Jenkinsfile
An example Declarative Pipeline Jenkinsfile for Feb 15 2017 demo
// A Declarative Pipeline is defined within a 'pipeline' block.
pipeline {
// agent defines where the pipeline will run.
agent {
// This also could have been 'agent any' - that has the same meaning.
label ""
// Other possible built-in agent types are 'agent none', for not running the
// top-level on any agent (which results in you needing to specify agents on
// each stage and do explicit checkouts of scm in those stages), 'docker',