Skip to content

Instantly share code, notes, and snippets.

View alexandru's full-sized avatar
😺
Having fun

Alexandru Nedelcu alexandru

😺
Having fun
View GitHub Profile
import akka.actor.ActorSystem
import akka.stream.Attributes
import akka.stream.scaladsl.Source
import monix.execution.rstreams.Subscription
import org.reactivestreams.{ Publisher, Subscriber }
import scala.concurrent.{ Await, ExecutionContext, Future }
import scala.concurrent.duration._
def repeated[A](x: A)(f: A => A)(implicit ec: ExecutionContext): Publisher[A] =
#!/usr/bin/env python
import smtplib
import argparse
from datetime import datetime, timedelta
from email.message import EmailMessage
parser = argparse.ArgumentParser(description='Send email')
#!/usr/bin/env python
import smtplib
import argparse
from datetime import datetime, timedelta
from email.message import EmailMessage
parser = argparse.ArgumentParser(description='Send email')
#!/usr/bin/env bash
#
# Quickly encrypt a message or a file for sending to
# your colleagues over unsecure messengers (Slack, etc)...
#
# echo "secret message" | encrypt
#
# Or to encrypt a file:
#
# encrypt ./path/to/file
@alexandru
alexandru / sierpinski.hs
Created November 29, 2019 09:01
Prints an ASCII Sierpinski triangle
#!/usr/bin/env stack
-- stack --resolver lts-14.14 script
import Data.Bits
main :: IO ()
main = mapM_ putStrLn lines
where
n = 32 :: Int
line i =
[ if i .&. j /= 0 then ' ' else '*'

See context.

To configure this script to automatically execute on file changes, save the XML config in ~/Library/LaunchAgents/dot-files.sync.plist then do:

launchctl load -w ~/Library/LaunchAgents/dot-files.sync.plist

First install pyenv.

Afterwards ...

Installing a Python version:

pyenv install 2.7.14
type Callback<A> = (a: A) => void;
/**
* Delays stuff for ensuring fairness.
*/
export function yieldRunLoop(): Promise<void> {
const fn: (cb: (() => void)) => void = typeof setImmediate !== 'undefined'
? setImmediate
: cb => setTimeout(cb, 0)
return new Promise(fn)