Skip to content

Instantly share code, notes, and snippets.

Avatar

Shinichi Tomita stomita

View GitHub Profile
View .babelrc
{
"presets": [
["@babel/env", {
"targets": { "esmodules": true }
}]
]
}
@stomita
stomita / index.ts
Last active Feb 21, 2019
ScanSnap Home(Mac)で読み取った名刺情報を名刺画像ごとSalesforceへ登録する(TypeScript)
View index.ts
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 Nov 2, 2018
This is a proposal of `createStateHook`, in order to eliminate call order magic and top-level restriction
View custom-hook-creator.js
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 Oct 16, 2018
Create React's new context API style component with legacy context
View legacy-context.js
/* @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 Oct 13, 2018
Legacy & New Context API / shouldUpdate is ignored in Function Component
View index.js
/**
*
*/
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 Feb 16, 2017
Flowtypeの不可解な挙動
View flowtest.js
/* @flow */
type NMap = { [key:string]: number }
// これは当然だめ
const map1: NMap = {
a: 1,
b: 2,
c: 'a',
};
@stomita
stomita / GAEmbedAPITest.page
Created Jan 28, 2016
Google Analytics Embed APIのサンプルをVF Pageにしたサンプル
View GAEmbedAPITest.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 Aug 28, 2015
security change after signup of DE
View gist:538bfaac981571fd6e7d
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' } });
});
View jwt.txt
eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJodHRwczovL2p3dC1pZHAuZXhhbXBsZS5jb20iLCJzdWIiOiJtYWlsdG86bWlrZUBleGFtcGxlLmNvbSIsIm5iZiI6MTQzOTA0MjI1NiwiZXhwIjoxNDM5MDQ1ODU2LCJpYXQiOjE0MzkwNDIyNTYsImp0aSI6ImlkMTIzNDU2IiwidHlwIjoiaHR0cHM6Ly9leGFtcGxlLmNvbS9yZWdpc3RlciIsImF1ZCI6WyJodHRwOi8vZm9vMS5jb20iLCJodHRwOi8vZm9vMi5jb20iXX0.ypVdY0dmsbThmOa08qe2g0aMeG8fBKxLTZn7y1lBKt4
@stomita
stomita / app001.test-bundle-by-cmd.js
Last active Aug 29, 2015
browserify+espowerifyでassertの結果がおかしくなる件
View app001.test-bundle-by-cmd.js
/*
* 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)',