sudo wget https://storage.googleapis.com/golang/go1.4.2.linux-amd64.tar.gz
tar -xzf go1.4.2.linux-amd64.tar.gz
export GOROOT=PATH_WHERE_YOU_EXTRACT_GO
export PATH=$PATH:$GOROOT/bin
export GOBIN=$GOROOT/bin
mkdir ~/golang/
export GOPATH=~/golang/
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 new_user(username, admin='no', comment="No comment provided"): | |
| log_action("New User (%s): %s" % (username, comment)) | |
| pass | |
| $ fab new_user:myusername | |
| $ fab new_user:username=myusername | |
| $ fab new_user:myusername,yes | |
| $ fab new_user:myusername,admin=yes | |
| $ fab new_user:myusername,admin=no,comment='Gary\, new developer (starts Monday)' |
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
| # Load Json into a Python object | |
| import urllib2 | |
| import json | |
| req = urllib2.Request("http://localhost:81/sensors/temperature.json") | |
| opener = urllib2.build_opener() | |
| f = opener.open(req) | |
| json = json.loads(f.read()) | |
| print json | |
| print json['unit'] |
I've been following this blog post on how to set up an api-only Rails 5 application. One of the sections talks about creating a subdomain for your api
Rails.application.routes.draw do
constraints subdomain: "api" do
scope module: "api" do
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 -*- | |
| ''' | |
| Returns state event data for state.sls and state.highstate execution only using a tcp socket, this method of | |
| returning data can be used for Splunk or ELK. | |
| Each event sent represents a single state executed. | |
| It is strongly recommended to use the ``event_return_whitelist`` so not all | |
| events call this returner, for example: |
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 python | |
| import salt.cli.caller | |
| import salt.config | |
| import argparse | |
| import sys | |
| import signal | |
| class TimeoutException(Exception): | |
| pass |
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 subprocess | |
| import re | |
| regex = re.compile('([A-Z]+)=(?:"(.*?)")') | |
| parts = "NAME,KNAME,MODEL,UUID,SIZE,ROTA,TYPE,MOUNTPOINT,MAJ:MIN" | |
| def blocks(): | |
| blocks = [] | |
| output = subprocess.check_output([ | |
| "sudo", "lsblk", "-P", "-o", |
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 selenium import webdriver | |
| from selenium.webdriver import DesiredCapabilities | |
| desired_capabilities = DesiredCapabilities.PHANTOMJS.copy() | |
| desired_capabilities['phantomjs.page.customHeaders.User-Agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_1) ' \ | |
| 'AppleWebKit/537.36 (KHTML, like Gecko) ' \ | |
| 'Chrome/39.0.2171.95 Safari/537.36' | |
| driver = webdriver.PhantomJS(desired_capabilities=desired_capabilities) |