Skip to content

Instantly share code, notes, and snippets.

@emahiro
emahiro / application.py
Created October 7, 2019 16:12
Google Cloud SDK v265.0.0 におけるGo1.9 廃止に伴い aetest が起動しなくなってしまったバグへの一時的な patch. Google の提供している devappserver の中の一部を書き換えます。
#!/usr/bin/env python
#
# Copyright 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@emahiro
emahiro / upload_sample.go
Created October 2, 2017 09:58
ginでmultipart/form-dataからuploadするファイルをbyte型で取り出す
f, h, err := c.Request.FormFile("test")
b, err := ioutil.ReadAll(f)
@emahiro
emahiro / oh_my_fish_setting
Created April 21, 2017 02:05
fishで使用しているomf.fishの設定ファイル
# Path to Oh My Fish install.
set -q XDG_DATA_HOME
and set -gx OMF_PATH "$XDG_DATA_HOME/omf"
or set -gx OMF_PATH "$HOME/.local/share/omf"
# Set Path
set -x PATH /bin $PATH
set -x PATH /usr/local/bin $PATH
set -x PATH /usr/local/opt/openssl/bin $PATH
@emahiro
emahiro / iso8601.swift
Created April 3, 2017 06:21
ISO8601の形式をswiftのDate型で扱う
private static let ISO8601Formatter: DateFormatter = {
let dateFormatter = DateFormatter()
dateFormatter.locale = Locale(identifier: "en_US_POSIX")
dateFormatter.timeZone = TimeZone(secondsFromGMT: 0)
dateFormatter.dateFormat = "yyyy-MM-dd'T'HH:mm:ssZZZZ"
return dateFormatter
}()
@emahiro
emahiro / sample.js
Created August 18, 2016 08:23
jsで画面の中央の座標を取る(画面の中央にポップアップを表示させる)
// ポップアップの要素
var popup = element;
// 画面の縦横
var w_height = $(window).height();
var w_width = $(window).width();
// 要素の縦横
var el_height = popup.height();
var el_width = popup.width();
@emahiro
emahiro / default.conf
Created August 10, 2016 05:43
php + nginx + php-fpm で動作させるためのnginx設定
server {
listen 80;
server_name localhost;
access_log /var/log/nginx/nene.access.log;
root /var/www/webroot;
index index.php;
location / {
try_files $uri $uri/ /index.php?$args;
@emahiro
emahiro / query_log_tracker.php
Last active August 15, 2016 10:13
LaravelでのSQLの実行計画へのログへの出力方法
<?php
\DB::listen(function ($sql, $bindings, $time) {
if (\Config::get('app.debug') === true && preg_match("/^select/", $sql)) {
$explain = \DB::select("explain {$sql}", $bindings);
\Log::info($explain);
$bindings = implode(', ', $bindings);
$method = request()->method();
$url = request()->url();
# atom-setting
/**
* forの中のiはevent内部の関数からみたらグローバル変数になるので、forで最後まで回した値がchangeの中に入ってしまう。
*/
// 即時関数を使う
for (var i = 0; i < targetElArray.length; i++) {
(function(_i){
$('#' + targetElArray[_i]).change(function(event) {
console.log(targetElArray[_i]);
@emahiro
emahiro / checkRequestValueValidation.php
Created October 23, 2015 10:07
laravelにて単一の値の正当性を検証する独自バリデーションルール
<?php
namespace App\Validator;
use Validator;
use Log;
class CheckRequestValueValidator
{
/**
* リクエストされた値のバリデーションを行う