View luhn.cpp
#include <algorithm>
#include <numeric>
#include <iostream>
#include <vector>
bool luhn (const std::string & id) {
static const int m[] = {0, 2, 4, 6, 8, 1, 3, 5, 7, 9};
bool is_odd = false;
auto lambda = [&](int a, char c) {
return a + ((is_odd = !is_odd) ? c - '0' : m[c - '0']);
View z3-salsa10.py
# Recover the key used by the Petya ransomware to encrypt the MFT (master file table)
import z3
import sys, struct
# XOR key for salsa10-src.bin :
KEY_SECTOR = 0x37
# Counter position, as two words
CNTLO = 0
CNTHI = 0
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;
View vmware.py
import sys
def main():
N = raw_input()
elements = [int(element) for element in sys.stdin.read().split(' ')]
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);
};
View extract-certificate.sh
#!/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 https://gist.github.com/mfukar/d1dd369deaa7c3941fde
// @version 0.2
// @description Remove all <noscript> tags in every document
// @author mfukar
// @grant none
// ==/UserScript==
/* jshint -W097 */
'use strict';
View bitbuffer.py
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:
* DYLD_FORCE_FLAT_NAMESPACE=1 DYLD_INSERT_LIBRARIES=mach_msg_hook.dylib [COMMAND]
*
* Have fun.