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 <stdio.h> | |
#include <sys/mman.h> | |
#include <mach/mach.h> | |
#include <mach/vm_statistics.h> | |
void vm_stat() | |
{ | |
int host = mach_host_self(); | |
vm_statistics64_data_t stat; | |
mach_msg_type_number_t count; |
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 math import pow | |
def linear_to_srgb(c): | |
if c < 0.0031308: | |
return 12.92 * c | |
return 1.055 * pow(c, 0.41666) - 0.055 | |
def srgb_to_linear(c): | |
if c < 0.04045: | |
return c / 12.92 |
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/python | |
import re | |
import sys | |
import os.path | |
import argparse | |
parser = argparse.ArgumentParser(description='Preprocess #include <...> directive') | |
parser.add_argument('-I', dest='paths', action='append', | |
help='add directory to include search path') | |
parser.add_argument('-o', '--output', dest='out', type=argparse.FileType('w'), default=sys.stdout, |
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
set(CMAKE_SYSTEM_NAME Darwin) | |
execute_process(COMMAND xcrun --sdk iphoneos --show-sdk-path OUTPUT_VARIABLE CMAKE_OSX_SYSROOT OUTPUT_STRIP_TRAILING_WHITESPACE) | |
execute_process(COMMAND xcrun --sdk iphoneos --find cc OUTPUT_VARIABLE CMAKE_C_COMPILER OUTPUT_STRIP_TRAILING_WHITESPACE) | |
execute_process(COMMAND xcrun --sdk iphoneos --find c++ OUTPUT_VARIABLE CMAKE_CXX_COMPILER OUTPUT_STRIP_TRAILING_WHITESPACE) | |
include(CMakeForceCompiler) | |
CMAKE_FORCE_C_COMPILER(${CMAKE_C_COMPILER} AppleClang) | |
CMAKE_FORCE_CXX_COMPILER(${CMAKE_CXX_COMPILER} AppleClang) | |
set(CMAKE_OSX_SYSROOT iphoneos CACHE STRING "") | |
set(CMAKE_OSX_ARCHITECTURES $(ARCHS_STANDARD) CACHE STRING "") |
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
execute pathogen#infect() | |
filetype plugin indent on | |
syntax on | |
set nocp | |
set tabstop=4 | |
set shiftwidth=4 | |
set expandtab | |
set smartindent | |
set cinoptions=:0,l1,g0,N-s,(0 |
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
constexpr unsigned int CRC32_TABLE[] = { | |
0x00000000, 0x1DB71064, 0x3B6E20C8, 0x26D930AC, 0x76DC4190, 0x6B6B51F4, 0x4DB26158, 0x5005713C, | |
0xEDB88320, 0xF00F9344, 0xD6D6A3E8, 0xCB61B38C, 0x9B64C2B0, 0x86D3D2D4, 0xA00AE278, 0xBDBDF21C | |
}; | |
constexpr unsigned int crc32_4(char c, unsigned int h) { return (h >> 4) ^ CRC32_TABLE[(h & 0xF) ^ c]; } | |
constexpr unsigned int crc32(const char *s, unsigned int h = ~0) { return !*s ? ~h : crc32(s + 1, crc32_4(*s >> 4, crc32_4(*s & 0xF, h))); } | |
constexpr unsigned int djb2a(const char *s, unsigned int h = 5381) { return !*s ? h : djb2a(s + 1, 33 * h ^ *s); } | |
constexpr unsigned int fnv1a(const char *s, unsigned int h = 0x811c9dc5) { return !*s ? h : fnv1a(s + 1, (h ^ *s) * 0x01000193); } |
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
// clang mouse-click.c -o mouse-click -framework ApplicationServices | |
#include <ApplicationServices/ApplicationServices.h> | |
#include <unistd.h> | |
#include <stdlib.h> | |
int main(int argc, char *argv[]) | |
{ | |
if (argc != 3) | |
{ | |
fprintf(stderr, "usage: %s [seconds to wait] [number of clicks]\n", argv[0]); |
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
#!/bin/sh | |
CATEGORIES="buildings food nature people technology objects" | |
DESTDIR=~/Pictures/unsplash | |
RESOLUTION=$(system_profiler SPDisplaysDataType | grep Resolution | sed 's/[^x0-9]//g') | |
for CATEGORY in ${CATEGORIES}; do | |
URL=https://source.unsplash.com/category/${CATEGORY}/${RESOLUTION}/daily | |
IMAGE=$(curl --silent --fail --location --write-out "%{url_effective}" --output /dev/null --url ${URL}) | |
NAME=${IMAGE##*/} |
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
int d = 42; | |
int o = 052; | |
int foo = 2321312; | |
int x = 0xdead'beef; | |
int X = 0Xc0'0f'fe; | |
int y = 0XBAD'cab1e; | |
int Y = 0Xc0'0f'fe; | |
int b = 0b101010; // C++14 | |
unsigned long long l1 = 18446744073709550592ull; // C++11 | |
unsigned long long l2 = 18'446'744'073'709'550'592llu; // C++14 |
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 __future__ import print_function | |
import sys | |
class Calculator(object): | |
"""A simple calculator class.""" | |
def double(self, number): | |
return 2 * number | |
if __name__ == '__main__': |
OlderNewer