Skip to content

Instantly share code, notes, and snippets.

@ps
ps / bug.c
Last active November 30, 2016 16:14
Fun with locks and condition variables
typedef struct WorkerParams {
int thread_id;
Log * log;
Jobs * jobs;
pthread_mutex_t jobs_lock;
pthread_cond_t work_added;
} WorkerParams;
void main() {
launch_master_node(3);
@ps
ps / Users.scala
Created May 15, 2017 01:48
Some(Int) vs just Int
// implementation 1
object Users {
var users: Seq[User] = Seq()
def delete(id: Long) : Option[Int] = {
val originalSize = users.length
this.users = users.filterNot(_.id == id)
Some(originalSize - users.length)
}
}