Skip to content

Instantly share code, notes, and snippets.

Eugenio Marletti Takhion

Block or report user

Report or block Takhion

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
rock3r / normalizeColorHex.kts
Last active Mar 24, 2019
A Kotlin script to normalize hex colour representations ("#RGB", "#ARGB", "#RRGGBB", "#AARRGGBB") into "#AARRGGBB", useful for when you're trying to find all unique colours in your app
View normalizeColorHex.kts
* ----------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
* Sebastiano Poggi wrote this file. As long as you retain this notice you
* can do whatever you want with this stuff. If we meet some day, and you think
* this stuff is worth it, you can buy me a beer in return. Seb
* ----------------------------------------------------------------------------
* Feel free to attribute this code in compiled products if you feel like it,
* but it's not required.
Takhion / ExhaustiveWhen.kt
Last active Nov 19, 2019
Exhaustive `when` mapping in Kotlin
View ExhaustiveWhen.kt
@file:Suppress("PackageDirectoryMismatch") // root package looks great when importing, ie. `import exhaustive`
* Allows requiring an exhaustive mapping in a `when` block when used with the [rangeTo] operator.
* @sample [exhaustive_when_example]
@Suppress("ClassName") // lowercase because it should look like a keyword
object exhaustive {
porglezomp / Leftpad.idr
Last active Oct 22, 2018
Taking on Hillel's challenge to formally verify leftpad (
View Leftpad.idr
import Data.Vect
-- `minus` is saturating subtraction, so this works like we want it to
eq_max : (n, k : Nat) -> maximum k n = plus (n `minus` k) k
eq_max n Z = rewrite minusZeroRight n in rewrite plusZeroRightNeutral n in Refl
eq_max Z (S _) = Refl
eq_max (S n) (S k) = rewrite sym $ plusSuccRightSucc (n `minus` k) k in rewrite eq_max n k in Refl
-- The type here says "the result is" padded to (maximum k n), and is padding plus the original
leftPad : (x : a) -> (n : Nat) -> (xs : Vect k a)
findepi /
Last active Jan 31, 2020
sort commits for GitHub's sake
git rebase "$(git merge-base HEAD master)" -x 'git commit --amend -C HEAD --date="$(date -R)" && sleep 1.05'
willhbr / Units.kt
Created May 23, 2017
Type-safe unit conversion with composite units
View Units.kt
* Based on Ben Trengrove's example:
package units
import java.util.concurrent.TimeUnit
abstract class Unit(val suffix: String, val ratio: Double) {
internal fun convertToBaseUnit(amount: Double) = amount * ratio
internal fun convertFromBaseUnit(amount: Double) = amount / ratio
thebitguru / facebook-photo-download.go
Created Jan 14, 2017
A simple go program to download all the high resolution pictures from your facebook albums.
View facebook-photo-download.go
package main
* A simple go program to download all the high resolution pictures from your facebook albums.
* To run this:
* 1. Go to
* 2. Get an Access Token: Get Token > Get User Access Token > Check "user_photos"
* 3. Paste in the app.
habemus-papadum / main.swift
Last active Nov 27, 2019
Single File Swift 3 Gui Sample
View main.swift
// A reminder to myself on how to quickly create a throw away gui app on OSX (i.e. a single file,
// w/o relying on XCode project templates
//Notes: In general it is hard to know how to create a Cocoa based gui without using XCode.
//This issue has existed for both Objective-C and now Swift
//Furthermore, Swift<-->Cocoa syntax has changed dramatically over various Swift versions,
//making stackoverflow posts unreliable
//This file provides a template for creating a throw away gui app
nickbutcher / 1_drawable_ic_hash_io16.xml
Last active Jan 8, 2020
Animated Stroke. The google I/O website this year ( has some funky animated lettering. I especially liked the animated stroke around the letters and wondered how you might implement that on Android. Turns out that AnimatedVectorDrawable makes this very easy! Here's how it looks:…
View 1_drawable_ic_hash_io16.xml
<?xml version="1.0" encoding="utf-8"?>
Copyright 2016 Google Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
tiwiz / build.gradle
Last active Jun 12, 2018
How to make Retrolambda work with both Mac OS X and Windows. Thanks to @Takhion -
View build.gradle
import org.gradle.internal.os.OperatingSystem;
String getJavaHome(String version) {
def stdout = new ByteArrayOutputStream()
exec {
commandLine "/usr/libexec/java_home", "-v", version
standardOutput = stdout;
return stdout.toString().trim()
mapsam /
Last active Jan 6, 2020
Namecheap > Github pages

Namecheap > Github pages

Pointing your domains to a gh-pages branch requires three steps.

  1. Add the Github IPs as A records on Namecheap. Both Github IPs are and
  2. Add your Github domain as the CNAME alias on Namecheap. (mind the extra period!)
  3. Add a CNAME with your new domain name in your repository. lowercase and nothing else
You can’t perform that action at this time.