Skip to content

Instantly share code, notes, and snippets.

Working from home

Yuya Tanaka ypresto

Working from home
Block or report user

Report or block ypresto

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
ypresto / settings-for-vscode-color.json
Last active Sep 9, 2019
Personally recommended color config for VSCode
View settings-for-vscode-color.json
"workbench.colorTheme": "One Dark Pro",
"workbench.colorCustomizations": {
"[One Dark Pro]": {
// Reduce brightness
"activityBar.background": "#1b1d23",
"badge.background": "#1b1d23",
"editor.background": "#1b1d23",
"sideBarSectionHeader.background": "#1b1d23",
"tab.activeBackground": "#1b1d23",
ypresto / backtrace_relative_path.rb
Last active May 30, 2019
Prepend specified path to backtrace in rspec output (for rails in subdirectory).
View backtrace_relative_path.rb
# NOTE: Put this file to spec/support/ .
# Prepend specified path to backtrace and Failure/Error section.
# Useful for multi module repository where rails is placed in the subdirectory.
# Intended for editors with click-to-open-file feature.
# For example
# # ./spec/models/your_model_spec.rb:12:in `your_method'
# to
# # ./rails/spec/models/your_model_spec.rb:12:in `your_method'
ypresto / safari-11-file-xhr-workaround.js
Last active May 11, 2018
[Does NOT work in Firefox] iOS 11.3 Safari / macOS Safari 11.1 empty <input type="file"> XHR bug workaround for rails-ujs / jquery_ujs
View safari-11-file-xhr-workaround.js
// iOS 11.3 Safari / macOS Safari 11.1 empty <input type="file"> XHR bug workaround.
// Replace empty File object with equivalent Blob in FormData, keeping its order, before sending it to server.
// Should work with IE10 and all other modern browsers.
// Because useragent value can be customized by WebView or etc., applying workaround code for all browsers.
document.addEventListener('ajax:beforeSend', function(e) {
var formData = e.detail[1].data
if (!(formData instanceof window.FormData)) return
if (!formData.keys) return // unsupported browser
ypresto / safari-11-file-xhr-workaround-2.js
Last active Sep 6, 2018
iOS 11.3 Safari / macOS Safari 11.1 empty <input type="file"> XHR bug workaround for rails-ujs / jquery_ujs
View safari-11-file-xhr-workaround-2.js
// iOS 11.3 Safari / macOS Safari 11.1 empty <input type="file"> XHR bug workaround.
// This should work with every modern browser which supports ES5 (including IE9).
document.addEventListener('ajax:before', function(e) {
var inputs ='input[type="file"]:not([disabled])')
inputs.forEach(function(input) {
if (input.files.length > 0) return
input.setAttribute('data-safari-temp-disabled', 'true')

Keybase proof

I hereby claim:

  • I am ypresto on github.
  • I am ypresto ( on keybase.
  • I have a public key ASBiAns4kqBa5eKu8wuHbtMxxMxV675BuMcbDtVlY93JBwo

To claim this, I am signing this object:

ypresto / init.lua
Last active Mar 1, 2018
View init.lua
local pressedKeyTable = {}
-- TODO: Consider about consumed per keys is necessary or not.
local consumed = false
local keyCodeTable = {}
keyCodeTable[0x66] = true -- EISUU
keyCodeTable[0x68] = true -- KANA
eventtap ={ hs.eventtap.event.types.keyDown, hs.eventtap.event.types.keyUp }, function(event)
local keyCode = event:getKeyCode()
if keyCodeTable[keyCode] == true then
ypresto /
Last active May 2, 2019
Gson adapter for Android's Uri class.
ypresto / YPLayoutGuideHelper.m
Last active Mar 1, 2018
Apply automaticallyAdjustsScrollViewInsets in child view controller like Container View or UIPageViewController
View YPLayoutGuideHelper.m
// YPLayoutGuideHelper.m
// Created by Yuya Tanaka, 2015
// This is free and unencumbered software released into the public domain.
// Refer:
// automaticallyAdjustsScrollViewInsets doesn't work for child view controllers
// hosted by something like Container View or UIPageViewController.
ypresto /
Last active Apr 27, 2019
Limit cache size of glide based on total size of Internal Storage implemented on the device.
package com.example.glide;
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.os.Environment;
import android.os.StatFs;
import android.util.Log;
import com.bumptech.glide.Glide;
ypresto / brook-rxjs-bridge.js
Last active Aug 29, 2015
Translate brook promise and channel into RxJS.
View brook-rxjs-bridge.js
.use('brook promise')
.define(function(ns) {
'use strict';
var observableFromPromise = function(promise, value) {
return Rx.Observable.create(function(observer) {
var called = false;
var throwIfCalled = function() {
if (called) {
throw new Error('promise resolved twice.');
You can’t perform that action at this time.