Skip to content

Instantly share code, notes, and snippets.

View hamzamuric's full-sized avatar
📚
Studying

Hamza Muric hamzamuric

📚
Studying
View GitHub Profile
@rtv
rtv / cond.c
Created February 19, 2013 19:56
An example of using pthread's condition variables, showing how to block a main thread while waiting for worker threads to finish their work, without joining the threads. This could be useful if you want to loop the threads, for example.
#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
#include <assert.h>
/* Compile like this:
gcc --std=c99 -lpthread cond.c -o cond
@orangy
orangy / event.kt
Last active September 30, 2019 09:45
C#-style events in Kotlin
class Event<T> {
private val handlers = arrayListOf<(Event<T>.(T) -> Unit)>()
fun plusAssign(handler: Event<T>.(T) -> Unit) { handlers.add(handler) }
fun invoke(value: T) { for (handler in handlers) handler(value) }
}
val e = Event<String>() // define event
fun main(args : Array<String>) {
e += { println(it) } // subscribe
@flyingluscas
flyingluscas / InstallPopcornTime.md
Last active April 19, 2023 01:51
Installing Popcorn Time on Ubuntu 16.x

1. Downloading

32 bits version

$ wget https://get.popcorntime.sh/build/Popcorn-Time-0.3.10-Linux-32.tar.xz -O popcorntime.tar.xz

64 bits version

@ymjing
ymjing / Cargo.toml
Created June 14, 2019 23:25
A simple brpc-rs service
[package]
name = "brpc_server_demo"
version = "0.1.0"
edition = "2018"
build = "build.rs"
[dependencies]
brpc-sys = { path = "../brpc-sys" }
cc = "1.0.37"
@kubukoz
kubukoz / cursed.scala
Created November 9, 2022 00:17
git conflicts parsing as Scala
object main extends App {
object <<<<<<< {
def HEAD(s: String) = this
}
implicit class StringOps(s: String) {
def =======(i: Int) = s
def >>>>>>>(i: Int) = i
}