Skip to content

Instantly share code, notes, and snippets.

@kyo-ago
kyo-ago / transform.ts
Created March 5, 2023 13:38
react-admin v3 to v4 upgrade code-mod
import {Transform} from "jscodeshift";
const transform: Transform = (fileInfo, api, options) => {
const j = api.jscodeshift;
const root = j(fileInfo.source);
root.find(j.JSXOpeningElement, {
name: { name: 'TextInput' },
})
.replaceWith(({node}) => {
@kyo-ago
kyo-ago / transform.ts
Last active March 5, 2023 01:52
react-router v5 to v6 upgrade code-mod
import {Transform} from "jscodeshift";
const transform: Transform = (fileInfo, api, options) => {
const j = api.jscodeshift;
const root = j(fileInfo.source);
root
.find(j.ImportDeclaration)
.filter(path => path.node.source.value === 'react-router' || path.node.source.value === 'react-router-dom')
.find(j.ImportSpecifier)
@kyo-ago
kyo-ago / index.gs
Created August 16, 2022 00:46
slack channel rename bot
var parseParams = function (qs) {
return qs.split(/&/).reduce((base, cur) => {
const kv = cur.split(/=/);
base[decodeURIComponent(kv.shift())] = decodeURIComponent(kv.join('='));
return base;
}, {});
}
function doPost(e) {
var prop = PropertiesService.getScriptProperties().getProperties();
/**
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 June 7, 2018 13:44
Karabiner-Elementsのcomplex_modificationsを展開するやつ
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$",
],
{
"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 October 28, 2017 13:52
application cache loading 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 March 30, 2014 14:17
休日だけhueの操作を変えるGAS(作りかけ)
var account = {
'email': '',
'password': ''
};
var bridgeid = '';
var initializeParameter = {
'devicetype' : 'GAS',
'username' : 'newdeveloper'
};
@kyo-ago
kyo-ago / gist:8280903
Last active January 2, 2016 09:09
JavaScriptでDCI的なものを実装してみた例
// 銀行口座
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);
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