View less_unfair_scheduling.cpp
This file contains 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
#include <unistd.h> | |
#include <sys/time.h> | |
#include <iostream> | |
#include <thread> | |
#include <mutex> | |
#include <condition_variable> | |
#include <chrono> | |
using namespace std; |
View unfair_queue.py
This file contains 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
from threading import Thread, get_ident | |
import time | |
from queue import Queue | |
THREAD_COUNT = 10 | |
POOL_GET_TIMEOUT = 10.0 | |
POOL_SIZE = 2 | |
pool = Queue() | |
for i in range(POOL_SIZE): |
View unfiar_scheduling.py
This file contains 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
from threading import Condition, Thread | |
import time | |
# This is a sample implementation of something like an object pool. It uses | |
# a condition variable to ensure that at most `counter` threads are allowed | |
# to execute at a time. | |
THREAD_COUNT = 10 | |
counter = 1 | |
cnd = Condition() |
View replay.php
This file contains 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
<?php | |
function _substr($data, $pos, $len) { | |
if (0 <= $pos && $pos + $len <= strlen($data) && $pos <= $pos + $len) { | |
return substr($data, $pos, $len); | |
} | |
return null; | |
} | |
function _unpack_byte($data, $pos) { | |
$str = _substr($data, $pos, 1); |
View subframe_callback.as
This file contains 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
class script : callback_base { | |
scene@ g; | |
array<dustman@> players; | |
script() { | |
@g = get_scene(); | |
} | |
void step(int num_entities) { | |
int nc = num_cameras(); |
View 16.cpp
This file contains 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
#include <iostream> | |
#include <vector> | |
#include <algorithm> | |
using namespace std; | |
int mexp(int v, int e, int MOD) { | |
int ret = 1; | |
if (e == 0) return ret; | |
for(int i = 31 - __builtin_clz(e); i >= 0; i--) { |
View 10-integral.cpp
This file contains 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
#include <iostream> | |
#include <vector> | |
#include <set> | |
#include <map> | |
#include <algorithm> | |
using namespace std; | |
int gcd(int a, int b) { | |
return b ? gcd(b, a % b) : a; |
View intcode.py
This file contains 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
import abc | |
import asyncio | |
import itertools | |
import sys | |
class Instruction(metaclass=abc.ABCMeta): | |
PARAMS = 0 | |
def __init__(self, comp, offset, mode): |
View dusttrackerpro.cpp
This file contains 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
class script { | |
scene@ g; | |
textfield@ txt; | |
int init_filth; | |
int init_filth_block; | |
int init_enemy; | |
script() { | |
@g = get_scene(); |
View sounddemo.cpp
This file contains 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
const string EMBED_sound1 = "test1.ogg"; | |
class script { | |
scene@ g; | |
script() { | |
@g = get_scene(); | |
} | |
void build_sounds(message@ msg) { |
NewerOlder