Skip to content

Instantly share code, notes, and snippets.

View malzzz's full-sized avatar

Mallory M. malzzz

  • Asymmetric Finance
  • /dev/null
View GitHub Profile
@mattt
mattt / uiappearance-selector.md
Last active March 19, 2024 12:52
A list of methods and properties conforming to `UIAppearance` as of iOS 12 Beta 3

Generate the list yourself:

$ cd /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.sdk/System/Library/Frameworks/UIKit.framework/Headers
$ grep UI_APPEARANCE_SELECTOR ./*     | \
  sed 's/NS_AVAILABLE_IOS(.*)//g'     | \
  sed 's/NS_DEPRECATED_IOS(.*)//g'    | \
  sed 's/API_AVAILABLE(.*)//g'        | \
  sed 's/API_UNAVAILABLE(.*)//g'      | \
 sed 's/UI_APPEARANCE_SELECTOR//g' | \
@Mortimerp9
Mortimerp9 / readerwithtooling.scala
Created April 14, 2013 22:14
An implementation of the Reader Monad in scala, with correct type variance and some implicit utils to simplify the daily use of Readers, In particular with Future.
/**
* A monad to abstract dependencies in the code, see https://coderwall.com/p/kh_z5g
*/
object Reader {
/**
* an implicit to convert a function A => B in a Reader[A, B]
*/
implicit def reader[C, R](block: C => R): Reader[C, R] = Reader(block)
@mergeconflict
mergeconflict / Inject.scala
Created May 28, 2013 18:16
"dependency injection" monad (for the lulz)
case class Inject[-E, +A](inject: E => A) {
// covariant functor and monad
def map[B](f: A => B): Inject[E, B] =
Inject { e => f(inject(e)) }
def flatMap[ε <: E, B](f: A => Inject[ε, B]): Inject[ε, B] =
Inject { e => f(inject(e)).inject(e) }
// to satisfy for-comprehension desugaring in scala < 2.10
def filter(f: A => Boolean): Inject[E, A] =
@viktorklang
viktorklang / CallbackExecutionContext.scala
Created September 7, 2013 21:42
Creates an ExecutionContext inside an Actor that will execute the runnables inside the Actor receive block, so that the risk of closing over Actor internals is less problematic.
//Warning: Uses Akka internal APIs (not binary compatible),
//can be written not to depend on that but implemented like this for brevity.
package akka.util
trait CallbackExecutionContext { this: akka.actor.Actor ⇒
// Defines our signal for callback execution
case object Execute
// ``SerializedSuspendableExecutionContext`` is Akka-internal
private[this] final val ssec: SerializedSuspendableExecutionContext = {
@larsrh
larsrh / church.scala
Created September 24, 2013 19:55
Church encoding in Scala
// rank 1
type num[a] = (a => a) => a => a
def zero[a]: num[a] = f => x => x
def succ[a](n: num[a]): num[a] = f => x => f(n(f)(x))
def eval(n: num[Int]): Int = n(_ + 1)(0)
// rank 2
@loosechainsaw
loosechainsaw / fuckyeahreadermonad.scala
Created November 6, 2013 12:16
Fuck Yeah Reader Monad
package examples.monads
case class User(id: Int, username: String, name: String)
trait UserRepository{
def getById(id: Int) : Option[User]
def save(user: Option[User]) : Unit
}
trait UserService{
@judotens
judotens / bitcoinkey.sh
Last active December 2, 2023 07:03
Scrape BitCoin private keys from directory.io
#!/bin/bash
# scrape all leaked bitcoin private keys into a tab separated text
# <private key>\t<bitcoin_address>
#
# support autoresume. just add these line into your cron : * * * * bash bitcoinkey.sh
# results stored on keys.txt
if [ ! -f last.page ]; then prev=`echo 0`; else prev=`cat last.page`; fi;
if [ -z $1 ]; then akhir=`echo 10`; else akhir=`echo $1`; fi;
abis=$(($prev+$akhir))
@nairbv
nairbv / gist:7923811
Created December 12, 2013 06:02
An example of using a Manifest to get around type erasure
scala> def foo[T : Manifest](a : List[T]) = {
| val m = implicitly[Manifest[T]]
| val I = classOf[Int]
| val S = classOf[String]
| m.erasure match {
| case I => "hi"
| case S => "bye"
| case _ => "whatever"
| }
| }
@shinnya
shinnya / ReaderMonad.scala
Last active September 10, 2017 06:22
Reader Monad
/*
* Copyright (C) 2017 Shinya Yamaoka
* Licensed under the MIT License.; you may not use this file except in
* compliance with the license. You may obtain a copy of the License at
* https://opensource.org/licenses/mit-license.php
*/
object ReaderMonad {
class Reader[-E, +R] private (g: E => R) {
def apply(env: E): R = g(env)
@xuwei-k
xuwei-k / FreeT.scala
Last active September 12, 2016 00:26
import scalaz._
object Tram {
type Tram[A] = FreeT[Function0, Id.Id, A]
implicit val instance: Monad[Tram] = FreeT.freeTMonad[Function0, Id.Id]
def suspend[A](a: => Tram[A]): Tram[A] =
instance.point(a).flatMap(conforms)