This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Creating the $LFS directory | |
| ... | |
| # Create lfs user and the profile for it | |
| ... | |
| sudo su - lfs | |
| # Downloading packet source: | |
| mkdir -vp $LFS/sources |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| for db in $(psql -t -X -h 192.168.132.111 -U postgres -d probedb -c 'SELECT erfstore_id FROM erfstores') ; do psql -X -h 192.168.132.111 -U postgres -d $db -f /build/trunk/dock/tree/customer/endace/src/bin/dbmgr/scripts/erfstoredb/da_breakdown_summary_sql.sql ; done | |
| # Or slightly more readable: | |
| export PGHOST=fin7000-4 | |
| export PGDATABASE=probedb | |
| export PGUSER=postgres | |
| cd /ginkgo/trunk/ginkgo/tree/customer/endace/src/bin/dbmgr/scripts/erfstoredb/ | |
| for db in $(psql -t -X -c 'SELECT erfstore_id FROM erfstores') erfstoredb ; do psql -X -d $db -f da_breakdown_summary_sql.sql ; done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import argparse | |
| import inspect | |
| class Argumentor: | |
| def __init__(self, description=None): | |
| self._parser = argparse.ArgumentParser(description=description) | |
| self._subparsers = self._parser.add_subparsers() | |
| def add(self, description={}): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- // How many events were created from date A to date B (possibly presenting data on a daily, weekly and monthly basis) | |
| -- Replace 'week' with 'day' or 'month' | |
| -- date_trunc takes: minute hour day week month quarter year | |
| -- NB! TIMESTAMP '2013-09-16' == '2013-09-16 00:00:00' so BETWEEN includes only tickets sold until that date. | |
| SELECT date_trunc('week', created_at) AS dt, count(*) AS total_events | |
| FROM events | |
| WHERE created_at BETWEEN TIMESTAMP '2013-06-16' AND TIMESTAMP '2013-09-16' | |
| GROUP BY date_trunc('week', created_at) | |
| -- // How many paid tickets were sold form date A to date B (presenting graphs on a day to day basis, weekly and monthly) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| head -1 /dev/urandom | base64 -w0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| # Original from: | |
| # http://pyvideo.org/video/1780/transforming-code-into-beautiful-idiomatic-python | |
| colors = ['red', 'green', 'blue', 'yellow'] | |
| names = ['apple', 'carrot', 'melon'] | |
| for color in reversed(colors): | |
| print color |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #%% DATA IMPORTING AND VISUALIZATION | |
| from urllib2 import urlopen | |
| from contextlib import closing | |
| from os.path import basename | |
| def download_file(url, name=None): | |
| with closing(urlopen(url)) as u, open(name if name else basename(url), 'w') as f: | |
| f.write(u.read()) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- PostgreSQL | |
| DROP TABLE IF EXISTS uview5_uni; | |
| CREATE TABLE uview5_uni AS | |
| SELECT | |
| start_time, | |
| CASE e WHEN 1 THEN mac_addr_1 ELSE mac_addr_2 END src_mac_addr, | |
| CASE e WHEN 1 THEN mac_addr_2 ELSE mac_addr_1 END des_mac_addr, | |
| CASE e WHEN 1 THEN byte_count_1 ELSE byte_count_2 END byte_count, | |
| CASE e WHEN 1 THEN packet_count_1 ELSE packet_count_2 END packet_count, | |
| last_time, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| egrep "(\*\*\*\*|excluding)" test.log | sed '/tps/ s/tps = \([.0-9]*\) .*/\1/; /uview/ s/ uview\([0-9]*\)/\1/' | sed -n '/\**/ {N;s/\n/,/;N;s/\n/,/;s/\**//p}' | |
| ## With loading into PostgreSQL: | |
| # Create table: | |
| psql -d 5 -c "create table test_output( id int, tps1 numeric, tps2 numeric)" | |
| # Extract and load data: | |
| egrep "(\*\*\*\*|excluding)" test.log | sed '/tps/ s/tps = \([.0-9]*\) .*/\1/; /uview/ s/ uview\([0-9]*\)/\1/' | sed -n '/\**/ {N;s/\n/,/;N;s/\n/,/;s/\**//p}' | psql -d 5 -c "TRUNCATE TABLE test_output; COPY test_output FROM STDIN (FORMAT csv, DELIMITER ',', HEADER false)" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Use Gists to store code you would like to remember later on | |
| console.log(window); // log the "window" object to the console |