Skip to content

Instantly share code, notes, and snippets.

View stomita's full-sized avatar

Shinichi Tomita stomita

View GitHub Profile
{
"presets": [
["@babel/env", {
"targets": { "esmodules": true }
}]
]
}
@stomita
stomita / index.ts
Last active February 21, 2019 08:52
ScanSnap Home(Mac)で読み取った名刺情報を名刺画像ごとSalesforceへ登録する(TypeScript)
import fs from 'fs';
import os from 'os';
import path from 'path';
import sqlite3 from 'sqlite3';
import jsforce, { Connection } from 'jsforce';
const SCANSNAP_DB_DIR = path.join(os.homedir(), '/Library/Application Support/PFU/ScanSnap Home/Managed/');
const SCANSNAP_FILE_DIR = path.join(os.homedir(), '/Documents/ScanSnapHome.localized');
const SCANSNAP_DB_FILE = path.join(SCANSNAP_DB_DIR, 'ScanSnapHome.sqlite');
const TIMESTAMP_FILE = '.timestamp';
@stomita
stomita / custom-hook-creator.js
Last active November 2, 2018 09:29
This is a proposal of `createStateHook`, in order to eliminate call order magic and top-level restriction
import { createStateHook } from 'react';
export function createFormInputHook() {
const useValueState = createStateHook();
return (initialValue) => {
const [value, setValue] = useValueState(initialValue);
function onHandleChange(e) {
setValue(e.target.value);
}
return { value, onChange: onHandleChange };
@stomita
stomita / legacy-context.js
Last active October 16, 2018 08:08
Create React's new context API style component with legacy context
/* @flow */
import EventEmitter from 'events';
import React, { type Node, type ComponentType } from 'react';
import PropTypes from 'prop-types';
/**
* Mimics new context API using legacy context
*/
type LegacyContextProvider<T> = ComponentType<{ value: T, children: Node }>;
@stomita
stomita / index.js
Created October 13, 2018 02:18
Legacy & New Context API / shouldUpdate is ignored in Function Component
/**
*
*/
import React, { createContext } from 'react';
import { createStore } from 'redux';
import { connect, Provider } from 'react-redux';
import { render } from 'react-dom';
import { compose, lifecycle, withStateHandlers, shouldUpdate } from 'recompose';
@stomita
stomita / flowtest.js
Last active February 16, 2017 10:15
Flowtypeの不可解な挙動
/* @flow */
type NMap = { [key:string]: number }
// これは当然だめ
const map1: NMap = {
a: 1,
b: 2,
c: 'a',
};
@stomita
stomita / GAEmbedAPITest.page
Created January 28, 2016 15:44
Google Analytics Embed APIのサンプルをVF Pageにしたサンプル
<apex:page showHeader="false" applyBodyTag="false" applyHtmlTag="false" docType="html-5.0">
<html>
<head>
<title>Embed API Demo</title>
</head>
<body>
<!-- Step 1: Create the containing elements. -->
<section id="auth-button"></section>
@stomita
stomita / gist:538bfaac981571fd6e7d
Last active August 28, 2015 09:45
security change after signup of DE
var connName = process.args[1];
console.log('connection = ' + connName);
var conn = jsforce.registry.getConnection(connName);
conn.identity().then(function() {
return conn.metadata.update('SecuritySettings', { fullName: 'Security', passwordPolicies: { expiration: 'Never' }});
}).then(function() {
return conn.metadata.update('Profile', { fullName: 'Admin', loginIpRanges: { startAddress:'0.0.0.0', endAddress: '255.255.255.255' } });
});
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2p3dC1pZHAuZXhhbXBsZS5jb20iLCJzdWIiOiJtYWlsdG86bWlrZUBleGFtcGxlLmNvbSIsIm5iZiI6MTQzOTA0MjI1NiwiZXhwIjoxNDM5MDQ1ODU2LCJpYXQiOjE0MzkwNDIyNTYsImp0aSI6ImlkMTIzNDU2IiwidHlwIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9yZWdpc3RlciIsImF1ZCI6WyJodHRwOi8vZm9vMS5jb20iLCJodHRwOi8vZm9vMi5jb20iXX0.ypVdY0dmsbThmOa08qe2g0aMeG8fBKxLTZn7y1lBKt4
@stomita
stomita / app001.test-bundle-by-cmd.js
Last active August 29, 2015 14:16
browserify+espowerifyでassertの結果がおかしくなる件
/*
* browserify -t espowerify ./build/test/e2e/app001.test.js > ./build/test/e2e/app001.test-bundle-by-cmd.js
*/
//...
'use strict';
var assert = require('power-assert');
describe('apptest001', function () {
it('should raise', function () {
assert(assert._expr(assert._capt(1 === 0, 'arguments/0'), {
content: 'assert(1 === 0)',