Skip to content

Instantly share code, notes, and snippets.

Avatar
🎈
out of the comfort zone

Omar Ahmed nebtrx

🎈
out of the comfort zone
View GitHub Profile
@nebtrx
nebtrx / tg_styles.scala
Last active Mar 10, 2019
Tagless Final Styles
View tg_styles.scala
// 1. Accessing algebras through Type Class(the Fake Type Class Jhon mentioned in his TF dead talk)
// instance for F
class Service {
def fetchUserInfo[F[_]: Concurrent: UserAlg: OrderAlg](id: UserId): F[UserInfo] = ???
}
// 2. Accessing algebras through interpreters dependencies
@nebtrx
nebtrx / Main.scala
Created Jan 15, 2019 — forked from jkpl/Main.scala
Ways to pattern match generic types in Scala
View Main.scala
object Main extends App {
AvoidLosingGenericType.run()
AvoidMatchingOnGenericTypeParams.run()
TypeableExample.run()
TypeTagExample.run()
}
class Funky[A, B](val foo: A, val bar: B) {
override def toString: String = s"Funky($foo, $bar)"
}
@nebtrx
nebtrx / SharedStateZIO.scala
Last active Nov 7, 2019
Shared State with `ZIO` instead of `cats-effects`
View SharedStateZIO.scala
package com.github.sharedstate
import scalaz.zio.{App, IO, Ref, Void}
import scala.concurrent.duration._
object SharedStateZIO extends App {
// this is a simpler alternative to `scalaz.zio.console.putStrLn`
def putStrLn(str: String): IO[Void, Unit] = IO.sync(println(str))
def process1(myState: Ref[List[String]]): IO[Void, Unit] = {
View GameWorld.scala
object game {
case class Lens[S, A](set: A => S => S, get: S => A) { self =>
def >>> [B](that: Lens[A, B]): Lens[S, B] =
Lens[S, B](
set = (b: B) => (s: S) => self.set(that.set(b)(self.get(s)))(s),
get = (s: S) => that.get(self.get(s))
)
}
case class Prism[S, A](set: A => S, get: S => Option[A]) { self =>
@nebtrx
nebtrx / modified-garret-theme
Created Nov 21, 2017
modified-garret-theme
View modified-garret-theme
#!/usr/bin/env zsh
#
# Garrett Zsh Theme for Prezto
# Created with modified code by Chauncey Garrett - @chauncey_io
#
# http://chauncey.io/projects/zsh-prompt-garrett/
#
# A prompt with the information you need the moment you need it.
#
# This prompt has the following features:
@nebtrx
nebtrx / atom-haskell
Created Mar 18, 2017
Atom Haskell related configurations
View atom-haskell
stack --no-system-ghc --install-ghc build ghc-mod hlint stylish-haskell
View Linux cheatsheet
# open/edit the GHC compiler seetings
code $(stack ghc -- --print-libdir)/settings
# searh process using the port
lsof -i tcp:<port>
# kill a process
sudo kill -9 <pid>
# list process
View HARVEST_LINT_GUIDE.md

Quick Instructions for using the harvest lint:

  1. Unpack the compressed file.
  2. cd into the uncompresed harvest-lint directory
  3. Fill the harvest-projects.yaml file following instructions from here
  4. Edit run-linter file and replace the placeholders in the following section with real information
export HARVEST_USERNAME=<account_username>
export HARVEST_PASSWORD=<account_password>
@nebtrx
nebtrx / Enabling Gradle Daemon on UNIX based OS
Created Jan 20, 2016
Enabling Gradle Daemon on UNIX based OS
View Enabling Gradle Daemon on UNIX based OS
touch ~/.gradle/gradle.properties && echo "org.gradle.daemon=true" >> ~/.gradle/gradle.properties
View My Git cheatsheet
# See commit changes
git whatchanged -m -n 1 -p <sha of merge commit>
# Delete branch
git branch -d the_local_branch
# Delete remote branch
git push origin --delete <branchName>