(
echo hoge
echo piyo
echo puyo
echo fuga
echo gaoh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gem 'mugyu', git: 'https://gist.github.com/4740c9312e70712fa52bad3ac2294fa0.git' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def lerp(a, b, t) | |
a * (1 - t) + b * t | |
end | |
def inverseLerp(a, b, c) | |
v = (c - a) / (b - a) | |
v = 0 if v < 0 | |
v = 1 if v > 1 | |
v | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Array.prototype.shuffle = function() { | |
var array = this; | |
for(var i = array.length - 1; i > 0; --i) { | |
// V8 の Math.random() のアルゴリズムは xorshift128+ らしい | |
var j = Math.floor(Math.random() * i); | |
var tmp = array[i]; | |
array[i] = array[j]; | |
array[j] = tmp; | |
} | |
return array; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function define_php_versions() | |
{ | |
$version = explode('.', PHP_VERSION); | |
define('PHP_VERSION_MAJOR', (int)$version[0]); | |
define('PHP_VERSION_MINOR', (int)$version[1]); | |
define('PHP_VERSION_RELEASE', (int)$version[2]); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class JSONErrorException extends \Exception {} | |
function json_error($error_code, $exceptionable = TRUE) | |
{ | |
static $json_errors = NULL; | |
if ($json_errors === NULL) | |
{ | |
$json_errors = [ | |
JSON_ERROR_NONE => 'No error has occurred', | |
JSON_ERROR_DEPTH => 'The maximum stack depth has been exceeded', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class String | |
UNACCENT = { | |
'©' => '(C)', | |
'«' => '<<', | |
'' => '-', | |
'®' => '(R)', | |
'»' => '>>', | |
'¼' => ' 1/4', | |
'½' => ' 1/2', | |
'¾' => ' 3/4', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 取得 現在年月日時分 | |
* @return{string} 現在時刻をベースにした YYYYMMDDHHmm | |
*/ | |
function get_datetime_string() { | |
const datetime = new Date(); | |
const year = datetime.getFullYear(); | |
const month = datetime.getMonth() + 1; | |
const day = datetime.getDate(); | |
const hours = datetime.getHours(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 文字列のリピート | |
*/ | |
function stringRepeat(length, string) { | |
return Array(length + 1).join(string) | |
} | |
/** | |
* なんかの文字埋め | |
*/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('DATE_MySQL_DATE', 'Y-m-d'); | |
define('DATE_MySQL_TIME', 'H:i:s'); | |
define('DATE_MySQL_YEAR', 'Y'); | |
define('DATE_MySQL_DATETIME', DATE_MySQL_DATE . ' ' . DATE_MySQL_TIME); | |
$now = time(); | |
echo date(DATE_ATOM, $now), "\n"; // => 2019-07-19T15:51:27+09:00 | |
echo date(DATE_RSS, $now), "\n"; // => Fri, 19 Jul 2019 15:51:27 +0900 | |
echo date(DATE_MySQL_DATE, $now), "\n"; // => 2019-07-19 |
NewerOlder