Skip to content

Instantly share code, notes, and snippets.

chobie chobie

  • Tokyo/Japan
Block or report user

Report or block chobie

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:546876
<?php
/*
mysqliでコネクションを確認しつつ接続しなおすサンプル
*/
$mysqli = mysqli_init();
$mysqli->options(MYSQLI_INIT_COMMAND,"set names utf8");
$host = "localhost";
$user = "user";
$pass = "";
$db_name = "moe";
View gist:568743
<?php
/**
* Text_PatternMatch
* =================
* テキストを適当にマッチング。
*
* Licence: MIT License
* Author : chobie ( http://twitter.com/chobi_e )
* Created_at: 2010-05-18
*
View gist:584743
<?php
declare(encoding='utf8');
namespace Tsunami;
$app = new Application(array(
"/"=>function($request){
echo "Hello World";
}
)
);
View gist:589911

how to install ZeroMQ php binding?

see also http://www.zeromq.org/bindings:php

wget http://www.zeromq.org/local--files/area:download/zeromq-2.0.9.tar.gz
tar zxf zeromq-2.0.9.tar.gz
cd zeromq-2.0.9
./configure
make && make install
cd ..
View gist:609451
<?php
//simple http proxy connection sample
$proxy = "proxy.example.com";
$port = 8080;
$url = "https://example.com/";
$host = parse_url($url);
$fp = fsockopen("tcp://" . $proxy, $port);
$request = "GET $url HTTP/1.1\r\n";
$request .= "Host: {$host['host']}\r\n";
$request .= "Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8\r\n";
View gist:616878
app.config
templating:
path:
- "%kernel.root_dir%/../views/%%bundle%%/%%controller%%/%%name%%%%format%%.%%renderer%%"
- "%kernel.root_dir%/../src/Symfony/Bundle/%%bundle%%/Resources/views/%%controller%%/%%name%%%%format%%.%%renderer%%"
View gist:621902
//for dyndns manage page
javascript:(function(){var s=document.createElement('script');s.charset='UTF-8';s.src='http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js';document.body.appendChild(s);})();
javascript:(function(){
cell = $("table[width=100%] td");
result = "";
for(var i in cell){
td = $(cell[i]);
if(td.children("input[type=text]").length){
@chobie
chobie / gist:627722
Created Oct 15, 2010
Doctrine2のsandboxでMysqlにテーブルつくってGuilhermeを20件$em->flush()した時のMysqlのログ
View gist:627722
101015 15:23:10 104 Connect root@localhost on moemoe
104 Query CREATE TABLE addresses (id INT AUTO_INCREMENT NOT NULL, street VARCHAR(255) NOT NULL, PRIMARY KEY(id)) ENGINE = InnoDB
104 Query CREATE TABLE users (id INT AUTO_INCREMENT NOT NULL, address_id INT DEFAULT NULL, name VARCHAR(50) NOT NULL, UNIQUE INDEX users_address_id_uniq (address_id), PRIMARY KEY(id)) ENGINE = InnoDB
104 Query ALTER TABLE users ADD FOREIGN KEY (address_id) REFERENCES addresses(id)
104 Quit
101015 15:23:12 105 Connect root@localhost on moemoe
105 Query START TRANSACTION
105 Query INSERT INTO users (name, address_id) VALUES ('Guilherme', NULL)
105 Query INSERT INTO users (name, address_id) VALUES ('Guilherme', NULL)
105 Query INSERT INTO users (name, address_id) VALUES ('Guilherme', NULL)
@chobie
chobie / gist:627733
Created Oct 15, 2010
Doctrine2とmysqliでのインサートの比較用
View gist:627733
<?php
// 本番環境ではやらないでね!
$mysqli = mysqli_init();
$mysqli->real_connect("localhost","user_name","password","db_name");
if($error = mysqli_connect_error()){
throw new RuntimeException($error);
}
$mysqli->set_charset("utf8");
View gist:636001
//今見ているページのURLを含んだツイートがあれば表示する
//from http://blog.asial.co.jp/659
function myfunc(json) {
var box = $('body');
$(json.results).each(function(i, v) {
v.jp_created_at = dateJp(v.created_at);
var html = template('<div class="twit">\
<blockquote class="commentOne">\
<p class="commentText">#{text}</p><p class="twitDate">#{jp_created_at}<\/p>\
<span class="arrow" \/>\
You can’t perform that action at this time.