Skip to content

Instantly share code, notes, and snippets.

View mtavkhelidze's full-sized avatar
🇬🇪
OOP is an exceptionally bad idea which could only have originated in California.

Misha Tavkhelidze mtavkhelidze

🇬🇪
OOP is an exceptionally bad idea which could only have originated in California.
View GitHub Profile
@mtavkhelidze
mtavkhelidze / intellij.vmoptions
Created January 23, 2019 10:32
Help -> Edit Custom VM Options
# custom IntelliJ IDEA VM options
# https://docs.oracle.com/javase/8/docs/technotes/tools/unix/java.html
-ea
-Xms4096m
-Xmx8192m
-XX:CMSInitiatingOccupancyFraction=65
-XX:MaxMetaspaceSize=512m
-XX:MaxTenuringThreshold=1
@mtavkhelidze
mtavkhelidze / example.ts
Created January 22, 2019 09:23 — forked from lierdakil/example.ts
An example of Functor in TypeScript. You can run this on https://www.typescriptlang.org/play/
interface Functor<T> {
map<U>(f: (x: T) => U): Functor<U>
}
class Box<T> implements Functor<T> {
value: T
constructor(x: T) {
this.value = x
}
map<U>(f: (x: T) => U): Box<U> {
@mtavkhelidze
mtavkhelidze / range.js
Last active October 29, 2019 08:39
Some fun with lazy evaluation in JavaScript.
/**
* @constructor
*/
function* range(from, until) {
let i = from;
const stop = until ? i => i >= until : () => false;
while (true) {
if (!stop(i)) {
yield i;
} else {
@mtavkhelidze
mtavkhelidze / curry.js
Created August 10, 2018 06:46
Curry the hell out of any function (JavaScript)
/**
* Curry the hell out of any function.
*
* @param f function
* @returns function
*/
function curry(f) {
const arity = f.length;
// preserve original `this` in case we're curring a class method;
@mtavkhelidze
mtavkhelidze / repeat-until.scala
Created July 8, 2018 17:23
Mimicking loops in Scala
import scala.language.reflectiveCalls
def repeat(command: => Unit) = new {
def until(condition: => Boolean): Unit =
if (condition) {
command
until(condition)
} else ()
}
@mtavkhelidze
mtavkhelidze / OrderedSet.js
Last active July 8, 2018 13:26
Ordered set data structure in JavaScript from Functional Program Design in Scala course by Martin Odersky.
function NonEmpty(elem, left, right) {
const contains = (x) => {
if (x < elem)
return left.contains(x);
else if (x > elem)
return right.contains(x);
else if (x === elem)
return true;
else

Keybase proof

I hereby claim:

  • I am mtavkhelidze on github.
  • I am mtavkhelidze (https://keybase.io/mtavkhelidze) on keybase.
  • I have a public key ASAnwKsslY4uA6pNahXu0wZsr_kIhXEhY0es1CW357irrwo

To claim this, I am signing this object:

@mtavkhelidze
mtavkhelidze / unmp
Created June 4, 2018 08:12
Update local or global npm packages
#!/usr/bin/env bash
function usage() {
echo "Usage: $(basename $0) -l/-u [-g -h]" 1>&2
echo "Options are:" 1>&2
echo " -l list packages" 1>&2
echo " -u update packages" 1>&2
echo " -g go global" 1>&2
echo " -h show this help" 1>&2
exit 1
@mtavkhelidze
mtavkhelidze / curry.js
Created March 31, 2018 12:12
Curry any JavaScript function as many times as you like.
Function.prototype.curry = function () {
const slice = Array.prototype.slice;
const args = slice.apply(arguments);
const that = this;
return function () {
return that.apply(null, args.concat(slice.apply(arguments)));
};
};
const fn = (x1, x2, x3) => {
@mtavkhelidze
mtavkhelidze / remove_android_studio.sh
Last active October 25, 2017 06:40 — forked from tahmidsadik/purgeAndroid.txt
How to completely remove Android Studio from Mac OS X
#!/usr/bin/env bash
# Remove Android Studio from your macOs
dry_run=true
while getopts "f" opt; do
case $opt in
f)
dry_run=false