Custom Search

Thursday, April 21, 2016

how to install python pycrypto

$pip install -d ~/mydir pycrypto

$cd mydir

$tar -xzf pycrypto-2.6.1.tar.gz

$sudo apt-get install python-dev

$sudo python install

python install raise RuntimeError("autoconf error") RuntimeError: autoconf error

$sudo apt-get install python-dev

$sudo python install

how to install python xmltodict

$pip install -d ~/mydir  xmltodict

$cd ~/mydir

$tar -xzf xmltodict-0.10.1.tar.gz

$sudo python install

Wednesday, April 20, 2016

How to github Check out pull requests locally

Fetch PR 77 and save it in branch named "new_batch_name"
$git fetch origin pull/77/head:new_batch_name

Got branch "new_batch_name"
$git checkout new_batch_name

Check for all commits in the PR 77
$git log -n 5

fatal: unable to access server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none

$ git config --global http.sslverify false

ubuntu add proxy to apt-get

$sudo vim /etc/apt/apt.conf
Acquire::Http::Proxy "";

$sudo apt-get update

How to use lsof to find information about files opened by a process

Open a file with vim editor and don't close it
$vim myfile1.txt

Find PID of vim process
$ps -aux | grep vim
saju      6570  0.1  0.0  76332  6260 pts/10   Sl+  02:43   0:00 vim myfile1.txt

check lsof the vim process and you can see the process opened one file
$sudo lsof -p 6570
vim     6570 saju    5u   REG    8,1    12288 17328734 /home/saju/testdownload/.myfile1.txt.swp

* Here 5u is the file descriptor (fd)

Open another file in same vim editor with ":split myfile2.txt" command

check lsof the process and you can see the process opened two files
$sudo lsof -p 6570
vim     6570 saju    5u   REG    8,1    12288 17328734 /home/saju/testdownload/.myfile1.txt.swp
vim     6570 saju    6u   REG    8,1    12288 17328754 /home/saju/testdownload/.myfile2.txt.swp

* Here 5u and 6u are the file descriptor (fd)

Ubuntu Linux Recover Deleted Files With lsof

Create a file
$vim myfile1.txt

Open that file with program "tail"
$tail -f myfile1.txt

Delete that file
$rm myfile1.txt

Find PID of process which opened "myfile1.txt"
$sudo lsof | grep myfile1.txt
#ps -aux | grep tail

Recover that file
$cp /proc/xxx/fd/4 myfile1.txt

* xxx is the PID of process which opened "myfile1.txt", this case it is "tail".

Sunday, April 3, 2016

openstack devstack/functions-common:1066 Failed to update apt repos, we're dead now


Get:55 trusty/restricted Sources [5433 B]        
Get:56 trusty/universe Sources [6399 kB]         
Get:57 trusty/multiverse Sources [174 kB]        
Get:58 trusty/main amd64 Packages [1350 kB]      
98% [58 Packages 1130 kB/1350 kB 84%]                              24.7 kB/s 8s++functions-common:apt_get_update:1066      die 1066 'Failed to update apt repos, we'\''re dead now'
++functions-common:die:186                  local exitcode=0
++functions-common:die:187                  set +o xtrace
[Call Trace]
[ERROR] /home/python/devstack/functions-common:1066 Failed to update apt repos, we're dead now
99% [58 Packages 1191 kB/1350 kB 88%]                              24.7 kB/s 6sError on exit
./ line 488: generate-subunit: command not found
Get:59 trusty/restricted amd64 Packages [13.0 kB]
Get:60 trusty/universe amd64 Packages [5859 kB]  
Get:61 trusty/multiverse amd64 Packages [132 kB] 
Get:62 trusty/main i386 Packages [1348 kB]       
Get:63 trusty/restricted i386 Packages [13.4 kB] 
Get:64 trusty/universe i386 Packages [5866 kB]   
Get:65 trusty/multiverse i386 Packages [134 kB]  
Get:66 trusty/main Translation-en [762 kB]       
Get:67 trusty/multiverse Translation-en [102 kB] 
Get:68 trusty/restricted Translation-en [3457 B] 
Get:69 trusty/universe Translation-en [4089 kB]  
Fetched 32.6 MB in 11min 53s (45.8 kB/s)                                      
Reading package lists... Done

Open file "functions-common" and search for "dead" and change "timeout 300" to "timeout 1000"

Friday, April 1, 2016

Python http status codes from httplib

>>> from pprint import pprint
>>> import httplib
>>> pprint(httplib.responses)
{100: 'Continue',
 101: 'Switching Protocols',
 200: 'OK',
 201: 'Created',
 202: 'Accepted',
 203: 'Non-Authoritative Information',
 204: 'No Content',
 205: 'Reset Content',
 206: 'Partial Content',
 300: 'Multiple Choices',
 301: 'Moved Permanently',
 302: 'Found',
 303: 'See Other',
 304: 'Not Modified',
 305: 'Use Proxy',
 306: '(Unused)',
 307: 'Temporary Redirect',
 400: 'Bad Request',
 401: 'Unauthorized',
 402: 'Payment Required',
 403: 'Forbidden',
 404: 'Not Found',
 405: 'Method Not Allowed',
 406: 'Not Acceptable',
 407: 'Proxy Authentication Required',
 408: 'Request Timeout',
 409: 'Conflict',
 410: 'Gone',
 411: 'Length Required',
 412: 'Precondition Failed',
 413: 'Request Entity Too Large',
 414: 'Request-URI Too Long',
 415: 'Unsupported Media Type',
 416: 'Requested Range Not Satisfiable',
 417: 'Expectation Failed',
 500: 'Internal Server Error',
 501: 'Not Implemented',
 502: 'Bad Gateway',
 503: 'Service Unavailable',
 504: 'Gateway Timeout',
 505: 'HTTP Version Not Supported'}

How to Vagrant Virtualbox restart a Virtual Machine

How to Vagrant Virtualbox restart a VM

$VBoxManage list vms

$VBoxManage controlvm reset