Skip to content

Instantly share code, notes, and snippets.

View yuuichi-fujioka's full-sized avatar

yuuichi fujioka yuuichi-fujioka

View GitHub Profile
@yuuichi-fujioka
yuuichi-fujioka / config
Created January 31, 2014 01:14
Disable host key verification on ssh
Host 192.168.56.*
StrictHostKeyChecking no
UserKnownHostsFile=/dev/null
@yuuichi-fujioka
yuuichi-fujioka / backdoor_example.py
Created February 5, 2014 00:41
Eventlet Backdoor
import time
import eventlet
from eventlet import backdoor
def main():
eventlet.monkey_patch()
eventlet.spawn(backdoor.backdoor_server, eventlet.listen(('localhost', 3000)))
@yuuichi-fujioka
yuuichi-fujioka / print_example.py
Created February 5, 2014 01:10
print function in < 3.0
from __future__ import print_function
print('foo', 'bar')
# output is "foo bar"
@yuuichi-fujioka
yuuichi-fujioka / memcache_reader.py
Created February 10, 2014 07:18
Example for using memcached
import memcache
c = memcache.Client(['127.0.0.1:11211'])
print c.get('name')
# "Taro" will be printed
@yuuichi-fujioka
yuuichi-fujioka / pecan_rest_api.py
Created February 10, 2014 07:18
REST API with pecan
import eventlet
from eventlet import wsgi
import pecan
from pecan import rest
class V1Controller(rest.RestController):
@pecan.expose()
def get(self, id):
@yuuichi-fujioka
yuuichi-fujioka / extend_volume.sh
Last active January 17, 2017 23:46
Extend root volume on LVM
#!/bin/bash
sudo pvcreate /dev/sdb1
sudo vgextend ubuntu-vg /dev/sdb1
sudo lvextend /dev/ubuntu-vg/root -l +100%FREE
# sudo lvextend /dev/ubuntu-vg/root -L+50G
sudo resize2fs /dev/ubuntu-vg/root # only for ext2,3,4
#sudo resize2fs /dev/ubuntu-vg/root 50G
@yuuichi-fujioka
yuuichi-fujioka / ceilometer v2 query example.sh
Created February 19, 2014 02:17
Example of ceilometer v2 api query (not complex)
curl -X GET -H 'X-Auth-Token: <Token>' -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'User-Agent: python-ceilometerclient' 'http://ceilometer-host:8777/v2/samples?q.field=meter&q.op=eq&q.value=switch.flow&q.field=metadata.flow.id&q.type=int&q.op=eq&q.value=0'
@yuuichi-fujioka
yuuichi-fujioka / conf.py
Created February 20, 2014 07:09
Example of load python based config file
v = {
'foo': 'bar'
}
@yuuichi-fujioka
yuuichi-fujioka / prop.py
Created February 25, 2014 06:42
property example
class Foo():
def __init__(self):
self.meta = {}
@property
def name(self):
return self.meta.get('name', None)
@name.setter
@yuuichi-fujioka
yuuichi-fujioka / with_example.py
Created February 25, 2014 06:49
with example
class Foo():
def __enter__(self):
print 'begin transaction'
return self
def __exit__(self, type, value, traceback):
if value:
print 'An error has occured in this transaction'
else: