Skip to content

Instantly share code, notes, and snippets.

View hiroakis's full-sized avatar

Hiroaki Sano hiroakis

View GitHub Profile
@hiroakis
hiroakis / installation_perlbrew
Created December 28, 2012 06:12
My perl environment for CentOS
mkdir /perl
export PERLBREW_ROOT=/perl
curl -L --insecure http://xrl.us/perlbrewinstall | bash
echo 'export PERLBREW_ROOT=/perl' >> ~/.zshrc
echo '[ -f /perl/etc/bashrc ] && source /perl/etc/bashrc' >> ~/.zshrc
source ~/.zshrc
perlbrew available
perlbrew install perl-5.16.2
perlbrew switch perl-5.16.2
perlbrew install-cpanm
@hiroakis
hiroakis / example_rabbitmq_api.py
Last active August 21, 2023 13:33
Calling the RabbitMQ api from Python sample
#!/usr/local/bin/python
import requests
import json
def call_rabbitmq_api(host, port, user, passwd):
url = 'http://%s:%s/api/queues' % (host, port)
r = requests.get(url, auth=(user,passwd))
return r
@hiroakis
hiroakis / installation_pyenv
Last active December 15, 2015 04:49
My Python developing environment.
# Install pyenv in ~/.pyenv
cd ~
git clone git://github.com/yyuu/pyenv.git .pyenv
echo 'export PYENV_ROOT="${HOME}/.pyenv"' >> ~/.zshrc
echo 'if [ -d "${PYENV_ROOT}" ]; then' >> ~/.zshrc
echo ' export PATH=${PYENV_ROOT}/bin:$PATH' >> ~/.zshrc
echo ' eval "$(pyenv init -)"' >> ~/.zshrc
echo 'fi' >> ~/.zshrc
@hiroakis
hiroakis / 01_riak.spec
Last active December 15, 2015 14:09
Custom Riak RPMs spec file.
%define _version 1.3.0
%define _revision 1.3.0
%define _release 1
Name: riak
Version: %{_version}
Release: %{_release}%{?dist}
License: Apache License
Group: Development/Libraries
Source: %{name}-%{_revision}.tar.gz
@hiroakis
hiroakis / functools_partial_example.py
Created July 13, 2013 18:21
functools.partial example
import functools
def calc(x, y, mode):
if mode == '+':
return x + y
elif mode == '-':
return x - y
elif mode == '*':
return x * y
elif mode == '/':
@hiroakis
hiroakis / functools_wraps_example.py
Created July 13, 2013 18:24
Create my own decorator using functools.wraps.
import functools
def ore(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
print "@ore : oreoreoreoreore"
return func(*args, **kwargs)
return wrapper
def plus(x, y):
@hiroakis
hiroakis / spec_helper.rb.patch
Last active October 14, 2016 05:46
A patch for spec_helper.rb in serverspec. This patch enables "rake spec" command to require server login password.
--- spec_helper.rb.org 2013-11-04 19:21:50.000000000 +0900
+++ spec_helper.rb 2013-11-04 23:01:26.000000000 +0900
@@ -6,12 +6,9 @@
include Serverspec::Helper::DetectOS
RSpec.configure do |c|
- if ENV['ASK_SUDO_PASSWORD']
- require 'highline/import'
- c.sudo_password = ask("Enter sudo password: ") { |q| q.echo = false }
- else
@hiroakis
hiroakis / bigip_operation.py
Last active December 30, 2015 08:39
This is an example that operate BIG IP via Python using pycontrol.
#!/usr/bin/env python
#-*- coding: utf-8 -*-
import pycontrol.pycontrol as pc
import os
host = 'xxx.xxx.xxx.xxx'
user = 'xxxxxx'
password = 'xxxxxx'
@hiroakis
hiroakis / Rakefile_serverspec
Last active June 5, 2016 21:27
serverspec for my environment
require 'rake'
require 'rspec/core/rake_task'
require 'yaml'
require 'highline/import'
properties = YAML.load_file('properties.yaml')
ENV['SSH_USER'] = ask("Enter ssh user: ") { |q| q.echo = true }
ENV['SSH_PASSWORD'] = ask("Enter ssh password: ") { |q| q.echo = false }
package main
import (
"log"
"net/http"
//"io/ioutil"
)
func get(url string, c chan bool){
resp, err := http.Get(url)