Skip to content

Instantly share code, notes, and snippets.

View st98's full-sized avatar

st98 st98

View GitHub Profile
#include <stdio.h>
void f(void) {
puts("f");
return;
}
void g(void) __attribute__ ((weak, alias("f")));
int main(void) {
g();
return 0;
#define ZERO 0
int main(void) {
return ZERO;
}
@st98
st98 / a.bat
Last active August 29, 2015 14:13
%PATHEXT%
> echo %PATHEXT%
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.PY
> type a.bat
echo a.bat
> type a.cmd
echo a.cmd
> a
a.bat
@st98
st98 / w.py
Last active August 29, 2015 14:14
たのしい winsound モジュール。Windows 限定。
import time
import winsound
dur = 60000 // 80
def main():
winsound.Beep(523, dur)
winsound.Beep(523, dur)
winsound.Beep(784, dur)
winsound.Beep(784, dur)
@st98
st98 / mml-modoki.py
Last active August 29, 2015 14:14
たのしい winsound モジュール。play('ccggaagrffeeddcr')。
import time
import winsound
_table = { 'c': 523, 'd': 587, 'e': 659, 'f': 698, 'g': 784, 'a': 880, 'b': 988 }
_dur = 60000 // 80
def play(s):
s = s.lower()
for c in s:
if c not in 'cdefgabr':
from ctypes import windll
windll.user32.MessageBoxW(0, u'めっせーじ', u'たいとる', 0x40)
{p} # => {p: p}
{p} = obj # => var p; p = obj.p;
{p: p} = obj # => var p; p = obj.p;
@st98
st98 / p.coffee
Created January 27, 2015 20:05
8 進数。p('1234') === 668。
p = (s) ->
m = s.match /[0-7]+/
if m is null
return NaN
r = 0
for c, i in (m[0].split '').reverse()
n = parseInt c, 10
r += n * Math.pow 8, i
if s[0] is '-' then -r else r
@st98
st98 / a.js
Created January 29, 2015 17:44
f('ABCDE') === 'ABCDE'; g('ABCDE') === 'ABCDE';
function f(s) {
return s.replace(/[A-~]/g, function (c) {
return String.fromCharCode(c.charCodeAt(0) + 0xfee0);
});
}
function g(s) {
return s.replace(/[\uff01-\uff5e]/g, function (c) {
return String.fromCharCode(c.charCodeAt(0) - 0xfee0);
});
}
@st98
st98 / a.js
Last active August 29, 2015 14:14
process.stdin, test
function f(s) {
return s.split('').map(function (a) {
return ('00' + a.charCodeAt(0).toString(16)).slice(-2);
}).join(' ');
}
process.stdin.setEncoding('utf8');
process.stdin.on('readable', function () {
var a = process.stdin.read();
if (a !== null) {
console.log('> ', a.replace(/\n/, ''));