Skip to content

Instantly share code, notes, and snippets.

View rudyyazdi's full-sized avatar

Rudy rudyyazdi

  • Sydney, Australia
View GitHub Profile
#[derive(Debug)]
enum State {
Idle,
Counting(u32),
Stopped,
}
fn increment_count(state: &mut State) {
// First, pattern match to understand the current state
match *state {
{
"stages": [
{
"id": "account",
"sections": [
{
"id": "availability",
"uc": "5657ebdfe924d0ab47ff7b9d",
"ignoreProgress": false,
"isAccMngr": false
{
"events": [
{
"actor": {
"id": "5918fef01f397904007317db",
"type": "user"
},
"attributedEvent": null,
"attributionDelta": null,
"changes": null,
// given the bunch or async calls, write a function that cancels the ones
// before it
const delay = (ms) => new Promise(res => setTimeout(() => {
res(ms);
}, ms));
const takeLastMaker = (fun) => {
const arr = [];
let i = 0;
return () => {
DO
$do$
DECLARE
s varchar(50);
BEGIN
FOR s IN SELECT schema_name FROM information_schema.schemata WHERE schema_name LIKE 'tenant%'
LOOP
EXECUTE 'DROP SCHEMA "' || s || '" CASCADE';
END LOOP;
END
# Setting PATH for Python 3.6
# The original version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.6/bin:${PATH}"
export PATH
PATH="$HOME/.nodenv/shims:$PATH"
RBENV_ROOT="$HOME/.rbenv"
eval "$(rbenv init -)"
-- SQL course https://www.udemy.com/the-complete-sql-bootcamp
-- count the number of customers per destrict
SELECT
COUNT(*) AS number_of_customers,
address.district AS district
FROM customer
JOIN address
ON customer.address_id = address.address_id
GROUP BY district
ORDER BY number_of_customers DESC;
# remider: replace expect with xxxx in all the spec files
find spec -type f -exec sed -i '' 's/expect/xxxxx/g' {} \;
hash.map(x => x match { case (a,b) => (b,a)})
hash.map{ case (a,b) => (b,a) }
@rudyyazdi
rudyyazdi / IO.scala
Created August 11, 2016 11:54 — forked from jdegoes/IO.scala
A pedagogical implementation of the IO monad in Scala in 14 LOC
case class IO[A](unsafePerformIO: () => A) {
def map[B](ab: A => B): IO[B] = IO(() => ab(unsafePerformIO()))
def flatMap[B](afb: A => IO[B]): IO[B] =IO(() => afb(unsafePerformIO()).unsafePerformIO())
def tryIO(ta: Throwable => A): IO[A] =
IO(() => IO.tryIO(unsafePerformIO()).unsafePerformIO() match {
case Left(t) => ta(t)
case Right(a) => a
})
}
object IO {