Skip to content

Instantly share code, notes, and snippets.

View violetyk's full-sized avatar

kagaya violetyk

View GitHub Profile
<?php
// import
$ch = curl_init();
$index = 'test'; // like database
$type = 'users'; // like table
$id = 1;
$data = array(
'name' => 'violetyk',
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
switchのデリミタで最初のcaseを書かないとパースエラーになる
<? switch(true):
<?php
// PEAR タイプ
switch ($condition) {
case 1:
# code...
break;
default:
# code...
@violetyk
violetyk / gist:5036741
Created February 26, 2013 07:49
testtest
test
@violetyk
violetyk / gist:5343883
Last active August 4, 2020 05:11
スクロールイベント 上下方向の判定
var start_pos = 0;
$(window).scroll(function(e){
var current_pos = $(this).scrollTop();
if (current_pos > start_pos) {
console.log('down');
} else {
console.log('up');
}
start_pos = current_pos;
});
map <SID>xx <SID>xx
let s:sid = s:sub(maparg("<SID>xx"),'xx$','')
unmap <SID>xx
let s:file = expand('<sfile>:p')
cd /usr/local/src/
wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
tar xf libevent-2.0.21-stable.tar.gz
./configure --prefix=/usr/local/libevent2
make
paco -D make install
cd /usr/local/src/
wget http://downloads.sourceforge.net/tmux/tmux-1.8.tar.gz
tar xf tmux-1.8.tar.gz
@violetyk
violetyk / gist:5589293
Last active December 17, 2015 09:39
[cakephp]ルーティング
<?php
/*
* /posts/123 -> $id
*/
// routes.php
Router::connect('/posts/*', array('controller' => 'posts', 'action' => 'view'));
// PostsController
function view($id = null) {
@violetyk
violetyk / gist:5655227
Last active December 17, 2015 18:39
mb_strimwidth()で50文字でくぎりたい
<?php
$str = 'ぱふぱふぱふぱふぱ!ぱふぱふぱふぱふぱ!ぱふぱふぱふぱふぱ!ぱふぱふぱふぱふぱ!これで50文字文字!うほ';
echo $strwidth = mb_strwidth($str, 'utf-8');
echo "\n";
echo mb_strlen($str, 'utf-8');
echo "\n";
$trimmarker = ' ...';
echo $trimmarker_width = mb_strwidth($trimmarker, 'utf-8');
echo "\n";
@violetyk
violetyk / irc.php
Last active December 18, 2015 16:49
<?php
$host = 'localhost';
$port = 6667;
$nick = 'bot';
$password = 'password';
$channel = '#channel';
$message = '日本語でおk';
$fp = fsockopen($host, $port, $erno, $errstr, 30);