This file contains 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 requests | |
url = 'http://www.webservicex.net/currencyconvertor.asmx/ConversionRate?FromCurrency=CNY&ToCurrency=USD' | |
r = requests.get(url) | |
data = r.text | |
data = data.split("\n")[1] | |
spos = data.find('">') + 2 | |
epos = data.find("</", spos) |
This file contains 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 fabric.api import * | |
def deep_snd(path_to_repo): | |
if path_to_repo[0] != '/': | |
path_to_repo = local("readlink -f {}".format(path_to_repo), capture=True) | |
dirs = local("find {} -name .gitmodules".format(path_to_repo), capture=True) | |
dirs = [x.rstrip(".gitmodules") for x in dirs.split()] |
This file contains 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
@roles(environment) | |
def resymlink_profile(old_ver, new_ver): | |
with cd("/data/web/express"): | |
sites = get_resource("sites", '?where={"type":"express"}')['_items'] | |
for s in sites: | |
with cd("{}/profiles".format(s['path'])): | |
if exists("cu_fit"): | |
link = run("readlink cu_fit") | |
version = link.split("/")[-1] | |
if version == old_ver: |
This file contains 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
%{SYSLOGBASE} %{URI:base_url}\|%{INT:unix_timestamp}\|%{DATA:category}\|%{IP:ip}\|%{URI:request_url}\|(?:%{URI:referrer}|)\|%{INT:uid}\|(?:%{URI:link}|)\|%{GREEDYDATA:errmsg} |
This file contains 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 elasticsearch | |
from pprint import pprint | |
es = elasticsearch.Elasticsearch() | |
query = {'size': 0, 'aggs': {'institutions': {'terms': {'field': 'institution', 'size': 10}}}} | |
res = es.search(index='courses', doc_type='class', body=query) | |
pprint(res['aggregations']) |
This file contains 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 urlparse import urljoin | |
>>> from functools import partial | |
>>> api_url = "http://my-eve-api.com/api/" | |
>>> endpointer = partial(urljoin, api_url) | |
>>> endpointer("sites") | |
'http://my-eve-api.com/api/sites' | |
>>> endpointer("contacts") | |
'http://my-eve-api.com/api/contacts' |
This file contains 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
- hosts: all | |
sudo: yes | |
tasks: | |
- name: "Build hosts file" | |
lineinfile: | |
dest=/etc/hosts | |
regexp=".*{{ item }}$" | |
line="{{ hostvars[item].ansible_eth1.ipv4.address }} {{item}}" | |
state=present | |
when: hostvars[item].ansible_eth1.ipv4.address is defined |
This file contains 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 re | |
import json | |
import sys | |
import os | |
from subprocess import Popen, PIPE | |
if __name__ == '__main__': | |
base_path = os.path.abspath(os.path.dirname(__file__)) | |
args = sys.argv |
This file contains 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
#setup ~/.boto first | |
from boto.support.layer1 import SupportConnection | |
conn = SupportConnection() | |
checks = conn.describe_trusted_advisor_checks("en") | |
ids = [c['id'] for c in checks['checks']] | |
summaries = conn.describe_trusted_advisor_check_summaries(ids) |
This file contains 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
cfg := api.DefaultConfig() | |
cfg.Address = "https://your_vault_addr:8200" | |
client, err := api.NewClient(cfg) | |
if err != nil { | |
fmt.Println(err) | |
} | |
inputs := map[string]string{ | |
"mount": "github", | |
"token": "token", | |
} |
OlderNewer