Skip to content

Instantly share code, notes, and snippets.

View gist:9edef603294f6ebc1966779af00fe5b7
/**
Copyright (c) 2018 kyo-ago
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@kyo-ago
kyo-ago / make.js
Last active Jun 7, 2018
Karabiner-Elementsのcomplex_modificationsを展開するやつ
View make.js
let fs = require('fs');
let karabinerJsonPath = `${process.env.HOME}/.config/karabiner/karabiner.json`;
let conditionAppMap = {
browsers: [
"^com\\.google\\.Chrome$",
"^org\\.mozilla\\.firefox$",
"^com\\.apple\\.Safari$",
],
View electron.webpack.config.json
{
"context": "/Users/kyo/projects/lifter/packages/lifter-app",
"devtool": "nosources-source-map",
"externals": [
"@lifter/electron-window-manager",
"@lifter/lifter-common",
"@lifter/lifter-main",
"@lifter/networksetup-proxy",
"electron-context-menu",
"electron-ipc",
@kyo-ago
kyo-ago / appcache.js
Last active Oct 28, 2017
application cache loading js
View appcache.js
(function (app) {
var loading_class = 'loading';
var html = document.documentElement;
loading_class = ' ' + loading_class + ' ';
//未サポート
if (!app || app.UNCACHED === app.status) {
init();
return;
}
@kyo-ago
kyo-ago / gist:9873380
Created Mar 30, 2014
休日だけhueの操作を変えるGAS(作りかけ)
View gist:9873380
var account = {
'email': '',
'password': ''
};
var bridgeid = '';
var initializeParameter = {
'devicetype' : 'GAS',
'username' : 'newdeveloper'
};
@kyo-ago
kyo-ago / gist:8280903
Last active Jan 2, 2016
JavaScriptでDCI的なものを実装してみた例
View gist:8280903
// 銀行口座
var BankAccount = function (balance) { this.balance = balance; };
BankAccount.prototype.increase = function (money) { this.balance += money; };
BankAccount.prototype.decrease = function (money) { this.balance -= money; };
// ロール: 送信側
var Sender = function () {};
Sender.prototype.send = function (money, to) {
this.decrease(money);
to.onReceived(money, this);
View gist:7358474
trait Node {
val number: Int
def max: Int = this.number
def min: Int = this.number
def sum: Int = this.number
def avg: List[Int] = List(this.number)
def find(e: Int): Option[Node] = if (this.number == e) Some(this) else None
}
case class Branch(left: Node, number: Int, right: Node) extends Node {
override def max: Int = List(left.max, this.number, right.max).max
View gist:7299747
import scala.util._
def binarySearch(number: Int, numbers: List[Int]): Try[Int] = {
def Y[A,B]( f:((A => B), A ) => B, x:A ):B = f( (y:A) => Y(f,y),x)
Success(Y( (f: ((Int, Int)) => (Int, Int), n: (Int, Int)) => {
if (n._1 == n._2) return Failure(new NoSuchElementException)
((mid: Int) => {
((numbers(mid), number) match {
case (l, r) if l > r => f(n._1, mid)
case (l, r) if l < r => f(mid + 1, n._2)
case _ => (mid, -1)
View gist:7292974
'use strict';
module.exports = function (grunt) {
var _ = grunt.util._;
var esprima = require('esprima');
var licenseRegExp = /BSD|MIT|License/i;
grunt.registerTask('save-license', 'Save the license', function () {
this.files.forEach(function (file) {
var valid = file.src.filter(grunt.file.exists.bind(grunt.file));
_.difference(file.src, valid).forEach(function (filepath) {
@kyo-ago
kyo-ago / background.js
Created Jul 28, 2013
githubのCSPを消すbackground.js
View background.js
chrome.webRequest.onHeadersReceived.addListener(function (details) {
for (var i = 0, l = details.responseHeaders.length; i < l; i++) {
var res = details.responseHeaders[i];
if (res.name.toLowerCase() !== 'content-security-policy')
continue;
res.value = '';
}
return {
'responseHeaders': details.responseHeaders
};