Skip to content

Instantly share code, notes, and snippets.

View 2no's full-sized avatar
🥳

Kazunori Ninomiya 2no

🥳
View GitHub Profile
@2no
2no / battery.cpp
Created May 30, 2014 09:37
Cygwin, gcc-g++ $ make battery
#include <iostream>
#include <windows.h>
int main(int argc, char *argv[])
{
SYSTEM_POWER_STATUS powerStatus;
int percent = 0;
if (GetSystemPowerStatus(&powerStatus) == TRUE) {
percent = (int)powerStatus.BatteryLifePercent;
@2no
2no / console2-hybrid.xml
Created May 29, 2014 02:04
A dark colour scheme for Console2
<?xml version="1.0"?>
<settings>
<console>
<colors>
<color id="0" r="40" g="42" b="32"/>
<color id="1" r="165" g="66" b="66"/>
<color id="2" r="140" g="148" b="64"/>
<color id="3" r="222" g="147" b="95"/>
<color id="4" r="95" g="129" b="157"/>
<color id="5" r="133" g="103" b="143"/>
@2no
2no / .minttyrc-hybrid
Last active August 29, 2015 14:01
Hybrid color settings for the Cygwin mintty terminal. $ cat .minttyrc-hybrid >> ~/.minttyrc
BackgroundColour=29,31,33
ForegroundColour=197,200,198
BoldBlack=40,42,46
Black=55,59,65
BoldRed=165,66,66
Red=204,102,102
BoldGreen=140,148,64
Green=181,189,104
BoldYellow=222,147,95
Yellow=240,198,116
@2no
2no / dogrunt.applescript
Created February 6, 2014 12:39
https://gist.github.com/wakuworks/5500063 を改良。ローカルファイルに grunt がなければ `npm install` を実行。さらにその後 `grunt` コマンド実行する
tell application "Finder"
set myWin to window 1
set theWin to (quoted form of POSIX path of (target of myWin as alias))
tell application "Terminal"
activate
tell window 1
do script "/bin/sh -c 'cd " & theWin & "; npm list grunt | grep empty >/dev/null 2>&1 && npm install; grunt'"
end tell
end tell
end tell
@2no
2no / npm.fish
Last active December 27, 2015 07:19
npm の入力補完 ~/.config/fish/completions/npm.fish
#!fish
if not type npm >/dev/null 2>&1
exit
end
set -l cmds \
add-user adduser apihelp author bin bugs c cache completion config ddp \
dedupe deprecate docs edit explore faq find find-dupes get help help-search \
home i info init install isntall issues la link list ll ln login ls outdated \
@2no
2no / composer.fish
Last active December 27, 2015 06:19
composer の入力補完 ~/.config/fish/completions/composer.fish
#!fish
if not type composer >/dev/null 2>&1
exit
end
composer --no-ansi | sed "1,/Available commands/d" | while read line
echo $line | sed "s/\s+//" | read cmd desc
complete -f -c composer -n '__fish_composer_using_command' -a "$cmd" -d "$desc"
end
git clone https://github.com/Version2beta/vagrant-chef-wordpress
cd vagrant-chef-wordpress
vagrant up
# http://localhost:8000 にアクセス
@2no
2no / sample.scss
Last active December 17, 2015 18:18
Sass で sprintf。compass なら、config.rb に sprintf.rb の内容を書いておくと使える。
$tmp: "";
.sample1:after{
$tmp: sprintf("%02d,%02d", 1, 2);
content: "#{$tmp}";
}
// 結果:content: "01,02";
$tmp: "";
.sample1:after{
$tmp: sprintf("%.5s", foobar);
@2no
2no / sample.scss
Last active December 17, 2015 16:59
Sass に文字列置換の関数を追加し、更に引数で関数を指定できる様にしてみる
$tmp: "";
.sample:after {
$tmp: str-replace("/_./", "|x|x.upcase.sub!('_', '')", "test_hoge");
content: "#{$tmp}";
}
// 結果:content: "testHoge";
$tmp: "";
.sample2:after{
$tmp: str-replace("_", "", "test_hoge");
@2no
2no / dogrunt.applescript
Last active December 16, 2015 21:29
このスクリプトを AppleScript エディタでアプリケーションとして保存した後、Finder のツールバーにボタンとして置いておく。後は Gruntfile.js があるディレクトリでボタンをクリックすれば自動的にターミナルが立ち上がって grunt コマンドを実行する
tell application "Finder"
set myWin to window 1
set theWin to (quoted form of POSIX path of (target of myWin as alias))
tell application "Terminal"
activate
tell window 1
do script "cd " & theWin & ";grunt"
end tell
end tell
end tell