Skip to content

Instantly share code, notes, and snippets.

@kain-jy
kain-jy / main.py
Created December 15, 2018 07:38
Get Vault Auth Token from Google Account
import request
from flask import Flask, request, redirect
BASE_URL = os.environ.get('BASE_URL') or 'http://localhost:5000'
VAULT_ADDR = os.environ['VAULT_ADDR']
VAULT_ROLE = os.environ['VAULT_ROLE']
GOOGLE_CLIENT_ID = os.environ['GOOGLE_CLIENT_ID']
GOOGLE_CLIENT_SECRET = os.environ['GOOGLE_CLIENT_SECRET']
app = Flask(__name__)
@kain-jy
kain-jy / config.ru
Created June 24, 2013 03:07
resque-web in /queue directory with unicorn
#!/usr/bin/env ruby
require 'logger'
require 'resque/server'
use Rack::ShowExceptions
Resque.redis = Redis.new(:host => "HOST", :port => 6379, :password => "PASS")
run Rack::URLMap.new \
@kain-jy
kain-jy / gist:5432459
Created April 22, 2013 04:34
php 5.4.x build-in server
<?php
if (file_exists($_SERVER['DOCUMENT_ROOT'].$_SERVER['REQUEST_URI'])) return false;
else include($_SERVER['DOCUMENT_ROOT'].'/index.php');
@kain-jy
kain-jy / code.py
Created April 6, 2013 11:18
[python] list結合の検証
# coding: utf-8
import profile
#from memory_profiler import profile as mprofile
from random import random
from itertools import chain
data = [[random() for j in xrange(1000)] for i in xrange(1000)]
def add(x,y):
@kain-jy
kain-jy / gist:4238790
Created December 8, 2012 05:33
[nginx][config] fuelphp+php-fpm
server {
listen 80;
server_name host.example.com;
charset utf-8;
access_log /var/log/nginx/host.example.access.log main;
error_log /var/log/nginx/host.example.error.log;
index index.php;
@kain-jy
kain-jy / gist:4138867
Created November 24, 2012 08:23
[rails] unicorn configure
# save config/unicorn.rb
worker_processes 2
working_directory "/home/{project_name}/app"
listen '/home/{project_name}/tmp/unicorn.sock'
stderr_path File.expand_path('log/unicorn.log', ENV['RAILS_ROOT'])
stdout_path File.expand_path('log/unicorn.log', ENV['RAILS_ROOT'])
preload_app true
@kain-jy
kain-jy / gist:4138864
Created November 24, 2012 08:21
[rails] init script
#!/bin/sh
BASE=$HOME/app
UNICORN_PID=$BASE/tmp/pids/unicorn.pid
case "$1" in
reload)
echo "reload..."
if [ ! -r $UNICORN_PID ] ; then
echo "no pid file found. maybe is no running."
@kain-jy
kain-jy / gist:4138784
Created November 24, 2012 07:28
[phpenv][php-build] php-fpm's init file
#! /bin/sh
#
# run as current user
# > mkdir ~/.phpenv/init
# > vim 5.3.19
#
# before, you should edit php-fpm.conf
# and comment out [www] user and group.
PHP_BASE=$HOME/.phpenv/versions/{version}
@kain-jy
kain-jy / websocket_tornado_redis.py
Created May 28, 2012 00:43 — forked from pelletier/websocket_tornado_redis.py
adapt for newer redis and redis-py
"""
This is a simple example of WebSocket + Tornado + Redis Pub/Sub usage.
Do not forget to replace YOURSERVER by the correct value.
Keep in mind that you need the *very latest* version of your web browser.
You also need to add Jacob Kristhammar's websocket implementation to Tornado:
Grab it here:
http://gist.github.com/526746
Or clone my fork of Tornado with websocket included:
http://github.com/pelletier/tornado
Oh and the Pub/Sub protocol is only available in Redis 2.0.0:
@kain-jy
kain-jy / gist:1414455
Created December 1, 2011 06:54
add2home iOS sample
<!DOCTYPE html>
<html>
<head>
<meta lang="ja" />
<meta charset="utf-8" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="viewport" content="width=device-width; height=device-height; initial-scale=1.0; maximum-scale=1.0; user-scalable=no">
<!--touch icon-->
<link rel="apple-touch-icon-precomposed" size="114x114" href="img/apple-touch-icon-114x114.png" />
<link rel="apple-touch-icon-precomposed" size="72x72" href="img/apple-touch-icon-72x72.png" />