2015年3月23日月曜日

sh: search ipadresses

$ for((i=1;i<255;i++))
> do
> ping -c 1 -W 1 ☆.☆.☆.$i | grep '64 bytes'
> done

Python: tips

>>> 'abcdefg'[0]
'a'
>>> 'abcdefg'[-1]
'g'
>>> 'abcdefg'[0:3]
'abc'
>>> 'abcdefg'[3:-1]
'def'
>>> 'abcdefg'[3:]
'defg'
>>> 'abcdefg'[:3]
'abc'
>>> 'abcdefg'[1::2]
'bdf'
>>> 'abcdefg'[::-1]
'gfedcba'


>>> '83 69 67 79 78'.split()
['83', '69', '67', '79', '78']
>>> '53:45:43:43:4f:4e'.split(':')
['53', '45', '43', '43', '4f', '4e']


>>> ' '.join(['83', '69', '67', '79', '78'])
'83 69 67 79 78'
>>> ':'.join(['53', '45', '43', '43', '4f', '4e'])
'53:45:43:43:4f:4e'


>>> import hashlib
>>> hashlib.md5('abc').hexdigest()
'900150983cd24fb0d6963f7d28e17f72'
>>> hashlib.sha1('abc').hexdigest()
'a9993e364706816aba3e25717850c26c9cd0d89d'
>>> hashlib.sha256('abc').hexdigest()
'ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad'
>>> hashlib.sha512('abc').hexdigest()
'ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f'




2015年3月8日日曜日

MongoDB: Python: find by descending

import pymongo

 conn = pymongo.Connection()
 db = conn["apache"]
 coll = db["access"]

for data in coll.find().sort([('time',pymongo.DESCENDING)]):



2015年3月7日土曜日

fluentd: Install for getting httpd access log

(1) MongoDB Install

(2) fluentd install

 30 $ sudo vim /etc/☆/td-agent.conf
 32   <source>
 33     type tail
 34     format apache
 35     path /☆/httpd/access_log
 36     pos_file /☆/apache2.access_log.pos
 37     tag mongo.apache.access
 38   </source>
 39
 40   <match mongo.*.*>
 41   # plugin type
 42   type mongo
 43   # mongodb db + collection
 44   database apache
 45   collection access
 46   # mongodb host + port
 47   host localhost
 48   port ☆
 49   # interval
 50   flush_interval 10s
 51   # make sure to include the time key
 52   include_time_key true
 53   </match>


2015年3月4日水曜日

Mobile-Tools

https://hhoshina.info/p/Mobile-Tools.html

Ruby: 2.2.1 Released !

  $ cd /****/rbenv/plugins/ruby-build                                        
  $ git pull origin master
 
  $ rbenv install --list
  ...
  2.2.1
  ...
  $ sudo  CONFIGURE_OPTS="--disable-install-rdoc --enable-shared" rbenv instal    l 2.2.1
  $ rbenv versions
 $ sudo rbenv global 2.2.1
 $ ruby -v
 ruby 2.2.1p85 (2015-02-26 revision 49769)

 $ sudo gem install bundler

 $ sudo gem install passenger

 $ sudo passenger-install-apache2-module

 $ cd /☆☆/rails_application

$ bundle update

fd-find

 $ sudo apt install fd-find $ fdfind 石