Skip to content

Instantly share code, notes, and snippets.

#include "brt.h"
#include <windows.h>
#include <psapi.h>
struct WorkingSetParams {
HANDLE process_handle;
size_t min_working_set;
size_t max_working_set;
DWORD flags;
@ACEfanatic02
ACEfanatic02 / sdtest.c
Created November 20, 2013 19:10
Quick demo using strtod.
#include <stdlib.h>
#include <stdio.h>
/*
Example Usage:
char * str = getString();
double val;
if (tryParseDouble(str, &val)) {
doSomethingWith(val);
import sublime
import sublime_plugin
import subprocess
import re
import os
import tempfile
# RUBY_METHOD_SEP_PATTERN = re.compile('[^.:]*$')
RUBY_METHOD_SEP_PATTERN = re.compile('((?<=\.).*$)|((?<=::).*$)')
@ACEfanatic02
ACEfanatic02 / utf8count.c
Created August 14, 2013 00:59
Count number of actual characters in a utf8 bytestring.
#include <stdint.h>
#include <stdbool.h>
typedef unsigned char uchar8_t;
static bool is_leading_byte(const uchar8_t c)
{
return (c <= 0x7f || c >= 0xc2);
}
@ACEfanatic02
ACEfanatic02 / gist:5824884
Created June 20, 2013 17:40
normalize_kana
# -*- coding: utf-8 -*-
FULL_KATA_OFFSET = ord(u"ァ") - ord(u"ぁ")
half_kata_to_hira = u"をぁぃぅぇぉゃゅょっーあいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよ"
def normalize_kana(s):
"""Normalizes all kana in the given string to full-width hiragana.
Args:
s String to be normalized.
@ACEfanatic02
ACEfanatic02 / 4241.c
Last active December 16, 2015 23:49
4241 CPU emulator, in C.
// 4241 4-bit Microprocessor
//
// Registers: r0 r1
//
// 1-byte Instructions
// 0 = Halt
// 1 = Add (r0 = r0 + r1)
// 2 = Subtract (r0 = r0 - r1)
// 3 = Increment r0
// 4 = Increment r1
def get_entry_type(self):
"""Returns selected entry type as string key."""
radio_pairs = [(self.window.ui.book_radio, 'book'),
(self.window.ui.manga_radio, 'manga'),
(self.window.ui.game_radio, 'game'),
(self.window.ui.flgame_radio, 'fullgame'),
(self.window.ui.net_radio, 'net'),
(self.window.ui.news_radio, 'news'),
(self.window.ui.nico_radio, 'nico'),
(self.window.ui.subs_radio, 'subs'),
# -*- coding: utf-8 -*-
import ast
RE_EXPR = re.compile(ur"\((\d+\.?\d*\s?[+-]\s?\d+\.?\d*)\)")
RE_TIME = re.compile(ur"(\d{2}):(\d{2}):(\d{2})")
def parse_value(string, entry_type):
"""Parses an input value to floating point. Allows expressions
of the form `(XX.X[+-]XX.X)` or `XX:XX:XX` as special cases, otherwise
def contains(self, value):
""" contains
Searchs recursively for a node containing the given value from current
node. Returns True on success and False on failure.
Args:
value: the value being searched for in the tree.
"""
def _contains(value, current):