Skip to content

Instantly share code, notes, and snippets.

@mstssk
mstssk / rgba2hex.js
Created June 9, 2014 08:57
rgba2hex.js
/**
* Converts RGB or RGBA format to Hex format.
* e.g. "rgb(28, 166, 171)" -> "#1ca6ab"
*
* @param rgba A color of RGB or RGBA format.
* @return A color of Hex format;
*/
function rgba2hex(rgba) {
var regex = /rgba?\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+)\s*)?\)/
parsed = regex.exec(rgba), red, green, blue, alpha, elems;
@mstssk
mstssk / .gti.sh
Last active August 29, 2015 14:06
alias gti=~/.gti.sh
#!sh
# Re-concatenate command. Care quoted arguments.
command="git"
while [ "$1" != "" ]
do
space_contain=`echo $1 | grep "\s"`
if [ "" != "$space_contain" ]
then
command="$command \"$1\""
@mstssk
mstssk / export-png.sh
Created January 14, 2015 15:10
Inkscape書いたアイコンをpngでエクスポートするシェルスクリプト。※元svgのファイル名と書き出すpngが同じ名前の前提。
#!/bin/bash
# dry-run
DRYRUN=0
# Requires inkscape
if ! type inkscape >/dev/null 2>&1; then
echo "Inkscape is NOT installed."
exit 1
fi
@mstssk
mstssk / commit-msg
Last active August 29, 2015 14:13
[BitBucket用]コミットコメントに #123 の様にチケットIDが書かれているのにActionコマンドが書かれていない場合に確認メッセージを出すフックスクリプト
#!/usr/bin/env ruby
# Resolve issues automatically when users push code - Bitbucket - Atlassian Documentation
# https://confluence.atlassian.com/display/BITBUCKET/Resolve+issues+automatically+when+users+push+code
require "readline"
# commands
resolve = Regexp.union(%w(close closes closed closing fix fixed fixes fixing resolve resolves resolved resolving))
reopen = Regexp.union(%w(reopen reopens reopening))
rect[fill="#d6e685"] { fill: #9fc1ea; }
rect[fill="#8cc665"] { fill: #60b7d8; }
rect[fill="#44a340"] { fill: #0592d0; }
rect[fill="#1e6823"] { fill: #252775; }
.legend li:nth-child(2) { background-color: #9fc1ea !important; }
.legend li:nth-child(3) { background-color: #60b7d8 !important; }
.legend li:nth-child(4) { background-color: #0592d0 !important; }
.legend li:nth-child(5) { background-color: #252775 !important; }
@mstssk
mstssk / toggle_finder_showallfiles.sh
Created April 15, 2015 14:26
MacのFinderの隠しファイルの表示/非表示をトグルするsh。一番初めは設定値がそもそも無いので、手で一度コマンド叩いておく必要がある。
#!/bin/bash
conf=`defaults read com.apple.finder AppleShowAllFiles`
if [ $conf = 'true' ]
then
newConf='false'
else
newConf='true'
fi
@mstssk
mstssk / series.md
Last active November 16, 2015 02:34
ここまで書いて飽きた http://togetter.com/li/836756

シリーズ

  1. バロム・1
  • 仮面ライダーV3
  • ザンボット3
  • ダイターン3
  • ストラトス・フォー
  • 1月
  • 2月
  • 3月のライオン
  • 4月は君の嘘
  • 5月
  • 6月
  • 7月4日に生まれて
  • 8月
  • 9月
  • 10月
@mstssk
mstssk / git-show-date.sh
Created March 22, 2016 16:01
gitのコミットIDと日付から雑にファイル名を作る
git show --pretty=format:'%cd %H.pdf' --date=iso | head -n1
@mstssk
mstssk / style.css
Created June 30, 2016 01:28
Twitterのアンケート機能で投票していなくてもパーセンテージが見えるようにする
/* style for https://twitter.com/ */
.TwitterCard [data-poll-state=opened] .PollXChoice-optionContainer .PollXChoice-progress {
max-width: 100% !important;
margin-left: .64286em !important;
margin-right: .64286em !important;
}