Skip to content

Instantly share code, notes, and snippets.

🇬🇪
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.
Block or report user

Report or block mtavkhelidze

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@mtavkhelidze
mtavkhelidze / Option.js
Created Jul 22, 2019
Option Monad in JavaScript
View Option.js
export class Monad {
// pure :: a -> M a
pure() {
throw Error("pure method needs to be implemented");
};
// flatMap :: # M a -> (a -> M b) -> M b
flatMap(x) {
throw Error("flatMap method needs to be implemented");
};
@mtavkhelidze
mtavkhelidze / Alamofire.request.error.handling.swift
Created Jul 21, 2019 — forked from perlguy99/Alamofire.request.error.handling.swift
Alamofire Request Error Handling - From their documentation
View Alamofire.request.error.handling.swift
Alamofire.request(urlString).responseJSON { response in
guard case let .failure(error) = response.result else { return }
if let error = error as? AFError {
switch error {
case .invalidURL(let url):
print("Invalid URL: \(url) - \(error.localizedDescription)")
case .parameterEncodingFailed(let reason):
print("Parameter encoding failed: \(error.localizedDescription)")
print("Failure Reason: \(reason)")
@mtavkhelidze
mtavkhelidze / intellij.vmoptions
Created Jan 23, 2019
Help -> Edit Custom VM Options
View intellij.vmoptions
# 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 Jan 22, 2019 — forked from lierdakil/example.ts
An example of Functor in TypeScript. You can run this on https://www.typescriptlang.org/play/
View example.ts
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 Jan 14, 2019
Some fun with lazy avaluation in JavaScript.
View range.js
/**
* @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 Aug 10, 2018
Curry the hell out of any function (JavaScript)
View curry.js
/**
* 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 Jul 8, 2018
Mimicking loops in Scala
View repeat-until.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 Jul 8, 2018
Ordered set data structure in JavaScript from Functional Program Design in Scala course by Martin Odersky.
View OrderedSet.js
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
View keybase.md

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 Jun 4, 2018
Update local or global npm packages
View unmp
#!/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
You can’t perform that action at this time.