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
def marshall: | |
def m: | |
def to_string: {S:.}; | |
def to_number: {N:.|tostring}; | |
def to_boolean: {BOOL:.}; | |
def to_array: {L:.|to_entries|map(.value|m)}; | |
def to_object: {M:.|map_values(m)}; | |
def to_null: {NULL:true}; | |
if .|type=="string" then .|to_string | |
elif .|type=="number" then .|to_number |
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 { | |
AthenaClient, | |
GetQueryExecutionCommand, | |
QueryExecutionState, | |
StartQueryExecutionCommand | |
} from "@aws-sdk/client-athena"; | |
const client = new AthenaClient({}); | |
const runAthenaQuery = async (queryString: string, workGroup: string): Promise<any> => { |
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
{ "dataCount":422 ,"xtype":"" , "Xcount" : {"event":58,"gov":56,"incubator":118,"edu":5,"funding":5,"corporate":2,"cowork":99,"publicS":7,"train":42,"society":28,"others":2},"total_events":58,"total_members":229,"data" : [{"y":"22.99995210","x":"120.21504670","L":"http:\/\/sme.moeasmea.gov.tw\/startup\/modules\/resource\/detail\/?sId=12","T":"C-Hub \u6210\u5927\u5275\u610f\u57fa\u5730","A":"\u81fa\u5357\u5e02\u6771\u5340\u5927\u5b78\u8def1\u865f","I":"edu"},{"y":"24.14467450","x":"120.66267870","L":"http:\/\/sme.moeasmea.gov.tw\/startup\/modules\/resource\/detail\/?sId=15","T":"CVS \u5171\u540c\u5de5\u4f5c\u7a7a\u9593","A":"\u81fa\u4e2d\u5e02\u897f\u5340\u6c11\u751f\u8def368\u5df72\u5f043\u865f","I":"cowork"},{"y":"22.61151800","x":"120.30031500","L":"http:\/\/sme.moeasmea.gov.tw\/startup\/modules\/resource\/detail\/?sId=18","T":"DesignV\u8de8\u57df\u5171\u540c\u5275\u610f\u7a7a\u9593","A":"\u9ad8\u96c4\u5e02\u82d3\u96c5\u5340\u81ea\u5f37\u4e09\u8def3\u865f35\u6a13-7( I )\u5ba4","I":"cowork"},{"y":"25.022136 |
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
<source> | |
type tail | |
path /var/log/cflogs/s3/access.log | |
pos_file /var/log/cflogs/s3/access.log.pos | |
format /^(?<owner>[^ ]*) (?<bucket>[^ ]*) \[(?<time>.*)\] (?<remote_ip>[^ ]*) (?<requester>[^ ]*) (?<request_id>[^ ]*) (?<operation>[^ ]*) (?<key>[^ ]*) \"(?<request_uri>.*)\" (?<http_status>[^ ]*) (?<error_code>[^ ]*) (?<bytes_sent>[^ ]*) (?<object_size>[^ ]*) (?<time_total>[^ ]*) (?<turn_around_time>[^ ]*) \"(?<referrer>.*)\" \"(?<user_agent>.*)\" (?<version_id>[^ ]*)/ | |
time_format %d/%b/%Y:%H:%M:%S %z | |
tag s3.es.uri_escape | |
</source> |
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
from scrapy.contrib.spiders import CrawlSpider | |
from scraper.items import ProductItem | |
from scrapy import log | |
import re | |
import json | |
# curl http://192.168.1.100:6800/schedule.json -d project=scraper -d spider=importjl -d setting=STORE=24 -d setting=RQ_QUEUE=scraper | |
class ImportjlSpider(CrawlSpider): |
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
globalconnection = None | |
def get_mongodb_connect_url(): | |
if IS_PRODUCTION: | |
return ('mongodb://fuck:yourmother' | |
'mongodb-1.fuck.com:27017,' | |
'mongodb-2.fuck.com:27017,' | |
'mongodb-3.fuck.com:27017,' | |
'mongodb-4.fuck.com:27017') |
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 sys | |
import time | |
import string | |
import hashlib | |
import itertools | |
def main(filename, output): | |
with open(filename) as f: |
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
#!/bin/bash | |
set -o errexit | |
set -o nounset | |
if [[ ${#} -ne 1 ]] | |
then | |
echo "Usage: ${0} upstart-conf-file" >&2 | |
exit 1 | |
fi |
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
#!/usr/bin/env bash | |
# Pre-requisites | |
sudo apt-get -y update | |
sudo apt-get --no-install-recommends -y install build-essential openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev libgdbm-dev ncurses-dev automake libtool bison subversion pkg-config libffi-dev vim | |
# Download and compile Ruby 2.0.0-p0 | |
cd /tmp | |
wget ftp://ftp.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p0.tar.gz | |
tar -xvzf ruby-2.0.0-p0.tar.gz |
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
def html_decorator(func): | |
""" | |
This decorator wraps the output in html. | |
(From http://stackoverflow.com/a/14647943) | |
""" | |
def _decorated(*args, **kwargs): | |
response = func(*args, **kwargs) | |
wrapped = ("<html><body>", |
NewerOlder