Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View thatwist's full-sized avatar
👣

Yuri Ostapchuk thatwist

👣
View GitHub Profile
@thatwist
thatwist / ForkJoinTest.java
Last active June 30, 2020 15:32
Simple ForkJoin program on Java
import java.util.concurrent.RecursiveTask;
import java.util.concurrent.ForkJoinPool;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
public interface Node {
Collection<Node> getChildren();
long getValue();
@thatwist
thatwist / CapsLockCtrlEscape.ahk
Created July 30, 2019 10:46 — forked from sedm0784/CapsLockCtrlEscape.ahk
AutoHotkey script to map Caps Lock to Escape when it's pressed on its own and Ctrl when used in combination with another key, à la Steve Losh. Adapted from one that does something similar with the Ctrl Key on the Vim Tips Wiki (http://vim.wikia.com/wiki/Map_caps_lock_to_escape_in_Windows?oldid=32281). (Plus contribs from @randy909 & @mmikeww.)
g_LastCtrlKeyDownTime := 0
g_AbortSendEsc := false
g_ControlRepeatDetected := false
*CapsLock::
if (g_ControlRepeatDetected)
{
return
}
@thatwist
thatwist / wirth-weber-prcedence-relationship.c
Last active March 30, 2018 12:12
Checks Wirth–Weber precedence relationship. This is an old piece of code I wrote in university - this is scary but it works.
/******************************************************************/
/* */
/* Dodatok do kyrsovoji robotu "Gramatuku peredyvannja". */
/* Programa realizyje algorutm 'perenos-zfortka' */
/* perevirjaje nalezhnist' vvedenoji */
/* stri4ku do zadanoji gramatuku. */
/* */
/******************************************************************/
@thatwist
thatwist / java_oracle_install.sh
Created March 30, 2018 11:56
Install Oracle Java Unix / ARM
#!/usr/bin/env bash
wget --no-cookies \
--no-check-certificate \
--header "Cookie: oraclelicense=accept-securebackup-cookie" \
"http://download.oracle.com/otn-pub/java/jdk/8u162-b12/0da788060d494f5095bf8624735fa2f1/jdk-8u162-linux-arm64-vfp-hflt.tar.gz" \
-O jdk-8u162-linux-arm64.tar.gz
tar -xzvf jdk-8u162-linux-arm64.tar.gz
sudo mkdir /usr/lib/jvm
@thatwist
thatwist / phone_number_to_words.scala
Created December 6, 2017 18:47
Parses a phone number and finds all possible words based on numpad-to-letter mapping and dictionary
trait SolutionDef { self: DictionaryDef with DebugDef =>
/*
* based on the example included:
* 866-5548 -> tool-kit
* the assumption is made that '-' symbol position doesn't matter
* and it's not a word divider
* e.g. any of those groups of numbers can make up a final sequence of words:
* 86 65548, 86665 548, 86 655 48, etc.
*
* here is no phone number format specified as every coutry has its own
@thatwist
thatwist / prime_product_palindrome.scala
Created December 6, 2017 18:41
Finds biggest palindrome which is a product of two prime numbers
import scala.annotation.tailrec
import scala.collection.parallel.mutable
object Solution extends App {
def isPalindrome(n: Int): Boolean = {
var num = n
//reversing number
var rev = 0
var rmd = 0
@thatwist
thatwist / keybase.md
Last active June 30, 2020 15:31
Keybase init

Keybase proof

I hereby claim:

  • I am thatwist on github.
  • I am twist522 (https://keybase.io/twist522) on keybase.
  • I have a public key ASAtWVnpEzz3VRtNWYMRv-m-efc1Cl2g88_8iXASBf2pUQo

To claim this, I am signing this object:

@thatwist
thatwist / Projections.scala
Last active April 6, 2016 22:50
Trying to project map to tuples in typesafe way (think I need shapeless here :-P)
object Projections {
object MapUtils {
implicit class MapWithGetAsInstanceOf[A](map: Map[A, Any]) {
/** get by key and cast to T, exception if cannot cast */
def getAs[T](key: A): Option[T] = map.get(key).asInstanceOf[Option[T]]
}
}
@thatwist
thatwist / Romans.scala
Created November 24, 2015 11:40
Example of convertion decimal to romans until 4999 (with old rules) using tail recursion
import scala.annotation.tailrec
object App1 extends App {
import Romans._
assert(resolveRoman(3999) == "MMMCMXCIX")
assert(resolveRoman(0) == "—")
def read(): Unit = {