Skip to content

Instantly share code, notes, and snippets.

@yewton
yewton / gist:2245904
Created March 30, 2012 02:24
PDO::FETCH_INTO leaks memory; PHP 5.3.10, MySQL 5.0.77
<?php
class A {
public $m;
public function __construct($pdo) {
$sql = 'select 1 as m';
$stmt = $pdo->prepare($sql);
$stmt->setFetchMode(PDO::FETCH_INTO, $this);
$stmt->execute();
}
@yewton
yewton / gist:2723321
Created May 18, 2012 05:23
LCG, xor shift
#include <iostream>
using namespace std;
class LCG {
unsigned long s;
static const unsigned long M = 1103515245UL;
static const unsigned long A = 12345UL;
static const unsigned long B = 2147483647UL;
public:
#include "A.hpp"
#include <iostream>
A::A() { }
A::~A() { }
void A::execute() { }
Pool<A> A::merePool(sizeof(A));
@yewton
yewton / wrapper.vbs
Created June 8, 2012 02:21
ウィンドウを開かないでバッチファイル実行
CreateObject("Wscript.Shell").Run WScript.Arguments(0),0
@yewton
yewton / myphpmd.pl
Created June 11, 2012 04:10
myphpmd
#!/usr/bin/perl
use strict;
my $source = $ARGV[0];
my $type = $ARGV[1];
my $rules = $ARGV[2];
my $result = `phpmd ${source} ${type} ${rules}`;
$result =~ s/^\s+//g;
$result =~ s/(:[0-9]+)/$1:/g;
@yewton
yewton / generate_ricty.sh
Created July 14, 2012 08:56
Generate Ricty on Mac OS X Lion
#!/bin/sh
brew install fontforge
brew install wget
git clone https://github.com/yascentur/Ricty.git Ricty
cd Ricty && \
wget http://levien.com/type/myfonts/Inconsolata.otf && \
wget http://iij.dl.sourceforge.jp/mix-mplus-ipa/56156/migu-1m-20120411-2.zip && \
unzip migu-1m-20120411-2.zip && \
cd migu-1m-20120411-2 && \
cp migu-1m-*.ttf ../ && \
@yewton
yewton / cmigemo.rb
Created July 14, 2012 19:52
Formula for cmigemo
# -*- coding: utf-8 -*-
require 'formula'
class Cmigemo < Formula
url 'http://cmigemo.googlecode.com/files/cmigemo-default-src-20110227.zip'
homepage 'http://www.kaoriya.net/software/cmigemo'
sha1 '25e279c56d3a8f1e82cbfb3526d1b38742d1d66c'
depends_on 'nkf'
@yewton
yewton / gist:3130598
Created July 17, 2012 16:59
key-chord setting
;; key-chord
(require 'key-chord)
(key-chord-mode 1)
(devar key-chord-bindings
'(("hf" . describe-function)
("hb" . describe-bindings)
("hv" . describe-variable)
("rs" . replace-string)
("rp" . replace-regexp)
("a;" . goto-line)
@yewton
yewton / znc-0.206.20120727.diff
Created July 27, 2012 06:14
ZNC の playback を Notice に
diff -Naru znc-0.206.orig/Client.cpp znc-0.206/Client.cpp
--- znc-0.206.orig/Client.cpp 2012-07-27 14:52:48.000000000 +0900
+++ znc-0.206/Client.cpp 2012-07-27 14:56:31.000000000 +0900
@@ -430,7 +430,7 @@
CChan* pChan = m_pUser->FindChan(sTarget);
if ((pChan) && (pChan->KeepBuffer())) {
- pChan->AddBuffer(":" + GetNickMask() + " PRIVMSG " + sTarget + " :" + m_pUser->AddTimestamp(sMsg));
+ pChan->AddBuffer(":" + GetNickMask() + " NOTICE " + sTarget + " :" + m_pUser->AddTimestamp(sMsg));
}
@yewton
yewton / znc-0.206.20120807.diff
Created August 7, 2012 06:21
ZNCのPlaybackをNoticeにする
diff -Naru znc-0.206.orig/Chan.cpp znc-0.206/Chan.cpp
--- znc-0.206.orig/Chan.cpp 2012-04-06 04:25:50.000000000 +0900
+++ znc-0.206/Chan.cpp 2012-08-07 16:31:17.000000000 +0900
@@ -570,7 +570,7 @@
MODULECALL(OnChanBufferStarting(*this, *pUseClient), m_pUser, NULL, bSkipStatusMsg = true);
if (!bSkipStatusMsg) {
- m_pUser->PutUser(":***[email protected] PRIVMSG " + GetName() + " :Buffer Playback...", pUseClient);
+ m_pUser->PutUser(":***[email protected] NOTICE " + GetName() + " :Buffer Playback...", pUseClient);
}