Skip to content

Instantly share code, notes, and snippets.

View notxcain's full-sized avatar
🏠
Working from home

Denis Mikhaylov notxcain

🏠
Working from home
View GitHub Profile
package data
import monocle.Lens
trait HasLens[A, B] {
def lens: Lens[A, B]
}
object HasLens extends HasLensSyntax0
@derekjw
derekjw / Fs2MapAsync.scala
Created April 23, 2018 10:08
ordered mapAsync for fs2
import cats.implicits._
import cats.effect.Effect
import fs2.{Pipe, Stream}
import fs2.async.Promise
import fs2.async.mutable.Queue
import scala.concurrent.ExecutionContext
def mapAsync[F[_]: Effect, A, B](parallelism: Int)(f: A => F[B])(implicit executionContext: ExecutionContext): Pipe[F, A, B] = { stream =>
Stream.eval(Queue.bounded[F, Option[F[Either[Throwable, B]]]](parallelism)).flatMap { q =>
@dannote
dannote / final-cut-pro-trial-reset.swift
Last active February 22, 2024 11:43
Final Cut Pro X trial reset
#!/usr/bin/swift
import Foundation
let path = URL(fileURLWithPath: NSString(string: "~/Library/Application Support/.ffuserdata").expandingTildeInPath)
let data = try! NSData(contentsOf: path) as Data
let dictionary = try! NSKeyedUnarchiver.unarchiveTopLevelObjectWithData(data) as! NSDictionary
let mutableDictionary = dictionary.mutableCopy() as! NSMutableDictionary
for (key, value) in mutableDictionary {
@chpatrick
chpatrick / typeable-reify
Last active September 2, 2017 07:53
Black magic and GADT serialization
# Black magic and GADT serialization
I thought it would be a cool exercise to write a simple but flexible RPC system in Haskell. The idea was that the server would have some functions and values available for you to use, and you can assemble them into a function call as you like, or provide your own parameters. In the end, writing the serialization and deserialization code ended up leading to some far more interesting challenges.
Some types, such as functions, cannot be serialized so they must be made available on the server. I represented this with the following GADT:
```haskell
type ValueID = Word32
type TypeID = Word32
@aras-p
aras-p / preprocessor_fun.h
Last active February 28, 2024 08:38
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@endolith
endolith / Has weird right-to-left characters.txt
Last active March 28, 2024 04:56
Unicode kaomoji smileys emoticons emoji
ּ_בּ
בּ_בּ
טּ_טּ
כּ‗כּ
לּ_לּ
מּ_מּ
סּ_סּ
תּ_תּ
٩(×̯×)۶
٩(̾●̮̮̃̾•̃̾)۶