Skip to content

Instantly share code, notes, and snippets.

View markus1189's full-sized avatar

Markus Hauck markus1189

  • Frankfurt am Main, Germany
View GitHub Profile
@unoexperto
unoexperto / patch_apk_for_sniffing.md
Last active May 13, 2024 04:15
How to patch Android app to sniff its HTTPS traffic with self-signed certificate

How to patch Android app to sniff its HTTPS traffic with self-signed certificate

  • Download apktool from https://ibotpeaches.github.io/Apktool/
  • Unpack apk file: java -jar /home/expert/work/tools/apktool.jar d net.flixster.android-9.1.3@APK4Fun.com.apk
  • Modify AndroidManifest.xml by adding android:networkSecurityConfig="@xml/network_security_config" attribute to application element.
  • Create file /res/xml/network_security_config.xml with following content:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
    <base-config>
@sgrankin
sgrankin / tagged.scala
Created July 14, 2017 15:24
scala tagged types
import com.twitter.bijection.Bijection
package object tagging {
sealed trait Tagged[+V, +T]
type @@[+V, +T] = V with Tagged[V, T]
object Tagged {
implicit class Untaggable[V, T](val tagged: V @@ T) extends AnyVal {
@inline def untag: V = tagged
}
@nh2
nh2 / ParallelConduit.hs
Last active August 31, 2018 20:33
DEPRECATED, use https://github.com/nh2/conduit-concurrent-map instead. Previous: Haskell: Shows how to make a conduit that maps a function in parallel over incoming elements, but maintains input order
#!/usr/bin/env stack
-- stack --resolver lts-8.12 script
-- Run this example with: `stack ParallelConduit.hs`
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE FlexibleContexts #-}
@treeowl
treeowl / BasicNat.hs
Last active December 13, 2023 15:12
Fast total sorting of arbitrary Traversable containers
{-# LANGUAGE DataKinds, TypeFamilies, TypeOperators, GADTs,
ScopedTypeVariables, TypeOperators #-}
-- | Type-level natural numbers and singletons, with proofs of
-- a few basic properties.
module BasicNat (
-- | Type-level natural numbers
Nat (..)
, type (+)
@agent4788
agent4788 / HS100.java
Last active November 17, 2023 13:34
Mit dieser kleinen API kann man die TP-Link HS100 und HS110 Wlan Steckdosen direkt aus Java ansteuern.
package de.test;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.InetAddress;

Explaining Miles's Magic

Miles Sabin recently opened a pull request fixing the infamous SI-2712. First off, this is remarkable and, if merged, will make everyone's life enormously easier. This is a bug that a lot of people hit often without even realizing it, and they just assume that either they did something wrong or the compiler is broken in some weird way. It is especially common for users of scalaz or cats.

But that's not what I wanted to write about. What I want to write about is the exact semantics of Miles's fix, because it does impose some very specific assumptions about the way that type constructors work, and understanding those assumptions is the key to getting the most of it his fix.

For starters, here is the sort of thing that SI-2712 affects:

def foo[F[_], A](fa: F[A]): String = fa.toString
@ion1
ion1 / PeirceLEM.hs
Last active July 10, 2022 02:24
Exercise: prove Peirce’s law <=> law of excluded middle in Haskell
-- Exercise: prove Peirce’s law <=> law of excluded middle in Haskell
{-# LANGUAGE Rank2Types #-}
import Data.Void
type Not a = a -> Void
type Peirce = forall a b. ((a -> b) -> a) -> a
type LEM = forall a. Either (Not a) a
-- Example of a dynamically generated FromJSON instance.
--
-- Can be useful when one needs to use a function with a
-- FromJSON constraint, but some detail about the
-- conversion from JSON is not known until runtime.
{-# LANGUAGE Rank2Types #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE OverloadedStrings #-}
@chrisdone
chrisdone / typing.md
Last active May 9, 2024 15:27
Typing Haskell in Haskell

Typing Haskell in Haskell

MARK P. JONES

Pacific Software Research Center

Department of Computer Science and Engineering

Oregon Graduate Institute of Science and Technology

@mvr
mvr / gist:8081429
Last active November 10, 2023 02:36
A Whirlwind Tour of Combinatorial Games in Haskell
A Whirlwind Tour of Combinatorial Games in Haskell
==================================================
Combinatorial games are an interesting class of games where two
players take turns to make a move, changing the game from one position
to another. In these games, both players have perfect information
about the state of the game and there is no element of chance. In
'normal play', the winner is declared when the other player is unable
to move. A lot of famous strategy games can be analysed as
combinatorial games: chess, go, tic-tac-toe.