Skip to content

Instantly share code, notes, and snippets.

View pedrofurla's full-sized avatar

Pedro Furlanetto pedrofurla

View GitHub Profile
@pedrofurla
pedrofurla / gist:5792e128f8d46a1ea72227098f42bea2
Created March 9, 2020 05:16
American Airlines Wifi/Internet traceroutes and traceroute with VPN
┌──[pedrofurlanetto]─[~/VirtualDev/gritty]─ (AP-2097)
└─ $ traceroute google.com
traceroute to google.com (216.58.195.78), 64 hops max, 52 byte packets
1 ns.aainflight.com (172.19.248.1) 2.692 ms 2.603 ms 1.293 ms
2 10.24.80.1 (10.24.80.1) 3.106 ms 3.860 ms 3.312 ms
3 * * *
4 * * *
5 172.27.196.3 (172.27.196.3) 613.152 ms 611.821 ms 670.278 ms
6 * * *
7 * * *
@pedrofurla
pedrofurla / Eithers-from-hell.hs
Last active February 25, 2020 02:00
Either mixing up with IO and vice-versa to my first working version using ExceptT
run0 :: IO ()
run0 = do
args' <- getArgs
let args = input args'
dynImg <- sequence $ readImageWithMetadata . fst <$> args
let img = getImg $ join dynImg
let bytes = LB.pack . compress <$> img
let writeTmp = LB.writeFile . snd <$> args
wrote <- sequence $ do
bits' <- bytes
[
{
"enabled": true,
"id": 3,
"installDate": 1536816442591,
"md5Url": "https://update.userstyles.org/143865.md5",
"name": "Github Dark Material",
"originalDigest": "5a8bbc1965d3dca4ed85e6140f86a674df5be101",
"originalMd5": "deb02357ad89cbd66cb108482829b9fa",
"sections": [
@pedrofurla
pedrofurla / nth.scala
Last active October 9, 2018 00:51
So, a shop that claims to be doing FP thinks this is too functional
object Nth extends App {
// Problem: given two sorted lists (`as` and `bs` below) find the nth smaller element.
// It's assumed that `k <= as.length + bs.length`.
def nth(as:List[Int], bs:List[Int], k:Int):Int = (as, bs) match {
case (Nil, Nil) => ???
case (a :: as, b :: bs) if k==0 => Math.min(a,b)
case (a :: as, b :: bs) if a < b => nth(as, b :: bs, k-1)
case (a :: as, b :: bs) if a > b => nth(a :: as, bs, k-1)
@pedrofurla
pedrofurla / Applicative.hs
Created August 26, 2018 23:48
Why the declaring types drives GHC crazy?
lift3 ::
Applicative f =>
(a -> b -> c -> d)
-> f a
-> f b
-> f c
-> f d
lift3 f a b c =
{-let -- This produces the error below
g :: f (c -> d)
output :: Parser (Maybe OutFilename)
output =
( \x -> if x == "none" then Nothing else Just x ) <$> strOption
( long "output"
<> short 'o'
<> value "none"
<> metavar "FILENAME"
<> help "Output file" )
<|>
flag' Nothing
scala> :paste
// Entering paste mode (ctrl-D to finish)
class A[T] {
def add(n: Int)( env: T =:= Int = null): Boolean = if(env == null) true else false
}
val a = new A[Int]
a.add(1) // 2
object IsItTrue {
val maybe = false
object bs {
val hhh = 10
def inc(x:Int) = x + 1
def sum(x:Int)(y:Int) = x + y
}
}
def f = false
@pedrofurla
pedrofurla / Main-Decompiled.java
Created September 12, 2017 04:34 — forked from rahulmutt/Main-Decompiled.java
Polymorphism in Eta via Type Erasure
public static class id extends Function {
public Closure enter(StgContext context) {
// context.R(2) is the first argument of the function
// All id simply does is evaluate the argument -
// it cannot do much more!
return context.R(2).evaluate(context);
}
public int arity() { return 1; }
}
sbt.version=0.13.13