Skip to content

Instantly share code, notes, and snippets.

@aspineon
aspineon / kotlin.md
Created January 19, 2020 00:27 — forked from choongyouqi/kotlin.md
[Kotlin Cheatsheet] #Kotlin

Functions

fun makeMathFun(num1: Int): (Int) -> Int = { num2 -> num1 * num2 }

fun mathOnList(numList: Array<Int>, myFunc: (num1: Int) -> Int) {
    numList.forEach {
        println("it: $it: ${myFunc(it)}")
    }
}
@aspineon
aspineon / gist:1fdb9a0abed89ce2a0a2f2753c4b2d30
Created December 13, 2019 15:19 — forked from corvax19/openssh-encrypt-decrypt.txt
Simple text encryption/decryption with openssl
echo -n "That's the text"|openssl enc -e -aes-256-cbc -a
Encrypt with interactive password. Encrypted message is base64-encoded afterwards.
echo -n "That's the text"|openssl enc -e -aes-256-cbc -a -k "MySuperPassword"
Encrypt with specified password. Encrypted message is base64-encoded afterwards.
echo "GVkYiq1b4M/8ZansBC3Jwx/UtGZzlxJPpygyC"|openssl base64 -d|openssl enc -d -aes-256-cbc
Base-64 decode and decrypt message with interactive password.
echo "GVkYiq1b4M/8ZansBC3Jwx/UtGZzlxJPpygyC"|openssl base64 -d|openssl enc -d -aes-256-cbc -k "MySuperPassword"
@aspineon
aspineon / gist:95c833a922e431e9b34b1d0f31fdc419
Created December 11, 2019 17:25 — forked from dodyg/gist:5823756
Kotlin Programming Language Cheat Sheet Part 3

#Control Structures

##If statement

Kotlin if statement should look familiar with other language

fun main(args : Array<String>) {
 val total = 10
@aspineon
aspineon / gist:e743daa8fcf958f73a1aee8694cf6790
Created December 11, 2019 17:24 — forked from dodyg/gist:5616605
Kotlin Programming Language Cheat Sheet Part 2

This is a quick guide to Kotlin programming language. The previous part of this guide is here

#Object Oriented

fun main(args : Array<String>) {
  class local (val x : Int)
  
  val y = local(10)
 println("${y.x}")
@aspineon
aspineon / gist:c931aa35de5093232e664e69637bfc26
Created December 11, 2019 17:24 — forked from dodyg/gist:5823184
Kotlin Programming Language Cheat Sheet Part 1

#Intro

Kotlin is a new programming language for the JVM. It produces Java bytecode, supports Android and generates JavaScript. The latest version of the language is Kotlin M5.3

Kotlin project website is at kotlin.jetbrains.org.

All the codes here can be copied and run on Kotlin online editor.

Let's get started.

@aspineon
aspineon / Car.java
Created June 25, 2019 14:57 — forked from nielsutrecht/Car.java
Simple mockito example
public class Car {
private Engine engine;
private FuelTank fuelTank;
public Car(Engine engine, FuelTank fuelTank) {
this.engine = engine;
this.fuelTank = fuelTank;
}
public void start() {
@aspineon
aspineon / wildfly-install.sh
Created October 2, 2018 19:37 — forked from sukharevd/wildfly-install.sh
Script to install JBoss Wildfly 10.x as service in Linux
#!/bin/bash
#title :wildfly-install.sh
#description :The script to install Wildfly 10.x
#more :http://sukharevd.net/wildfly-8-installation.html
#author :Dmitriy Sukharev
#date :2016-06-18T02:45-0700
#usage :/bin/bash wildfly-install.sh
#tested-version1 :10.0.0.CR3
#tested-distros1 :Ubuntu 15.10; Debian 7,8; CentOS 7; Fedora 22
#tested-version2 :10.0.0.Final
@aspineon
aspineon / note.md
Created October 2, 2018 19:31 — forked from ChrisKujawa/note.md
Oracle with Jboss 7

Oracle

Run for example docker image

Jboss configuration

As first create model directory and add module.xml

$ mkdir -p server/jboss-as-7.2.0.Final/modules/com/oracle/jdbc/ojdbc14/main/ $ vim server/jboss-as-7.2.0.Final/modules/com/oracle/jdbc/ojdbc14/main/module.xml

Could look like this:

## Register driver
ARCHIVE_NAME=ojdbc6.jar
REPOSITORY_DIR=pathToDriver
SERVER_DIR=pathToWildfly
INSTALL_DIR=$SERVER_DIR/modules/system/layers/base/com/oracle/ojdbc6/main
SERVER_USER=petr
SERVER_PASSW=petr
mkdir -p $INSTALL_DIR
cp $REPOSITORY_DIR/$ARCHIVE_NAME $INSTALL_DIR
@aspineon
aspineon / gist:82fe84319efc74807330d294de3caf2e
Created August 16, 2018 04:32 — forked from roalcantara/gist:2342555
JAVA > Hibernate > Custom Validator Simple Sample
package com.xpto.domain.model.validator;
import javax.validation.Constraint;
import javax.validation.Payload;
import java.lang.annotation.*;
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = PhotoExtensionValidator.class)
@Documented