Skip to content

Instantly share code, notes, and snippets.

Avatar
🕘
JST +09:00

Yoshiaki Sugimoto ysugimoto

🕘
JST +09:00
View GitHub Profile
@ysugimoto
ysugimoto / npm-run-completion.sh
Created Aug 21, 2017
Bash-completion for `npm run` command
View npm-run-completion.sh
#!/bin/bash
# This is bash-completion for 'npm run' command.
# Find up package.json and completion 'npm scripts'.
_npm_run_completion() {
CURRENT="${COMP_WORDS[COMP_CWORD]}"
SUBCOMMAND="${COMP_WORDS[COMP_CWORD-1]}"
if [ "${SUBCOMMAND}" != "run" ]; then
return
fi
@ysugimoto
ysugimoto / 0_reuse_code.js
Created Oct 7, 2016
Here are some things you can do with Gists in GistBox.
View 0_reuse_code.js
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ysugimoto
ysugimoto / ats
Last active Jul 12, 2016
Artisan task selector-runner ( Depend peco )
View ats
#!/bin/sh
# Artisan ( Laravel's CLI tool ) find-up, selectable runner
# @depend
# peco - https://github.com/peco/peco
PHP=`which php`
CWD=`pwd`
ARTISAN="artisan"
COMMAND=
View GetZoneInfo.php
<?php
class GetZoneInfo {
const ORIGIN_SIGNATURE = '$ORIGIN';
const IN_SIGNATURE = 'IN';
const A_RECORD = "A";
const CNAME_RECORD = "CNAME";
protected $fqdnList = [];
@ysugimoto
ysugimoto / setup.sh
Last active Mar 6, 2020
set up docker-compose.yml
View setup.sh
#!/bin/bash
YOU=`whoami`
CWD=$(cd $(dirname $0);pwd)
# Create mout storage directory if not exists
if [ ! -d "$HOME/perfstore/graphite" ]; then
echo "creating directory: $HOME/perfstore/graphite..."
mkdir -p $HOME/perfstore/graphite
fi
@ysugimoto
ysugimoto / qdmail.php
Last active Aug 23, 2017
qdmail for PHP5.3+
View qdmail.php
<?php
/**
* Qdmail ver 1.2.6b
* E-Mail for multibyte charset
*
* PHP versions 4 and 5 (PHP4.3 upper)
*
* Copyright 2008, Spok in japan , tokyo
* hal456.net/qdmail : http://hal456.net/qdmail/
* & CPA-LAB/Technical : http://www.cpa-lab.com/tech/
@ysugimoto
ysugimoto / detect_mp4_duration.sh
Created Jun 24, 2015
MP4の動画ファイルの再生時間を取得するワンライナー
View detect_mp4_duration.sh
#!/bin/sh
# http://qiita.com/takashisite/items/0eeb45c8bbd232e915dd
ffmpeg -i movie.mp4 2>&1 | grep "Duration" | cut -d ' ' -f 4 | sed s/,// | sed 's@\..*@@g' | awk '{ split($1, A, ":"); split(A[3], B, "."); print 3600*A[1] + 60*A[2] + B[1] }'
View Releasenote-Go-1.4.md

Go 1.4 RC1が出たのでまとめ

原文: http://tip.golang.org/doc/go1.4

Introduction to Go 1.4 より

  • ガベージコレクタを改善したよ
  • go コマンドにいくつかツールが追加されたよ
  • Android, NaCl, AMD64上のPlan9サポートが追加されたよ。互換性も維持するよ
@ysugimoto
ysugimoto / ellipsis.js
Last active Aug 29, 2015
複数行をellipsisする君
View ellipsis.js
(function(global) {
'use strict';
function Ellipsis(element, trail) {
this.element = element;
this.exactHeight = element.offsetHeight;
this.text = element.textContent;
this.textSize = this.text.length;
this.trail = trail || '...';
}
@ysugimoto
ysugimoto / getImage.cpp
Last active Jun 1, 2017
Exxternal image shows in Sprite on cocos2d-x v3.x
View getImage.cpp
#include "network/HttpRequest.h"
#include "network/HttpClient.h"
#include "network/HttpResponse.h"
using namespace cocos2d::network;
HttpRequest* request = new HttpRequest();
request->setUrl("http://example.com/external/image.png");
request->setRequestType(HttpRequest::Type::GET);
request->setResponseCallback([this](HttpClient *sender, HttpResponse *response) {