Skip to content

Instantly share code, notes, and snippets.

View GlulkAlex's full-sized avatar
🏠
Working from home

Alex Glukhovtsev GlulkAlex

🏠
Working from home
View GitHub Profile
@frgomes
frgomes / scala_base64_encode_decode.scala
Created July 28, 2017 12:39
Scala - Base64 encode/decode
// Base64 encode
val text = "This is plaintext."
val bytesEncoded = java.util.Base64.getEncoder.encode(text.getBytes())
// Base64 decode
val textDecoded = new String(java.util.Base64.getDecoder.decode(bytesEncoded))
println(textDecoded)
@tuxfight3r
tuxfight3r / 01.bash_shortcuts_v2.md
Last active May 2, 2024 09:06
Bash keyboard shortcuts

Bash Shortcuts

visual cheetsheet

Moving

command description
ctrl + a Goto BEGINNING of command line
@Zearin
Zearin / python_decorator_guide.md
Last active March 30, 2024 12:28
The best explanation of Python decorators I’ve ever seen. (An archived answer from StackOverflow.)

NOTE: This is a question I found on StackOverflow which I’ve archived here, because the answer is so effing phenomenal.


Q: How can I make a chain of function decorators in Python?


If you are not into long explanations, see [Paolo Bergantino’s answer][2].

@asaskevich
asaskevich / MainSandBox.java
Created July 26, 2014 10:07
Java Reflection - Remove "private final" modifiers and set/get value to field
package sandbox;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
public class MainSandBox {
public static void main(String[] args) throws Exception {
Example ex = new Example();
// Change private modifier to public
Field f = ex.getClass().getDeclaredField("id");
/**
* A tiny class that extends a list with four combinatorial operations:
* ''combinations'', ''subsets'', ''permutations'', ''variations''.
*
* You can find all the ideas behind this code at blog-post:
*
* http://vkostyukov.ru/posts/combinatorial-algorithms-in-scala/
*
* How to use this class.
*
@hanbzu
hanbzu / water_pouring.scala
Created November 4, 2013 13:16
Scala: water pouring problem solution
class Pouring(capacity: Vector[Int]) {
// States
type State = Vector[Int]
val initialState = capacity map (x => 0)
// Moves
trait Move {
// A method that defines state changes
def change(state: State): State
@dainkaplan
dainkaplan / Ansi.java
Last active February 2, 2024 15:12
Simple ANSI colors class for terminal code for JVM written in Scala and Java (two implementations)
package org.tempura.console.util;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Usage:
* <li>String msg = Ansi.Red.and(Ansi.BgYellow).format("Hello %s", name)</li>
* <li>String msg = Ansi.Blink.colorize("BOOM!")</li>