Skip to content

Instantly share code, notes, and snippets.

@ngyuki
ngyuki / .bootstrap-modals
Last active October 29, 2018 00:47
Bootstrap でモーダルを多重表示するサンプル
We couldn’t find that file to show.
function success(t){
return new Promise(resolve => {
setTimeout(() => {
resolve();
}, t);
})
}
function error(t){
return new Promise((resolve, reject) => {
#!/usr/bin/env node
// @see https://qiita.com/soarflat/items/1a9613e023200bbebcb3
function sampleResolve(value) {
return new Promise(resolve => {
setTimeout(() => {
resolve(value);
}, 1000);
})
<?php
namespace strpos {
function startsWith($haystack, $needle) {
return (strpos($haystack, $needle) === 0);
}
function endsWith($haystack, $needle) {
return strrpos($haystack, $needle, 0) === strlen($haystack) - strlen($needle);
}
}
@ngyuki
ngyuki / README.md
Last active August 29, 2015 14:10
run script from user data on aws for centos

Install

curl -o /etc/init.d/auto-userscript \
  https://gist.githubusercontent.com/ngyuki/61bf0262dc1bf450499a/raw/auto-userscript

chmod +x /etc/init.d/auto-userscript

chkconfig --add auto-userscript
@ngyuki
ngyuki / autoissue
Last active September 18, 2020 07:29
auto generate issue for centos6
#!/bin/bash
#
### BEGIN INIT INFO
# Required-Start: $network
# Should-Start: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
### END INIT INFO
#
# chkconfig: 2345 98 02
@ngyuki
ngyuki / autohostname
Created November 18, 2014 13:15
auto set hostname for centos
#! /bin/bash
#
# chkconfig: 2345 11 89
. /etc/init.d/functions
[ -x /sbin/ip ] || exit 1
[ "$EUID" != "0" ] && exit 4
case "$1" in
@ngyuki
ngyuki / daemontools
Last active August 29, 2015 14:09
daemontools ocf script for pacemaker and heartbeat
#!/bin/sh
#######################################################################
# TEST
#
# export OCF_ROOT=/usr/lib/ocf
# export OCF_RESKEY_service_dir=/service/dummy
# export OCF_RESKEY_svc_bin=/usr/bin/svc
# export OCF_RESKEY_svstat_bin=/usr/bin/svstat
#
@ngyuki
ngyuki / ec2-route
Last active August 29, 2015 14:07
aws ec2 change route table lsb script
#!/bin/sh
#
# chkconfig: 12345 01 99
# description: EC2 route change
. /etc/rc.d/init.d/functions
prog=${0##*/}
lock=/var/lock/subsys/$prog
<?php
function compose(callable $initial, callable ...$functions)
{
if (count($functions) < 1) {
throw new \InvalidArgumentException('at least two functions are required');
}
return array_reduce($functions, function ($f, $g) {
return function (...$args) use ($f, $g) {
return $f($g(...$args));