Skip to content

Instantly share code, notes, and snippets.

View yuka2py's full-sized avatar

yuka2py yuka2py

View GitHub Profile
@yuka2py
yuka2py / gist:6148288
Last active December 20, 2015 14:39 — forked from miya0001/gist:6145701
ページ内のjQueryの有無に関わらず、別のjQueryをロードしてスクリプトで利用する。既存のjQueryがあれば、それを変更しない。 ブックマークレットなどでの利用を想定。
(function(func){
var jq = document.createElement('script');
jq.src = '//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js';
jq.async = 1;
jq.onload = function() {
document.body.removeChild(jq);
func(jQuery.noConflict(true));
};
document.body.appendChild(jq);
})(function($){
@yuka2py
yuka2py / gist:5996538
Created July 14, 2013 23:25
メモ。svn の trunk を git で管理。
1. svn の trunk の中で git init
2. ~/.subversion/config に以下を記述して git リソースなどを svn 管理下から除外する
global-ignores = .DS_Store Thumbs.db .git .gitignore
@yuka2py
yuka2py / debug.php
Last active December 17, 2015 16:39
CakePHP の debug 関数が心地よかったので、簡易版を書いたので貼っておきます。 あくまで簡易版 (*'-'*)。ちなみに WordPress 案件中に作ったので、WordPress 記法になっているのがミソですw $var は、出力したい変数。 $label は、ついでに出力したい文字列。 $echo は、true の場合のみ出力する。条件付きで出力したいとき、if 書く手間をほんの少し減らすことができます。
<?php
/**
* Output the contents of the variable along with the file and line number.
* @param mixed $var output variable of any types.
* @param string $label optional. default is null.
* @param boolean $echo optional. default is true.
* @return void
*/
function debug( $var, $label=null, $echo=true ) {
@yuka2py
yuka2py / cconsole.php
Last active December 17, 2015 04:49
This is small utility to log output to the console of the browser from the PHP.
<?php
register_shutdown_function('cconsole::flush');
class cconsole
{
private static $logs = array();
private static $prefix = '[php] ';
private static $timers = array();
@yuka2py
yuka2py / gist:3957781
Created October 26, 2012 09:11
appfogでDBへの接続情報を取得する
<?php
$services_json = getenv('VCAP_SERVICES');
$services = json_decode($services_json, true);
$config = null;
foreach ($services as $name => $service) {
if (0 === stripos($name, 'mysql')) {
$config = $service[0]['credentials'];
break;
}
@yuka2py
yuka2py / README
Created October 24, 2012 00:51
コンストラクタを使った継承
コンストラクタを用いた継承のアプローチ。
オブジェクト生成の度に、各オブジェクトのメソッドとして関数オブジェクトを生成されるのかしら?
@yuka2py
yuka2py / README
Created October 24, 2012 00:45
プロトタイプチェーンによる継承
プロトタイプチェーンによる継承で、基本だと思うんですが、16行目で Employee.prototype = new Person; ってやった時に、Personのコンストラクタが走るのが微妙です。
何か認識を間違っているのかしら?