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:4943170
Last active December 13, 2015 16:48
sslページか判断
<?php
function sslchk()
{
if ((false === empty($_SERVER['HTTPS'])) && ('off' !== $_SERVER['HTTPS'])) {
return true;
}
return false;
}
<?php
$haystack = "11,10,1,4,5";
$needle = 1;
$pos = strpos(','.$haystack.',', ','.$needle.',');
if($pos !== false){
echo "ok:".$pos;
}else{
@shigwata
shigwata / gist:8860092
Last active August 29, 2015 13:56
jQueryでコンフリクトを避ける方法
jQuery.noConflict();
(function($) {
// 実行させたい処理をここに書く
})(jQuery);
@shigwata
shigwata / gist:8860273
Created February 7, 2014 10:23
aタグでformをsubmitする
<form name="form" method="post" action="./">
<a href="javascript:void(0)" onclick="document.form.submit();return false;">submit</a>
<input type=hidden name="hoge" value="test">
</form>
@shigwata
shigwata / gist:4a382cdecfc0714ed539
Last active November 3, 2015 02:41
文字コード変換
<?php
/**
* EUCをUTF-8へと変換
* @param mixed $var 変換したい値
* @return mixed 変換した値を返す
*/
function chgUTF($var)
{
if (is_array($var)) {
@shigwata
shigwata / gist:9800745
Last active August 29, 2015 13:57
aタグでformをsubmitする(onsubmitハンドラを呼ぶ場合)
<!doctype html>
<html>
<head>
<title>Document</title>
<script>
function chk(f){
if(!f.mail.value){
alert('error');
return false;
}
@shigwata
shigwata / 0_reuse_code.js
Created March 27, 2014 08:56
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@shigwata
shigwata / gist:56e66a91f785c247676f
Last active August 29, 2015 13:58
globでGLOB_BRACEを使う
<?php
/**
* ファイル検索対象拡張子
*/
define('IMG_EXTENSION', '{jpg,png,gif}');
define('OFFICE_EXTENSION', '{pdf}');
function fileSearch($con)
{
@shigwata
shigwata / gist:10702773
Last active August 29, 2015 13:59
フォームの未入力をチェックする
function radioChk(name)
{
var elements;
var len;
var i;
elements = document.getElementsByName(name);
if (elements) {
len = elements.length;
for (i = 0; i < len; i ++) {
if (elements[i].checked) {
@shigwata
shigwata / gist:74ebaf4c42a5c40612c4
Created May 2, 2014 09:22
AjaxでHTMLを挿入サンプル
$.ajax({
type: "GET",
url: "ajax.php",
cache: false,
dataType: "html",
data: {
p1: "hoge",
p2: "fuga"
}
}).done(function(html){