- intro, download, install & setup
- basics, syntax
- control flow
- more types, data structures
- methods & interfaces
- concurrency
- nice to know stuff
- golang gotchas <-- especially if you are coming from python, ruby etc
- workspace
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 Crypto.Cipher import AES | |
from Crypto import Random | |
import base64 | |
block_size = AES.block_size | |
#unpad = lambda s : s[0:-ord(s[-1])] | |
def pad(plain_text): |
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
`pip install pycrypto` | |
from Crypto.Cipher import DES3 | |
from Crypto import Random | |
key = 'Sixteen byte key' | |
iv = Random.new().read(DES3.block_size) #DES3.block_size==8 | |
cipher_encrypt = DES3.new(key, DES3.MODE_OFB, iv) | |
plaintext = 'sona si latine loqueri ' #padded with spaces so than len(plaintext) is multiple of 8 | |
encrypted_text = cipher_encrypt.encrypt(plaintext) |
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
- name: install newer nginx and ovveride old config file | |
shell: sudo apt-get -y -o Dpkg::Options::=--force-confnew install nginx | |
notify: restart nginx |
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
#https://www.zeitgeist.se/2013/11/22/strongswan-howto-create-your-own-vpn/ | |
#https://www.gypthecat.com/ipsec-vpn-host-to-host-on-ubuntu-14-04-with-strongswan | |
#Example of simple pre-shared keys vpn setup: https://www.strongswan.org/uml/testresults/ikev2/rw-psk-ipv4/ | |
$ sudo apt-get -y install strongswan | |
$ ipsec version | |
Linux strongSwan U5.1.2/K3.13.0-55-generic | |
Institute for Internet Technologies and Applications | |
University of Applied Sciences Rapperswil, Switzerland | |
See 'ipsec --copyright' for copyright information. |
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
package main | |
import ( | |
"fmt" | |
"net/http" | |
) | |
type Mystring string | |
type Mystruct struct { |
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 rest_framework.test import APIClient | |
class SomeTests(LiveServerTestCase): | |
def setUp(self): | |
self.real_URL = settings.SOME_URL | |
settings.SOME_URL = '{0}/some-url/'.format(self.live_server_url) | |
self.client = APIClient() | |
self.payload = """<some>xml-string</xml>""" |
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
# We compare/measure reading a file from memory(1) vs reading from filesytem(2) | |
################################## | |
### 1. reading file from memory ## | |
################################## | |
import time | |
import mmap | |
filename = "myfile.txt" |
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
class DateTimefaker(datetime): | |
""" | |
fake datetime to use your own custom datetimes | |
""" | |
def __new__(cls, *args, **kwargs): | |
return datetime.__new__(datetime, *args, **kwargs) | |
class TestSomething(TestCase): | |
fixtures = ['test_data'] |
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
#/etc/haproxy/haproxy.cfg | |
frontend http-in | |
bind *:{{APP_PORT}} | |
mode http | |
default_backend servers | |
frontend https-in | |
bind *:{{APP_PORT_HTTPS}} ssl no-sslv3 crt /etc/haproxy/server_cert.pem | |
reqadd X-Forwarded-Proto:\ https |