Skip to content

Instantly share code, notes, and snippets.

@kijtra
kijtra / author-and-committer-bulk-change.sh
Last active May 15, 2020 08:18
Gitで過去のコミットのAuthorとCommitterを一括変更する
#!/bin/sh
git filter-branch --env-filter '
OLD_EMAIL="old@example.com"
CORRECT_NAME="new-user-name"
CORRECT_EMAIL="new@example.com"
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
then
$base: 16px;
$bg_positions: (
mini: (
w: $base,
h: $base,
x: 0,
y: $base
),
big: (
@kijtra
kijtra / template.html
Last active October 19, 2021 15:08
Pure CSS Admin Template skeleton (demo: https://codepen.io/kijtra/pen/MpZeGq )
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Admin Template</title>
<link rel="stylesheet" href="template.css">
</head>
<body>
@kijtra
kijtra / user.sql
Last active October 28, 2016 13:48
User information store DB(MySQL) structure example
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`id` BIGINT(20) UNSIGNED NOT NULL AUTO_INCREMENT,
`name` VARCHAR(50) NOT NULL DEFAULT '',
`email` VARCHAR(100) NOT NULL DEFAULT '',
`password` CHAR(60) NOT NULL DEFAULT '', /* Use PHP's password_hash() */
`display_name` VARCHAR(191) NOT NULL DEFAULT '',
`url` VARCHAR(191) NOT NULL DEFAULT '',
`registered_at` DATETIME NULL DEFAULT NULL,
@kijtra
kijtra / .bashrc
Last active October 5, 2017 05:37
Bash color like Windows Git Bash
function show_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ \(\1\)/'
}
function show_colored_prompt {
local WHITE="\[\e[00m\]"
local GRAY="\[\e[1;30m\]"
local LIGHTGREEN="\[\e[1;32m\]"
local GREEN="\[\e[0;32m\]"
local PURPLE="\[\e[0;35m\]"
@kijtra
kijtra / numalpha.php
Last active September 10, 2016 15:06
#PHP Numeric to Alphabet OR Alphabet to Numeric function very simple
<?php
function numalpha($value) {
if (ctype_digit((string) $value)) {
return strtr(base_convert($value, 10, 36), '0123456789', 'ABCDEFGHIJ');
} elseif (ctype_alpha($value)) {
return base_convert(strtr($value, 'ABCDEFGHIJ', '0123456789'), 36, 10);
}
return false;
}
@kijtra
kijtra / google_maps_api-padding_bounds.js
Last active June 25, 2016 05:29
Get Paddinged Bounds for MapGoogle Maps API
if (google && google.maps && !google.maps.Map.prototype.getPadBounds) {
google.maps.Map.prototype.getPadBounds = function (top, right, bottom, left) {
top = (('' + top).match(/^[0-9]+$/i) ? parseInt(top) : 0);
right = (('' + right).match(/^[0-9]+$/i) ? parseInt(right) : 0);
bottom = (('' + bottom).match(/^[0-9]+$/i) ? parseInt(bottom) : 0);
left = (('' + left).match(/^[0-9]+$/i) ? parseInt(left) : 0);
var bounds = this.getBounds();
var scale = Math.pow(2, this.getZoom());
var proj = this.getProjection();
@kijtra
kijtra / pref_ids.php
Created June 9, 2016 04:14
都道府県ID(pref)
<?php
$pref_ids = array(
'01' => '北海道', '02' => '青森県', '03' => '岩手県', '04' => '宮城県', '05' => '秋田県',
'06' => '山形県', '07' => '福島県', '08' => '茨城県', '09' => '栃木県', '10' => '群馬県',
'11' => '埼玉県', '12' => '千葉県', '13' => '東京都', '14' => '神奈川県', '15' => '新潟県',
'16' => '富山県', '17' => '石川県', '18' => '福井県', '19' => '山梨県', '20' => '長野県',
'21' => '岐阜県', '22' => '静岡県', '23' => '愛知県', '24' => '三重県', '25' => '滋賀県',
'26' => '京都府', '27' => '大阪府', '28' => '兵庫県', '29' => '奈良県', '30' => '和歌山県',
'31' => '鳥取県', '32' => '島根県', '33' => '岡山県', '34' => '広島県', '35' => '山口県',
'36' => '徳島県', '37' => '香川県', '38' => '愛媛県', '39' => '高知県', '40' => '福岡県',
@kijtra
kijtra / depot.php
Last active March 19, 2016 15:05
#PHP simple flexible data container with ArrayObject
<?php
function depot()
{
static $container = null;
if (null === $container) {
$container = new \ArrayObject(array(), $flag);
}
$flag = \ArrayObject::ARRAY_AS_PROPS;
$args = func_get_args();
@kijtra
kijtra / meta_tag.php
Last active March 17, 2016 15:37
#PHP html meta-tag (OGP, FB app, Twitter Cards, etc) helper.
<?php
function meta_tag()
{
static $buffer = array();
$charset = 'utf-8';
$num = func_num_args();
$args = func_get_args();
if (2 === $num && is_string($args[0]) && is_string($args[1])) {