Skip to content

Instantly share code, notes, and snippets.

@syuji-higa
syuji-higa / git-diff-archive.sh
Last active November 16, 2019 04:59
batch - Git diff and archive
repos={repositorys}
target={target}
output={output}
name=$1
suffix=$2
from=$3
to=$4
repo=${repos}/${name}
@syuji-higa
syuji-higa / .gitignore
Last active November 16, 2019 04:58
Git - ignore default setting
# cache
.DS_Store
Thumb.db
# log
*.log
# npm
node_modules
@syuji-higa
syuji-higa / .htaccess
Last active November 16, 2019 04:57
htaccess - defaualt setting
SetEnvIf User-Agent "^facebookexternalhit" facebook
SetEnvIf User-Agent "^Twitterbot" twitter
SetEnvIf User-Agent "^mixi-check" mixi
SetEnvIf User-Agent "Android" android
SetEnvIf User-Agent "\(\+https:\/\/developers\.google\.com\/\+\/web\/snippet\/" google
Satisfy Any
Order Deny,Allow
Deny from all
@syuji-higa
syuji-higa / ajax-api-get.php
Last active November 12, 2020 03:05
PHP - get data with Ajax
<?php
// リクエスト形式によってはヘッダーに入ってこないので削除
if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) ||
$_SERVER['HTTP_X_REQUESTED_WITH'] !== 'XMLHttpRequest') {
die(json_encode(array('status' => "Invalid call.")));
}
setlocale(LC_ALL, 'ja_JP.UTF-8');
// application/json の POST リクエストの場合は、$_POST に入ってこないので以下から取得
// $params = json_decode(file_get_contents('php://input'), true);
if($_SERVER['REQUEST_METHOD'] !== 'POST') {
@syuji-higa
syuji-higa / ajax-get-test-data.php
Last active November 16, 2019 04:55
PHP - get data with Ajax
<?php
if(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) ||
$_SERVER['HTTP_X_REQUESTED_WITH'] !== 'XMLHttpRequest') {
die(json_encode(array('status' => "Invalid call.")));
}
$value = array(
array('id' => 0, 'name' => 'taro', 'age' => '25'),
array('id' => 0, 'name' => 'jiro', 'age' => '20'),
);
header('Content-Type: application/json; charset=UTF-8');
@syuji-higa
syuji-higa / csv-search-view.php
Last active November 16, 2019 04:52
PHP - search CSV view
<?php
setlocale(LC_ALL, 'ja_JP.UTF-8');
function get_csv_search_to_map($csv, $search_key, $search_val) {
$csv = ereg_replace("\r\n|\r|\n", "\n", $csv);
$csv = mb_convert_encoding($csv, 'UTF-8', 'sjis-win');
$temp = tmpfile();
$meta = stream_get_meta_data($temp);
fwrite($temp, $csv);
rewind($temp);
$file = new SplFileObject($meta['uri']);
@syuji-higa
syuji-higa / csv-to-map.php
Last active November 16, 2019 04:52
PHP - CSV to map
<?php
setlocale(LC_ALL, 'ja_JP.UTF-8');
function csv_to_map($csv) {
$csv = ereg_replace("\r\n|\r|\n", "\n", $csv);
$csv = mb_convert_encoding($csv, 'UTF-8', 'sjis-win');
$temp = tmpfile();
$meta = stream_get_meta_data($temp);
fwrite($temp, $csv);
rewind($temp);
$file = new SplFileObject($meta['uri']);
@syuji-higa
syuji-higa / csv-to-map_plus.php
Last active November 16, 2019 04:53
PHP - CSV to map plus
<?php
if($_SERVER['SERVER_NAME'] === 'xxxxx.xxx' &&
(!isset($_SERVER['HTTP_X_REQUESTED_WITH']) ||
$_SERVER['HTTP_X_REQUESTED_WITH'] !== 'XMLHttpRequest')) {
die(json_encode(array('status' => "Invalid call.")));
}
setlocale(LC_ALL, 'ja_JP.UTF-8');
function csv_to_map($csv) {
$csv = ereg_replace("\r\n|\r|\n", "\n", $csv);
$csv = mb_convert_encoding($csv, 'UTF-8', 'sjis-win');
@syuji-higa
syuji-higa / .stylintrc
Last active March 14, 2020 11:20
Style Lint - setting for Stylus Supremacy
{
"blocks": false,
"brackets": "never",
"colons": "never",
"colors": "always",
"commaSpace": "always",
"commentSpace": "always",
"cssLiteral": "never",
"customProperties": [],
"depthLimit": false,
@syuji-higa
syuji-higa / settings.json
Last active November 16, 2019 04:29
VSCode - auto format on save for JavaScript
{
"[javascript]": {
"editor.formatOnSave": true,
},
"[typescript]": {
"editor.formatOnSave": true,
},
}