Skip to content

Instantly share code, notes, and snippets.

import difflib
veggies1 = '''
celery
spinach
lettuce
garlic
carrot
cabbage
potato
--- lao 2020-02-21 23:30:39.942229878 -0800
+++ tzu 2020-02-21 23:30:50.442260588 -0800
@@ -1,7 +1,6 @@
-The Way that can be told of is not the eternal Way;
-The name that can be named is not the eternal name.
The Nameless is the origin of Heaven and Earth;
-The Named is the mother of all things.
+The named is the mother of all things.
+
Therefore let there always be non-being,
---
- hosts: router_fsn
gather_facts: no
connection: local
tasks:
- name: Login
include_vars: secrets.yml
- name: Provider definition
import requests
data = { 'username' : 'root', 'password' : 'default' }
r = requests.post('https://address.of.opengear/api/v1/sessions/', data=json.dumps(data), verify=False)
token = json.loads(r.text)['session']
import requests, json
data = { 'username' : 'root', 'password' : 'default' }
r = requests.post('https://address.of.opengear/api/v1/sessions/', json.dumps(data), verify=False)
token = json.loads(r)['session']
import requests, json
data = { 'username' : 'root', 'password' : 'default' }
r = requests.post('https://address.of.opengear/api/v1/sessions/', json.dumps(data), verify=False)
token = json.loads(r.text)['session']
import requests, json
data = { 'username' : 'root', 'password' : 'default' }
r = requests.post('https://address.of.opengear/api/v1/sessions/', data=json.dumps(data), verify=False)
token = json.loads(r.text)['session']
headers = { 'Authorization' : 'Token ' + token }
r = requests.get('https://address.of.opengear/api/v1/serialPorts/', headers=headers, verify=False)
j = json.loads(r.text)
print(json.dumps(j, indent=4))
def my_function(n):
return n > 1
print(my_function(1))
print(my_function(2))
import unittest
class TestStringMethods(unittest.TestCase):
def test_upper(self):
self.assertEqual('foo'.upper(), 'FOO')
def test_isupper(self):
self.assertTrue('FOO'.isupper())
self.assertFalse('Foo'.isupper())