Skip to content

Instantly share code, notes, and snippets.

View 2no's full-sized avatar
🥳

Kazunori Ninomiya 2no

🥳
View GitHub Profile
@2no
2no / Gruntfile.js
Created March 1, 2013 07:49
Mac + grunt 0.4.0 + grunt-devtools + grunt-contrib-livereload。 livereload の拡張機能を On にしつつ、devtools で livereload を開始すると livereload.js が読み込めずに自動リロードが機能しなくなる為、ブロウザの再読み込みを追加
module.exports = function(grunt) {
'use strict';
var path = require('path'),
lrSnippet = require('grunt-contrib-livereload/lib/utils').livereloadSnippet,
folderMount = function folderMount(connect, point) {
return connect.static(path.resolve(point));
};
grunt.initConfig({
@2no
2no / .vimrc
Last active December 14, 2015 16:19
ST2 の Emmet ライクなスニペット
let g:user_emmet_settings = {
\ 'html' : {
\ 'expandos' : {
\ '!' : 'html:5'
\ },
\ 'snippets' : {
\ '!!' : "<!doctype html>",
\ '!!!4t' : "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">",
\ '!!!4s' : "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">",
\ '!!!xt' : "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">",
@2no
2no / gist:5115207
Created March 8, 2013 09:15
FuelPHP 1.5.2 と 1.5.3 の差分(パス省略)
diff -qr fuelphp-1.5.3 fuelphp-1.5.2
Only in fuelphp-1.5.3/fuel/app/cache: fuel
Only in fuelphp-1.5.3/fuel/app/logs: 2013
Only in fuelphp-1.5.3/fuel/app/views: person
fuel/core/classes/fuel.php
fuel/core/classes/security.php
fuel/core/config/config.php
fuel/app/config/config.php
docs/assets/js/combined.js
@2no
2no / Gruntfile.js
Last active December 15, 2015 03:38
インデントや複数行続く改行を削除(script, style 要素は除外)
module.exports = function(grunt)
{
'use strict';
grunt.config.init({
html_clean: {
html: {
src: 'sample.html',
newline: '\r\n', // 省略可
},
@2no
2no / Gruntfile.js
Created March 19, 2013 12:27
grunt-templater にパス取得用のヘルパー。現在処理中のテンプレートのパスやファイル名の取得などが行える…はず。$ npm install grunt grunt-templater ejs
module.exports = function(grunt)
{
'use strict';
var ROOT_PATH = '.',
TEMPLATE_PATH = ROOT_PATH + '/templates';
grunt.config.init({
template: {
hoge: {
@2no
2no / Gruntfile.js
Last active December 16, 2015 07:08
grunt.file.write はファイルエンコーディングを指定して保存が可能だが、iconv-lite を使っている関係で SJIS などの保存は出来ない。 別途 iconv をインストールして対応する必要がある。 (ただし、libiconv にパッチをあてないと SJIS-win や EUCJP-win は扱えない)
'use strict';
module.exports = function(grunt) {
grunt.initConfig({
encoding: {
standardSetting: {
toEncoding: 'SJIS'
, files: {
'dest/result.txt': 'src/original.txt'
, 'dest/concat.txt': ['src/concat/*.txt']
@2no
2no / ect_helper_path.js
Last active December 16, 2015 14:49
grunt-ect 用パスヘルパー。require('./lib/helper').Path.setRoot でルートを指定することも可能
'use strict';
module.exports = function(grunt)
{
var Path = require('./lib/helper').Path;
grunt.task.renameTask('ect', 'grunt-ect_ect');
grunt.task.registerMultiTask('ect', 'overwrite by grunt-ect helper',
function() {
var config = {}
@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
@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 / 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);