Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / .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 / 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 / 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 / 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:

(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 / 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;
@m13253
m13253 / upower-Add-a-critical-action-Ignore.patch
Created October 5, 2016 14:19
A patch for UPower to disable low battery action
From 1ba6e724dabf3a91e59b871750e22d420a4b1238 Mon Sep 17 00:00:00 2001
From: Star Brilliant <[email protected]>
Date: Wed, 5 Oct 2016 22:02:36 +0800
Subject: [PATCH] Add a critical action: Ignore
---
etc/UPower.conf | 3 ++-
src/linux/up-backend.c | 5 +++++
2 files changed, 7 insertions(+), 1 deletion(-)
@m13253
m13253 / PolyAdder.cc
Last active July 24, 2019 08:38
C++ program to add two polynomials in forms like "4x^3+3x^2+2x+1"
#include <cassert>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <utility>
template <typename T>
class List {