Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@nowri
nowri / util.js
Last active May 8, 2017 20:16
inputフォームのvalueをHH:mm形式にフォーマットする
import moment from 'moment'
export default {
formInputTime (val = '') {
let h, m, ar
val = val.replace(/(^\s+)|(\s+$)/g, '').replace(/\n/g, '')
ar = val.split(':')
if (ar.length === 2) {
h = ar[0]
m = ar[1]
} else {
@nowri
nowri / sphover.js
Created April 17, 2017 06:26
スマホブラウザでホバーエフェクト。Androidブラウザのtouchend対応
var hoverEffect = function($dom, timerIdList) {
var CLASS_HOVER = "hover",
touthStart = (Modernizr.touch)? "touchstart" : "mouseover",
touthEnd = (Modernizr.touch)? "touchend" : "mouseout",
isAndroid = isMobile.Android();
$dom.each(function(i, el){
@nowri
nowri / es6timer.js
Created July 15, 2016 07:55
ES6Timer
const STATE_READY = 1;
const STATE_PLAYING = 2;
const STATE_PAUSE = 3;
const STATE_END = 0;
class Timer {
constructor(updateFunc, sec) {
this.sec = sec;
this.updateFunc = updateFunc;
this.state = STATE_READY;
{
"remove-empty-rulesets": true,
"always-semicolon": true,
"color-case": "lower",
"block-indent": " ",
"color-shorthand": false,
"element-case": "lower",
"eof-newline": true,
"leading-zero": true,
"quotes": "double",
const NumberUtil = (function() {
"use strict";
function normalize(value, minimum, maximum) {
return (value - minimum) / (maximum - minimum);
}
function interpolate(normValue, minimum, maximum) {
@nowri
nowri / GasAuth.js
Last active November 9, 2015 08:43
ES6対応 GAS、Execution API実行用認証スクリプト 参考 : https://developers.google.com/apps-script/guides/rest/quickstart/js
// Your Client ID can be retrieved from your project in the Google
// Developer Console, https://console.developers.google.com
const CLIENT_ID = 'CHANGE_YOUR_CLIENT_ID';
const SCOPES = ['CHANGE_YOUR_SCOPES'];
const SCRIPT_ID = 'CHANGE_YOUR_SCRIPT_ID';
//callback events
export const COMPLETE = "complete";
export const ERROR = "error";
@nowri
nowri / jquery.redux.js
Last active January 15, 2020 01:59
jQueryでFluxライブラリreduxを使えるようになるPlugin
/*! jquery.redux.js | Copyright (c) 2015 nowri | The MIT License (MIT) */
(function(factory) {
if(typeof exports === 'object') {
factory(require('jquery'));
} else if(typeof define === 'function' && define.amd) {
define(['jquery'], factory);
} else {
factory(jQuery);
}
}(function($) {
@nowri
nowri / mithrilutil.js
Last active August 28, 2015 03:54
mithrilでredux使う
define(["lodash"], function(_){
return {
bindActionsMithril: function(actions, store, m) {
var newActions = {};
store.subscribe(function() {
m.endComputation();
});
_.each(actions, function(action, key){
newActions[key] = function() {
var act;
@nowri
nowri / file0.js
Last active August 29, 2015 14:27
GASで非共有Driveファイルのオーナー権限を変更する ref: http://qiita.com/nowri/items/2d33f9ba580da52c913c
var file = DriveApp.getFileById("FILE_ID_HERE");//自分がオーナーのファイル
var targetMail = "new@example.org";
var oldMail;
file.setOwner(targetMail);
oldMail = Session.getActiveUser().getEmail();
file.removeEditor(oldMail);
@nowri
nowri / index.js
Last active August 29, 2015 14:27
react-jade amd-export gulp-plugin
var gutil = require('gulp-util');
var through = require('through2');
var jade = require('react-jade');
var ext = gutil.replaceExtension;
module.exports = function (outputFileName) {
function transform(file, enc, cb) {
var jadePath = file.path;
file.path = ext(file.path, '.js');
if(file.isStream()){