Skip to content

Instantly share code, notes, and snippets.

View polidog's full-sized avatar
🌎

Ryota Mochizuki polidog

🌎
View GitHub Profile
@polidog
polidog / config.toml
Created August 8, 2016 17:08
GORMのMySQL接続のサンプル
[Database]
driver = "mysql"
server = ""
user = "hoge"
password = "fuga"
database = "testgo"
charset = "utf8"
parseTime = "true"
@polidog
polidog / gulpfile.js
Last active February 19, 2018 12:49
Gulp+PHP CS Fixer
var gulp = require('gulp');
var exec = require('child_process').exec;
gulp.task('watch',function(){
gulp.watch("./src/**/*.php").on('change',function(event){
var command = "php-cs-fixer fix " + event.path + " --config-file=" + __dirname + "/.php_cs"
exec(command);
console.log("execute command: "+command);
})
});
<?php
namespace AppBundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use AppBundle\DependencyInjection\Compiler\YahooOAuthCompilerPass;
class AppBundle extends Bundle
{
@polidog
polidog / YahooJpResourceOwner.php
Last active June 14, 2016 10:02
YahooID連携用のResourceOwner
<?php
namespace AppBundle\OAuth\ResourceOwner
use HWI\Bundle\OAuthBundle\OAuth\ResourceOwner\GenericOAuth2ResourceOwner;
use HWI\Bundle\OAuthBundle\Security\Core\Authentication\Token\OAuthToken;
use Symfony\Component\HttpFoundation\Request;
use Buzz\Message\RequestInterface as HttpRequestInterface;
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
class YahooJpResourceOwner extends GenericOAuth2ResourceOwner
@polidog
polidog / invoke_test.php
Created June 2, 2016 09:02
__invoke()が必要場合ってどんなときだろうって考えてみた
<?php
/*
* __invoke()を使う意味がわからなかったけど、よく考えたらcallableな引数渡すときに無名関数じゃなくて、オブジェクト
* そのものを渡したい時に使えそうだと思った。
*/
class Hoge {
public function __invoke(string $output)
{
$this->exec($output);
@polidog
polidog / VichUriExtension.php
Created May 26, 2016 00:27
vich uploader bundleのassetの改良版
<?php
/**
* Created by PhpStorm.
* User: polidog
* Date: 2016/05/26
*/
namespace AppBundle\Twig\Excetsion;
@polidog
polidog / anniversary.coffee
Created April 22, 2016 02:17
nightmare+hubot
Nightmare = require 'nightmare'
request = require 'request'
fs = require 'fs'
Gyazo = require 'gyazo-api'
nightmare = Nightmare()
url = process.env.HATENA_COUNT_URL
filename = "./ss.png"
client = new Gyazo(process.env.GYAZO_TOKEN)
<?php
function recursive_array_search($needle, array $haystack) {
foreach ($haystack as $key => $value) {
if ($value === $needle) {
return $key;
}
if (is_array($value)) {
$chideKey = recursive_array_search($needle, $value);
return [$key, $chideKey];
}
@polidog
polidog / composer.json
Created December 11, 2014 17:16
composerのインストール後にパーミッションを変える方法 ref: http://qiita.com/polidog/items/0c747eb42474d254738d
{
"name": "polidog/composer-test",
"authors": [
{
"name": "polidog",
"email": "polidogs@gmail.com"
}
],
"repositories": [
@polidog
polidog / gorilla3.py
Last active October 26, 2015 09:52
うっかりAmazon 3SにNFD(utf-8-mac)なファイル名をアップロードしたときに修正する方法
# coding: utf-8
import re
import unicodedata
from sh import aws
BUCKET = "aws-bucket-name" # 対象のs3 bucket名
s3 = aws.bake("s3")
def _s3rename(path, name, rename):