This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#[derive(Debug)] | |
enum State { | |
Idle, | |
Counting(u32), | |
Stopped, | |
} | |
fn increment_count(state: &mut State) { | |
// First, pattern match to understand the current state | |
match *state { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"stages": [ | |
{ | |
"id": "account", | |
"sections": [ | |
{ | |
"id": "availability", | |
"uc": "5657ebdfe924d0ab47ff7b9d", | |
"ignoreProgress": false, | |
"isAccMngr": false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"events": [ | |
{ | |
"actor": { | |
"id": "5918fef01f397904007317db", | |
"type": "user" | |
}, | |
"attributedEvent": null, | |
"attributionDelta": null, | |
"changes": null, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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 () => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 -)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# remider: replace expect with xxxx in all the spec files | |
find spec -type f -exec sed -i '' 's/expect/xxxxx/g' {} \; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hash.map(x => x match { case (a,b) => (b,a)}) | |
hash.map{ case (a,b) => (b,a) } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
NewerOlder