Skip to content

Instantly share code, notes, and snippets.

View shigwata's full-sized avatar
:octocat:
🐈🐈

shigwata shigwata

:octocat:
🐈🐈
View GitHub Profile
@shigwata
shigwata / gist:3f5319d1cb8cfc04b3bb
Created May 20, 2015 09:47
Javascriptで強制的にイベントを発生させる方法
// onChangeをエミュレート
var elem = document.getElementById("total");
// ブラウザ判定
if ( /*@cc_on ! @*/ false) {
// IEの場合
elem.fireEvent("onchange");
} else {
// Firefoxの場合
var evt = document.createEvent("MouseEvents"); // マウスイベント作成
evt.initEvent("change", false, true); // イベントの設定
@shigwata
shigwata / gist:a397ca31433cbb6b93d1
Created April 8, 2015 11:45
Git導入について

Git導入について

Gitとは

バージョン管理ツール

メリット・デメリット

メリット

  • 個人に環境があるので同時作業が可能
  • 更新履歴が残る。いつ誰が何をなぜ変更したのか残ります。
@shigwata
shigwata / gist:c908a9af3ea956aa3c8d
Last active August 29, 2015 14:18
月の何週目か取得
<?php
/**
* 月の何週目か取得
* @param integer $y 年
* @param integer $m 月
* @param integer $d 日
*/
function getNthWeek($y, $m, $d)
{
$week1 = date('W', mktime(0, 0, 0, $m, 1, $y));
@shigwata
shigwata / gist:51b89a6ecb2bff8f2763
Created March 17, 2015 06:03
NumberFormat javascriptで数値にカンマの追加 http://www.lopple.jp/?p=241
var numberFormat = function(num) {
return num.toString().replace(/^\d+[^\.]/, function(t) {
return t.replace(/([\d]+?)(?=(?:\d{3})+$)/g, function(t) {
return t + ',';
});
});
}
add/remove
begin/end
create/destroy
fast/last
get/put
get/set
increment/decrement
insert/delete
lock/unlock
min/max
@shigwata
shigwata / gist:6783c8230ddd05c9b38a
Created September 29, 2014 04:43
アメブロからRSS情報を取得し表示する。
<?php
/**
* アメブロからRSS情報を取得します
* @param [type] $url [description]
* @return [type] [description]
*/
function get_ameba_rss($url) {
$xml = simplexml_load_file($url);
$results = array();
@shigwata
shigwata / gist:b3e3894ad33739ede814
Created September 13, 2014 06:09
git diff でファイル名のみ表示する
git diff 比較ブランチ名 --name-only
@shigwata
shigwata / gist:a15bb7b268df7858637c
Created July 18, 2014 04:37
リセットボタン
$(function(){
// リセットボタン
$(".clearForm").bind("click", function(){
event.preventDefault();
$(this.form).find("textarea, :text, select").val("").end().find(":checked").removeAttr("checked");
});
});
@shigwata
shigwata / gist:7f4d18a49a37944990ef
Created June 20, 2014 01:54
imgタグ 縦横リサイズ
<?php
$size = getimagesize($img);
$size_w = 708;
$size_h = ($size_w / $size[0]) * $size[1];
$image = '<img src="'.$img.'" width="'.$size_w.'" height="'.$size_h.'">';
@shigwata
shigwata / gist:55099279451b43937b4d
Last active August 29, 2015 14:01
Check date in JavaScript
function isValidDate(year, month, day) {
var d = new Date(year, month, day);
if ((d.getFullYear() != year) ||
(d.getMonth() != month) ||
(d.getDate() != day)
) {
return false;
}
return true;
}