Skip to content

Instantly share code, notes, and snippets.

@creationix
creationix / chatServer.js
Created November 19, 2010 20:47
A simple TCP based chat server written in node.js
// Load the TCP Library
net = require('net');
// Keep track of the chat clients
var clients = [];
// Start a TCP Server
net.createServer(function (socket) {
// Identify this client
@wilkie
wilkie / opengl-transparency-demo.cpp
Created September 5, 2012 20:46
Rendering directly to a composited window in vista+ with opengl.
#define _WIN32_WINNT 0x0500
#include <windows.h>
#include <windowsx.h>
#include <GL/gl.h>
#include <GL/glu.h>
#include <dwmapi.h>
#pragma comment (lib, "opengl32.lib")
@1wErt3r
1wErt3r / SMBDIS.ASM
Created November 9, 2012 22:27
A Comprehensive Super Mario Bros. Disassembly
;SMBDIS.ASM - A COMPREHENSIVE SUPER MARIO BROS. DISASSEMBLY
;by doppelganger (doppelheathen@gmail.com)
;This file is provided for your own use as-is. It will require the character rom data
;and an iNES file header to get it to work.
;There are so many people I have to thank for this, that taking all the credit for
;myself would be an unforgivable act of arrogance. Without their help this would
;probably not be possible. So I thank all the peeps in the nesdev scene whose insight into
;the 6502 and the NES helped me learn how it works (you guys know who you are, there's no
@nhatminhle
nhatminhle / stdatomic.h
Last active November 23, 2022 10:15
A portable version of stdatomic.h extracted from the FreeBSD libc, for Clang 3.1+ and GCC 4.7+.
/*
* An implementation of C11 stdatomic.h directly borrowed from FreeBSD
* (original copyright follows), with minor modifications for
* portability to other systems. Works for recent Clang (that
* implement the feature c_atomic) and GCC 4.7+; includes
* compatibility for GCC below 4.7 but I wouldn't recommend it.
*
* Caveats and limitations:
* - Only the ``_Atomic parentheses'' notation is implemented, while
* the ``_Atomic space'' one is not.
@jmblog
jmblog / gist:6077993
Last active November 22, 2021 08:37
所得税と住民税の計算方法

所得税(国税)

所得税の計算方法

所得税額 = (所得金額(A) - 所得控除額(B)) × 税率 - 税額控除額(C)

  • 「所得金額(A)- 所得控除額(B)」は 課税所得金額 といい、1,000円未満の端数を切り捨てる。

所得税の税率

@aras-p
aras-p / preprocessor_fun.h
Last active July 16, 2024 02:50
Things to commit just before leaving your job
// Just before switching jobs:
// Add one of these.
// Preferably into the same commit where you do a large merge.
//
// This started as a tweet with a joke of "C++ pro-tip: #define private public",
// and then it quickly escalated into more and more evil suggestions.
// I've tried to capture interesting suggestions here.
//
// Contributors: @r2d2rigo, @joeldevahl, @msinilo, @_Humus_,
// @YuriyODonnell, @rygorous, @cmuratori, @mike_acton, @grumpygiant,
@FrankHB
FrankHB / draft-text-encoding
Created August 23, 2013 12:53
Outline for introducing character and text encoding.
1.多语言字符集和编码相关的参考规范之中最重要的有两个,一个是ISO/IEC 10646,一个是 Unicode 。
前者是专家委员会起草的国际标准。(前身还有两个不同的草案,因为中国大陆等方面的反对而否决。)
后者是行业协会组织的规范。ISO/IEC 10646正式版采用Unicode方案,之后的版本也和 Unicode 有基本的对应关系(虽然不一一对应),对普通应用来说基本可以作为同一个方案。
2.Unicode 定义了通用字符集(Universal Character Set, UCS) ,其中以代码点(code point) 作为逻辑上区分字符的单位。
由于历史原因,各种同源字符可能有不同的代码点,这方面汉字( CJKV unified ideographs ,中日韩越统一表意文字)问题尤其突出(相关工作称为Han Unification)。代码点可以由 U+X 的方式表示,X是16进制的自然数。
3.现行 UCS 代码点范围 U+0~U+10FFFF ,划分为 17 个平面,编号 0~16 ,每个平面有 65536 个代码点。
其中最常用的代码点子集是 0 号平面(代码点 U+0~U+FFFF ):基本多文种平面(basic mutilingual plane, BMP) ,之后是第一辅助平面:多文种补充平面(supplementary multilingual plane, SMP) 和第二辅助平面:表意文字补充平面(supplementary ideographic plane, SIP) 。第三至十三辅助平面尚未使用。第十四辅助平面称为特别用途补充平面(supplementary special-purpose plane, SSP) ,其中是控制字符。剩下的两个平面是私人使用区(private use area) 。
一个平面内的代码点可以被两个八元组(octet) 表示,也就是 16 位二进制整数。一般 C/C++ 实现使用的一个字节正好有 8 位,但不总是保证。
4.以 UCS 为基础可以表示文本编码。
早期使用 UCS 限定于现在的一个平面内,可以用 16 位编码(两个八元组)表示任意的 Unicode 代码点,称为 UCS-2 。
#!/usr/bin/ruby
# Create display override file to force Mac OS X to use RGB mode for Display
# see http://embdev.net/topic/284710
require 'base64'
data=`ioreg -l -d0 -w 0 -r -c AppleDisplay`
edids=data.scan(/IODisplayEDID.*?<([a-z0-9]+)>/i).flatten
vendorids=data.scan(/DisplayVendorID.*?([0-9]+)/i).flatten
@ejdyksen
ejdyksen / patch-edid.md
Last active July 26, 2024 11:46
A script to fix EDID problems on external monitors in macOS

patch-edid.rb

A script to fix EDID problems on external monitors in macOS.

Instructions

  1. Connect only the problem display.

  2. Create this directory structure (if it doesn't already exist):