Skip to content

Instantly share code, notes, and snippets.

View itsmemattchung's full-sized avatar

Matt Chung itsmemattchung

View GitHub Profile
import pdb
pdb.set_trace()
flav = flavor or srv_args.get("flavorRef")
dconf = disk_config if disk_config is not None else srv_args.get("OS-DCF:diskConfig", "AUTO")
pers = personality if personality is not None else srv_args.get("personality", [])
body = {"type": "launch_server",
"args": {
"server": {
"name": server_name or srv_args.get("name"),
"imageRef": image or srv_args.get("imageRef"),
def main(args):
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers()
parser_add_device = subparsers.add_parser(
'add-device', help="Add host sub-command")
parser_add_device.add_argument(
'--host', action='store', dest='host',
help="Hostname of Zenoss Server")
parser_add_device.add_argument(
'--username', action='store', dest='username')
27
28 mpg_combined_average = data_set.ix[
29 (data_set['DRIVE_DESCR'] == 'All Wheel Drive') &
30 (data_set['VOLUME'] > 3) &
31 (data_set['GEARS'] % 2 == 0)].MPG_COMBINED.mean()
32
33 print "MPG Combined is {mpg}".format(mpg=mpg_combined_average)
27 Cart.prototype.findTicket = function(ticket){
28 return db.query(findTicketQuery, [this.sessionid, ticket.id])
29 .then(function(results)){
30 return new Ticket(results.rows[0])
31 })
32 }
diff --git a/Lib/tokenize.py b/Lib/tokenize.py
index 8bc83fd..96edf6c 100644
--- a/Lib/tokenize.py
+++ b/Lib/tokenize.py
@@ -434,12 +434,16 @@ def open(filename):
"""Open a file in read only mode using the encoding detected by
detect_encoding().
"""
- buffer = _builtin_open(filename, 'rb')
- encoding, lines = detect_encoding(buffer.readline)
@itsmemattchung
itsmemattchung / gist:36f619efe8cf9c0a7a1d
Created April 1, 2015 21:44
why would you have a nested function with mock in there?
1064 class TestTokenize(TestCase):
1065
1066 def test_tokenize(self):
1067 import tokenize as tokenize_module
1068 encoding = object()
1069 encoding_used = None
1070 def mock_detect_encoding(readline):
1071 return encoding, [b'first', b'second']
1072
openstack output will be in this color.
==> openstack: Creating temporary keypair for this instance...
==> openstack: Waiting for server (f8fc5320-019b-44f7-91da-98104571fc60) to become ready...
==> openstack: Waiting for SSH to become available...
==> openstack: Connected to SSH!
==> openstack: Provisioning with Ansible...
openstack: Creating Ansible staging directory...
openstack: Creating directory: /tmp/packer-provisioner-ansible-local
openstack:
@itsmemattchung
itsmemattchung / gist:822577fa9477d33b6fa8
Created October 8, 2015 18:05
Github3 tests failing
(github3)Matts-MacBook-Air:github3.py mattchung$ make tests >> /tmp/github3_errors.txt
no previously-included directories found matching '*.pyc'
no previously-included directories found matching 'docs/_build'
make: *** [travis] Error 1
(github3)Matts-MacBook-Air:github3.py mattchung$ view /tmp/github3_errors.txt
Processing /Users/mattchung/Development/github3.py
Requirement already satisfied (use --upgrade to upgrade): github3.py==1.0.0a2 from file:///Users/mattchung/Development/github3.py in /Users/mattchung/.virtualenvs/github3/lib/python2.7/site-packages (from -r dev-requirements.txt (line 1))
Requirement already satisfied (use --upgrade to upgrade): mock==1.0.1 in /Users/mattchung/.virtualenvs/github3/lib/python2.7/site-packages (from -r dev-requirements.txt (line 2))
Requirement already satisfied (use --upgrade to upgrade): pytest>=2.3.5 in /Users/mattchung/.virtualenvs/github3/lib/python2.7/site-packages (from -r dev-requirements.txt (line 3))
/**
* Sumologic module
* @module lib/sumologic
*/
var rsvp = require('rsvp');
var fs = require('fs');
var request = require('request')
var util = require('util');
@itsmemattchung
itsmemattchung / subclass_example.py
Created November 25, 2015 16:13
how to make mistakes in python subclass
class MyOtherClass(object):
def do_something(self):
self.__do_a_new_step()
self.__do_one_more_step()
# Should be subclassing from MyClass
class MyOtherClass(MyClass):
def do_something(self):
self.__do_a_new_step()
self.__do_one_more_step()