Skip to content

Instantly share code, notes, and snippets.

View hirokazumiyaji's full-sized avatar

Hirokazu Miyaji hirokazumiyaji

View GitHub Profile
@hirokazumiyaji
hirokazumiyaji / config.go
Last active August 29, 2015 14:06
go configuration
package go
import (
"io/ioutil"
"github.com/gonuts/yaml"
)
var Config = make(map[string]interface{})
func Load(yamlFile string) (err error) {
@hirokazumiyaji
hirokazumiyaji / parallelmigrate.py
Last active May 18, 2023 09:24
django parallel migrate(per host)
# coding: utf-8
from __future__ import absolute_import, unicode_literals
from collections import defaultdict
import commands
from multiprocessing import Process
from django.conf import settings
from django.core.management.base import BaseCommand
@hirokazumiyaji
hirokazumiyaji / index.html
Created September 23, 2014 14:06
angularjs sample
<!doctype html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.25/angular.min.js"></script>
<script type="text/javascript">
function tableController($http, $scope) {
$scope.records = [
{
id: 1,
name: 'John',
@hirokazumiyaji
hirokazumiyaji / serial.html
Created November 11, 2014 15:10
kockout.js sample
<!doctype html>
<html>
<head>
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/knockout/3.2.0/knockout-min.js"></script>
<script type="text/javascript">
$(function() {
function Campaign(data) {
var self = this;
@hirokazumiyaji
hirokazumiyaji / nginx.conf
Created November 24, 2014 11:40
nginx + uwsgi conf
user root;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
multi_accept on;
}
@hirokazumiyaji
hirokazumiyaji / emailfields.py
Last active August 29, 2015 14:10
django email forms field.
# coding: utf-8
import re
from django.forms.fields import CharField
from django.forms.widgets import EmailInput
from django.utils.deconstruct import deconstructible
class EmailValidator(object):
@hirokazumiyaji
hirokazumiyaji / progress.py
Last active August 29, 2015 14:10
Progress
# coding: utf-8
from __future__ import absolute_import, unicode_literals, print_function
import sys
class Progress(object):
def __init__(self, max_count):
self._count = 0
@hirokazumiyaji
hirokazumiyaji / req.go
Created December 7, 2014 14:46
json request
package main
import (
"bytes"
"encoding/json"
"flag"
"fmt"
"io/ioutil"
"net/http"
"os"
@hirokazumiyaji
hirokazumiyaji / Dockerfile
Last active August 29, 2015 14:11
nginx in Ubuntu 14.10
FROM ubuntu:14.10
MAINTAINER Hirokazu Miyaji <[email protected]>
RUN locale-gen ja_JP.UTF-8 UTF-8
RUN apt-get -y update &&\
apt-get -y install clang-3.5 llvm-3.5 &&\
ln -snf /usr/bin/gcc /usr/bin/clang-3.5 &&\
ln -snf /usr/bin/g++ /usr/bin/clang++-3.5 &&\
apt-get -y install linux-headers-$(uname -r) build-essential git zlib1g-dev libssl-dev libpcre3-dev wget &&\
git clone -b master https://github.com/jemalloc/jemalloc.git /usr/local/src/jemalloc &&\
@hirokazumiyaji
hirokazumiyaji / colorprint.go
Created December 31, 2014 10:47
Color Print
package colorprint
import fmt
func Red(format string, a ...interface{}) {
fmt.Println("\x1b[31;1m%s\x1b[0m\n", fmt.Sprintf(format, a...))
}
func Green(format string, a ...interface{}) {
fmt.Println("\x1b[32;1m%s\x1b[0m\n", fmt.Sprintf(format, a...))