View terminate-worker-threads.c
#include <unistd.h>
#include <stdbool.h>
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#define NUM_THREADS 10
pthread_mutex_t cv_mutex;
pthread_cond_t notification_cv;
import sys
def main():
N = raw_input()
elements = [int(element) for element in' ')]
L, R = 0, len(elements)
# We got ourselves a maximum subarray problem, with inverted semantics.
# The subarray we want to find is the one to flip all the bits in.
View reasonable-tuple.cpp
#include <tuple>
struct Cache;
template<int, typename> struct cache_getter;
template<int, typename...> struct tuple_walker;
template<int I, typename... Ts> struct cache_getter<I, std::tuple<Ts...> > {
static std::tuple<Ts...> get(Cache & c);
#!/usr/bin/env sh
set -e # fail on unhandled error
set -u # fail on undefined variable
#set -x # debug
alias command_exists="type >/dev/null 2>&1"
if command_exists curl; then
View nuke-noscript.user.js
// ==UserScript==
// @name nuke noscript
// @namespace
// @version 0.2
// @description Remove all <noscript> tags in every document
// @author mfukar
// @grant none
// ==/UserScript==
/* jshint -W097 */
'use strict';
import struct
class bitbuffer:
# TODO: need reader?
def __init__(self):
self.buffer = b''
self.byte = 0
self.bit_pos = 7
def append(self, value, nbits):
View LotSX.js
// ==UserScript==
// @name Prophet's LotS Script for ArmorGames
// @namespace tag://armorgames
// @description Layout and raid management
// @author Prophet
// @version 0.1
// @grant GM_xmlhttpRequest
// @grant GM_setValue
// @grant GM_getValue
// @grant unsafeWindow
View mach_msg_hook.c
* View the contents of messages sent/received via `mach_msg`.
* Compile with:
* clang -arch x86_64 -arch i386 -Wall -o mach_msg_hook.dylib -dynamiclib mach_msg_hook.c
* and run as:
* Have fun.
View memoizer.cpp
* A memoizer (Y-combinator), with a cache on operator().
* The type of the function that can be memoized is (((Args...)->R), Args...) -> R, which
* makes the memoizer of type ( (((Args...) -> R), Args...) -> R ) -> ((Args...) -> R).
* WARNING: If the memoized function modifies its arguments, the results will not be
* cached correctly.
View idontknow.c
* The array contains a set of unsorted numbers. All numbers appear an even number of
* times. The exception is two numbers, call them M and N, which appear an odd number of
* times. Find M and N.
* This solution is O(n), where n is the size of the array. It requires two passes over
* the array.
* The generalised version of this problem (N elements, one number repeats K times) can
* be reduced to solving the linear system of equations: