Skip to content

Instantly share code, notes, and snippets.

@m13253
m13253 / preload.cpp
Last active September 8, 2017 06:38
Preload files into memory cache, for example IME database, in case you have a slow HDD.
#include <windows.h>
#include <string>
using namespace std::string_literals;
constexpr size_t buffer_size = 64*1024;
static char buffer[buffer_size];
static DWORD PrintString(HANDLE h_stdout, std::wstring const& string) {
DWORD count;
(function (root, factory) {
var lodash = 'lodash';
if (typeof define === 'function' && define.amd) {
define([lodash], factory);
} else if (typeof module === 'object' && module.exports) {
module.exports = factory(require(lodash));
} else {
root.BOMDetect = factory(_);
}
}(this, function (_) {
@m13253
m13253 / keybase.md
Created June 19, 2016 13:46
My Keybase identity proof

Keybase proof

I hereby claim:

  • I am m13253 on github.
  • I am m13253 (https://keybase.io/m13253) on keybase.
  • I have a public key whose fingerprint is 7F9A 921B D8D8 F587 6F1E E6BB 4E13 92C0 6970 0583

To claim this, I am signing this object:

@m13253
m13253 / MyCal.py
Created June 10, 2016 15:21
A simple Tkinter calendar with memo feature
#!/usr/bin/env python2
import calendar
import datetime
import os.path
from Tkinter import *
class Application(Frame):
def __init__(self, master):
@m13253
m13253 / GetVersionEx.c
Created January 17, 2016 10:58
GetVersionEx - Print Windows version information
#include <stdio.h>
#include <windows.h>
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd) {
OSVERSIONINFOEXW version_info;
ZeroMemory(&version_info, sizeof version_info);
version_info.dwOSVersionInfoSize = sizeof version_info;
if(GetVersionExW((LPOSVERSIONINFOW) &version_info)) {
wprintf(L"OSVERSIONINFOEX {\n");
wprintf(L"\tdwOSVersionInfoSize\t= %u,\n", version_info.dwOSVersionInfoSize);
@m13253
m13253 / .Xmodmap
Created October 30, 2015 10:33
Xmodmap layout configuration to map an Apple Bluetooth Keyboard to standard US layout
keycode 51 = KP_Enter NoSymbol KP_Enter
keycode 64 = Super_L NoSymbol Super_L
keycode 94 = Shift_L NoSymbol Shift_L
keycode 108 = Control_R NoSymbol Control_R
keycode 128 = Super_R NoSymbol Super_R
keycode 133 = Alt_L Meta_L Alt_L Meta_L
keycode 134 = Alt_R Meta_R Alt_R Meta_R
keycode 169 = backslash bar backslash bar
keycode 170 = backslash bar backslash bar
clear Shift
@m13253
m13253 / stlstrip.py
Last active August 29, 2015 14:21
The script to strip debugging symbol from STL and C++ standard library
#!/usr/bin/python
# The script was adapted from
# http://ubuntuforums.org/showthread.php?t=701336&p=4368203#post4368203
# I posted here for convenience. Credit goes to the original author.
# No warranty is provided. Use it at your own risk.
#
# Strips all STL symbols from the object file %1
#
# Known bugs:
# The original author is not escaping paths containing space,
@m13253
m13253 / badwine.c
Last active July 24, 2019 08:44
The program that crashes Wine 1.7.42 https://bugs.winehq.org/show_bug.cgi?id=38598
// Compile with:
// i686-w64-mingw32-gcc -g -mwindows -o badwine.exe badwine.c
#include <assert.h>
#include <stdint.h>
#include <windows.h>
HINSTANCE g_hInstance;
HWND g_hWnd;
HDC screen_dc, window_dc, buffer_dc;
@m13253
m13253 / live.sh
Last active August 29, 2015 14:20
My screencast live stream configuration
# Personal reminder
# Do not use it unless you know what it means!
parec --rate=48000 --format=float32le -d alsa_output.pci-0000_00_1b.0.analog-stereo.monitor | \
ffmpeg -f x11grab -video_size 1366x768 -framerate 25 -i :0 \
-f f32le -ar 48k -ac 2 -i - \
-vf setpts='(RTCTIME-RTCSTART)/(TB*1000000)' \
-b:v 512k -c:v libx264 -profile:v main -pix_fmt yuv420p -level:v 4.1 -tune:v zerolatency -preset:v ultrafast -g:v 25 \
-b:a 96k -c:a libfdk_aac -profile:a aac_he \
-f flv -vsync passthrough rtmp://localhost/live
@m13253
m13253 / SourceHanSans-sample.html
Last active August 29, 2015 14:20
Sample text document for Source Han Sans font
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8" />
<style>
p {
width: 600px;
font-family: "Source Han Sans SC Normal";
font-weight: 300;
font-size: 18px;