Given a query such as
SELECT order_id,product_name,qty FROM orders
which returns three columns of data, the results can be placed into the file /tmo/orders.txt using the query:
SELECT order_id,product_name,qty FROM orders
| # Associative Arrays | |
| declare -A characters | |
| AA="abcdabcaba" | |
| for ((x=0; x<${#AA}; x++)) | |
| do | |
| tmp=${AA:$x:1} | |
| ((characters[$tmp]++)) | |
| done |
| function httpdate2unixtimestamp(date, array, time_string, timestamp) { | |
| # input: [02/Dec/2011:04:02:42 -0500] | |
| # output: 1322816562 | |
| # date is argument | |
| # array, time_string, timestamp is local variable | |
| split(date, array, "[]/: []") | |
| if (array[3]=="Jan") month="01" | |
| else if (array[3]=="Feb") month="02" | |
| else if (array[3]=="Mar") month="03" | |
| else if (array[3]=="Apr") month="04" |
| # Recipe 6.18. Automatically Initializing Instance Variables from _ _init_ _ Arguments | |
| # Solution | |
| # You can "factor out" the attribute-assignment task to an auxiliary function: | |
| def set_attributes_from_dict(d): | |
| self = d.pop('self') | |
| for n, v in d.iteritems(): | |
| setattr(self, n, v) | |
| # Now, the typical boilerplate code for an _ _init_ _ method such as: |
| graphite_index = json.loads(open('index.json').read()) | |
| result = json.dumps(instances, sort_keys=True, indent=4, encoding='utf-8') |
| #!/bin/bash | |
| app_path="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" | |
| app_name="$(basename "${BASH_SOURCE[0]}")" | |
| pid_file="${app_path}/run.pid" | |
| VERSION="${app_name} ver. 0.9.0" | |
| function help () { | |
| cat <<EOF | |
| usage: ${app_name} [-h] [-v] |
| utime(){ date -d @$1; } | |
| utime(){ date -d "1970-01-01 GMT $1 seconds"; } | |
| utime(){ awk -v d=$1 'BEGIN{print strftime("%a %b %d %H:%M:%S %Y", d)}'; } | |
| utime(){ perl -e "print localtime($1).\"\n\""; } | |
| utime(){ python -c "import time; print(time.strftime('%a %b %d %H:%M:%S %Y', time.localtime($1)))"; } | |
| [root@test test]# utime(){ date -d @$1; } | |
| [root@test test]# utime 1273817956 | |
| Fri May 14 14:19:16 CST 2010 | |
| { | |
| "title": "Templated Graphs", | |
| "services": { | |
| "filter": { | |
| "list": [ | |
| { | |
| "type": "filter", | |
| "name": "host", | |
| "query": "sensu.*", | |
| "includeAll": true, |
| { | |
| "id": 3, | |
| "title": "cAdvisor Templated", | |
| "originalTitle": "cAdvisor Templated", | |
| "tags": [], | |
| "style": "dark", | |
| "timezone": "browser", | |
| "editable": true, | |
| "hideControls": false, | |
| "sharedCrosshair": false, |