Skip to content

Instantly share code, notes, and snippets.

fn rand7() -> uint {
let r = 5 * (rand5() - 1) + rand5(); // r is uniformly distributed between 1 and 25
if r > 21 {
return rand7(); // discard 22, 23, 24, 25
} else {
return r % 7 + 1;
}
}
use comm;
use hashmap;
use option::{Some, None};
use ops::Drop;
use rt::rtio::IoFactoryObject;
use rt::uv;
use rt::uv::signal;
use rt::local::Local;
use task;
pub use rt::uv::{Signum, Break, HangUp, Interrupt, WindowSizeChange};
use std::{io, libc, os, rt, str};
#[fixed_stack_segment]
pub fn waitpid(pid: libc::pid_t, status: &mut libc::c_int) -> libc::pid_t {
unsafe { libc::funcs::posix01::wait::waitpid(pid, status, 0) }
}
#[fixed_stack_segment]
fn single_threaded_main() {
\begin{titlepage}
\centering
\includegraphics[width=\linewidth]{Downloads/NTU-Logo.PNG}\\[5cm]
\textbf{\LARGE CSC401\\Advanced Topics in Algorithms\\}
{\LARGE Report for Assignment 1\\[3cm]}
{\large \textsl{Name:} Do Nhat Minh\\}
{\large \textsl{Matric No.:} U1020131A\\[2cm]}
{\large School of Computer Engineering\\}
{\large Nanyang Technological University\\}
\vfill
@minhnhdo
minhnhdo / keybase.md
Last active May 9, 2019 17:06
keybase.md

Keybase proof

I hereby claim:

  • I am minhnhdo on github.
  • I am minh (https://keybase.io/minh) on keybase.
  • I have a public key whose fingerprint is 4515 ADD7 F018 6E3B D304 F3FD 7FC7 BA38 FDA7 1950

To claim this, I am signing this object:

#include <pthread.h>
#include <stdio.h>
#include <unistd.h>
#define TOTAL_THREADS 2
#define MAX 10
int shared = 0;
int turn = 0;
int started = 0;
@minhnhdo
minhnhdo / ledis.md
Last active December 6, 2015 16:50

Update (10am)

  • RPUSH, SADD needs to support multiple values
  • Command names are case-insensitive, parameter and values are case-sensitive and must be all lowercase.
  • If a command doesn't specify return value, please return OK if successful, or follow the error code.
  • Updated sample tests (see link in the sample tests section)
  • SET will always overwrite the value for that key

Grokking Challenge Finale

@minhnhdo
minhnhdo / solver.js
Last active January 15, 2016 09:21
solver for guessing game at http://walisu.com/psswrd (usage: paste into the developer console)
function makeConstraint(code, characters) {
var ret = {};
for (var i = 0; i < characters.length; i++) {
ret[characters[i]] = true;
}
for (var i = 0; i < code.length; i++) {
ret[code[i]] = false;
}
return ret;
}
---------------------- MODULE dqueue ------------------------
EXTENDS Integers, Sequences, TLC
(*
--algorithm DistributedQueue {
\* Globals
variables
\** @PGo{ var queue []uint64 }@PGo
version: '2'
services:
etcd1:
image: quay.io/coreos/etcd
container_name: etcd1
command: >
etcd -name etcd1
-advertise-client-urls http://172.28.128.7:2379,http://172.28.128.7:4001
-listen-client-urls http://0.0.0.0:2379,http://0.0.0.0:4001
-initial-advertise-peer-urls http://172.28.128.7:2380