Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Yuya Tanaka ypresto

🏠
Working from home
View GitHub Profile
@ypresto
ypresto / .zshrc
Created May 31, 2020
Fix "SSL certificate problem: certificate has expired" issue in homebrew
View .zshrc
# Add this snippet to your .zshrc, .bashrc or etc.
# https://security.stackexchange.com/a/232446/235706
export CURL_SSL_BACKEND=secure-transport
# https://github.com/Homebrew/brew/issues/6274#issuecomment-507937736
export HOMEBREW_NO_ENV_FILTERING=1
@ypresto
ypresto / docker-compose-mutagen.yml
Last active Feb 2, 2020
Use mutagen with docker-sync like setup.
View docker-compose-mutagen.yml
version: "3.7"
services:
service1:
volumes:
- your-app-mutagen-service1:/var/app:nocopy
service2:
volumes:
- your-app-mutagen-service2:/var/app:nocopy
@ypresto
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
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
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.
// https://stackoverflow.com/questions/49614091/safari-11-1-ajax-xhr-form-submission-fails-when-inputtype-file-is-empty
// https://github.com/rails/rails/issues/32440
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
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).
// https://stackoverflow.com/questions/49614091/safari-11-1-ajax-xhr-form-submission-fails-when-inputtype-file-is-empty
// https://github.com/rails/rails/issues/32440
document.addEventListener('ajax:before', function(e) {
var inputs = e.target.querySelectorAll('input[type="file"]:not([disabled])')
inputs.forEach(function(input) {
if (input.files.length > 0) return
input.setAttribute('data-safari-temp-disabled', 'true')
View keybase.md

Keybase proof

I hereby claim:

  • I am ypresto on github.
  • I am ypresto (https://keybase.io/ypresto) on keybase.
  • I have a public key ASBiAns4kqBa5eKu8wuHbtMxxMxV675BuMcbDtVlY93JBwo

To claim this, I am signing this object:

@ypresto
ypresto / init.lua
Last active Mar 1, 2018
英数キーとかかなキーとかを同時押しの時だけAltキーにするHammerspoonの設定
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.new({ hs.eventtap.event.types.keyDown, hs.eventtap.event.types.keyUp }, function(event)
local keyCode = event:getKeyCode()
if keyCodeTable[keyCode] == true then
@ypresto
ypresto / UriTypeHierarchyAdapter.java
Last active Jan 14, 2020
Gson adapter for Android's Uri class.
View UriTypeHierarchyAdapter.java
import android.net.Uri;
import com.google.gson.JsonDeserializationContext;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonElement;
import com.google.gson.JsonParseException;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
@ypresto
ypresto / YPLayoutGuideHelper.m
Last active Apr 20, 2020
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: http://unlicense.org/
//
// automaticallyAdjustsScrollViewInsets doesn't work for child view controllers
// hosted by something like Container View or UIPageViewController.
You can’t perform that action at this time.