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 createChatworkClient(token) { | |
var header = {'X-ChatWorkToken' : token }; | |
return { | |
postMessage: function(roomId, message) { | |
var url = "https://api.chatwork.com/v2/rooms/" + roomId + "/messages"; | |
var payload = { | |
'body': message | |
}; | |
var options = { | |
'method': 'post', |
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 basic_auth_custom(Closure $auth) { | |
switch (true) { | |
case !isset($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']): | |
case !$auth($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW']); | |
header('WWW-Authenticate: Basic realm="Enter username and password."'); | |
header('Content-Type: text/plain; charset=utf-8'); | |
die('このページを見るにはログインが必要です'); | |
} | |
} |
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 ArraySchema { | |
private $value; | |
function __construct(array $value) { | |
$this->value = $value; | |
} | |
function getValue() { | |
return $this->value; | |
} | |
} |
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 rstrpos ($haystack, $needle) { | |
$size = strlen ($haystack); | |
$pos = strpos(strrev($haystack), $needle); | |
if ($pos === false) { | |
return false; | |
} | |
return $size - $pos; | |
} |
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 api_forminput_jsonoutput($get_action, $post_action) { | |
header('Content-Type: application/json; charset=utf-8'); | |
try { | |
if ($_SERVER["REQUEST_METHOD"] == "POST") { | |
echo json_encode($post_action()); | |
} else { | |
echo json_encode($get_action()); | |
} | |
} catch(RuntimeException $e) { |
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 | |
declare(strict_types=1); | |
class StringVO { | |
protected $value; // string | |
function __construct(string $value) { | |
$this->value = $value; | |
} | |
public function getValue(): string { | |
return $this->value; |
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
package com.naosim.table; | |
import java.util.HashMap; | |
import java.util.Map; | |
public class VariousColumnTable<ROW> { | |
private final Map<Class, Integer> columnIndex; | |
private final Map<ROW, Object[]> rows; | |
public VariousColumnTable(Class ...columns) { |
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
package com.naosim.table; | |
import java.util.HashMap; | |
import java.util.Map; | |
public class Table<ROW, CLM, CELL> { | |
private final Map<CLM, Integer> columnIndex; | |
private final Map<ROW, CELL[]> rows; | |
public Table(CLM ...columns) { |
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 EasyInclude { | |
private $root; | |
private $excludePhp; | |
public function __construct($root, $excludePhp = null) { | |
$this->root = $root; | |
$this->excludePhp = $excludePhp; | |
} | |
private function loadFromWeb($url) { |
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 includeFromWeb($url, $root = '.') { | |
$file = $root . '/vendor/' . explode('//', $url)[1]; | |
$dir = substr($file, 0, strrpos($file, '/')); | |
if(!file_exists($file)) { | |
if(!file_exists($dir)) { | |
mkdir($dir, 0777, true); | |
} | |
$text = trim(file_get_contents($url)); |