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> | |
enum stuff { | |
laugh, | |
strike, | |
slap, | |
}; | |
struct true_ {}; | |
struct false_ {}; |
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
/** | |
* Compile with GCC 4.9: | |
* g++ -std=c++1y lisp.cpp | |
*/ | |
#include <iostream> | |
#include <stdio.h> | |
auto terminal = [] (auto stream) { | |
return [=] (auto func) { | |
return func (stream); |
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
function Send-NetworkData { | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory)] | |
[string] | |
$Computer, | |
[Parameter(Mandatory)] | |
[ValidateRange(1, 65535)] | |
[Int16] |
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
#!/usr/bin/env python | |
# Useful common polynomials: | |
#POLY = 0x82F63B78 # CRC-32C (Castagnoli) | |
#POLY = 0xEB31D82E # CRC-32K (Koopman) | |
#POLY = 0xD5828281 # CRC-32Q | |
class CRCForger(): | |
def __init__(self, *args, **kwargs): |
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
private InputFilter getCharactersLimited() { | |
// Limit characters input | |
InputFilter[] filters = new InputFilter[1]; | |
filters[0] = new InputFilter(){ | |
@Override | |
public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { | |
if (end > start) { | |
char[] acceptedChars = new char[]{'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', |
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
/** | |
* 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: |
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
/** | |
* 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. | |
*/ |
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
/* | |
* 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. |
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 struct | |
class bitbuffer: | |
# TODO: need reader? | |
def __init__(self): | |
self.buffer = b'' | |
self.byte = 0 | |
self.bit_pos = 7 | |
def append(self, value, nbits): |
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
// ==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'; |