Skip to content

Instantly share code, notes, and snippets.

View mattn's full-sized avatar
🍛
I love curry 🍛

mattn mattn

🍛
I love curry 🍛
View GitHub Profile
#if _WIN32_WINNT < 0x0500
# error "should be NT"
#endif
#include <windows.h>
#include <tlhelp32.h>
#include <winternl.h>
#include <stdio.h>
DWORD getppid()
{
// Running JSDeferred on WSH
var _util = {
cat : function(f){
if(f.match(/^http:/)) {
var xhr = new ActiveXObject("Microsoft.XMLHTTP");
xhr.open("GET", f, false);
xhr.send();
return xhr.responseText;
}
return (new ActiveXObject("Scripting.FileSystemObject")).OpenTextFile(f,1,false).ReadAll();
@mattn
mattn / gist:304597
Created February 15, 2010 12:09 — forked from xaicron/gist:304564
#!/usr/bin/env perl
use strict;
use warnings;
use Encode;
use Gtk2 -init;
my $data = decode_utf8 do { local $/; <STDIN> } || '';
&main();exit;
@mattn
mattn / foo.cxx
Created February 25, 2010 08:31 — forked from hasegawayosuke/foo.cxx
/*
fix: error C2016: C では、構造体または共用体に少なくとも 1 つのメンバが必要です。
struct function {
};
*/
/*
foo.cxx(9) : error C2146: 構文エラー : ';' が、識別子 'foo' の前に必要です。
foo.cxx(9) : error C4430: 型指定子がありません - int と仮定しました。メモ: C++ は int を既定値としてサポートしていません
foo.cxx(9) : error C4430: 型指定子がありません - int と仮定しました。メモ: C++ は int を既定値としてサポートしていません
#include <stdio.h>
typedef enum { GU = 1, CHOKI = 2, PA = 3 } HAND;
void judge(HAND handA, HAND handB);
int
main(void) {
judge(GU, GU);
judge(GU, CHOKI);
judge(GU, PA);
#include <stdio.h>
void *create_counter(int n)
{
static int m = 0;
int counter()
{
printf("address in closure %p\n", &m);
return m++;
}
@mattn
mattn / kurukuruimg.user.js
Created April 5, 2010 01:17 — forked from hitode909/kurukuruimg.user.js
webkit version
// ==UserScript==
// @name kurukuruimg
// @namespace http://www.hatena.ne.jp/hitode909
// @include *
// ==/UserScript==
var style = document.createElement('style');
document.body.appendChild(style);
style.textContent = "img, canvas, video {\n" + "-webkit-transform: rotate(0deg);\n" + " }";
#!perl
# 日本の祝日をGoogleから持ってくるスクリプト
use strict;
use LWP::UserAgent;
use POSIX qw(strftime);
use URI;
use JSON::XS;
use XML::LibXML;
use XML::LibXML::XPathContext;
@mattn
mattn / gist:563440
Created September 3, 2010 04:56 — forked from soh335/gist:554964
use strict;
use warnings;
use Net::Twitter;
use Path::Class;
use Array::Diff;
use Config::Pit;
use Getopt::Long;
use LWP::Simple;
use File::Temp;
#include <stdio.h>
void hoge(char *str) {
str[1] = 'a';
}
int main(void) {
char foo[10];
char b[] = {0xe3,0x81,0xa0,0xe3,0x81,0xbe,0xe3,0x81,0xa3,0xe3,0x81,0xa6,0xe3,0x82,0xb3,0xe3,0x83,0xbc,0xe3,0x83,0x89,0xe3,0x82,0x92,0xe3,0x81,0x8b,0xe3,0x81,0x91,0xe3,0x82,0x88,0x00};
strcpy(foo, "hoge");