Skip to content

Instantly share code, notes, and snippets.

View 2no's full-sized avatar
🥳

Kazunori Ninomiya 2no

🥳
View GitHub Profile
@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 / 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 / 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 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 / 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 / .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 / 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 / grunt.js
Last active December 13, 2015 21:18
某サイトのマネ。Resource.get をテンプレートに用意して、更新日時を src の最後に追加してキャッシュ対策。 $ npm install grunt-contrib grunt-templater ejs
module.exports = function(grunt) {
'use strict';
var
/**
* ルートパス
*
* @constant
* @type {string}
@2no
2no / exsample.js
Created November 24, 2012 12:42
jQuery.timeline.js - アニメーションタイムライン
// jQuery、timeline.js を事前に読み込んでおく必要あり
//
// timeline.js について
// - http://hitsujiwool.tumblr.com/post/31191259501/timeline-js
// - https://github.com/hitsujiwool/timeline
// 使い方1:一括指定して実行
var totalFrames = 200,
tl = $("div").timeline(totalFrames)
@2no
2no / gist:3824817
Created October 3, 2012 03:27
Grunt で js を minify して gzip 圧縮
// 個別で js を minify して gzip したかったので、こんな感じになった
// ファイル名などにスペースが入ってた時どうするのか
module.exports = function(grunt) {
'use strict';
var src = 'shared/js/*.js',
files = grunt.file.expandFiles(src),
suffix = '.min',
minFiles = {},
gzFiles = {};