Skip to content

Instantly share code, notes, and snippets.

View 2rs2ts's full-sized avatar

Andrew G 2rs2ts

View GitHub Profile
@mkrizek
mkrizek / ansible-jinja-types.md
Last active May 9, 2023 07:47
Ansible, Jinja2 and Types

Ansible, Jinja2 and Types

Strings, strings everywhere

Jinja2 is a templating engine and as such its primary use case is to render templates into text; which is usually HTML output saved into text file.

Consider the following Ansible play that uses Jinja2 templates to evaluate expressions:

- hosts: localhost
  gather_facts: no
@gbaman
gbaman / graphql_example.py
Created November 1, 2017 00:18
An example on using the Github GraphQL API with Python 3
# An example to get the remaining rate limit using the Github GraphQL API.
import requests
headers = {"Authorization": "Bearer YOUR API KEY"}
def run_query(query): # A simple function to use requests.post to make the API call. Note the json= section.
request = requests.post('https://api.github.com/graphql', json={'query': query}, headers=headers)
if request.status_code == 200:
'''
intro.py
Managing kubernetes objects using common resource operations with the python client
-----------------------------------------------------------------------------------------------
Some of this operations include;
- **`create_xxxx`** : create a resource object. Ex **`create_namespaced_pod`** and **`create_namespaced_deployment`**, for creation of pods and deployments respectively. This performs operations similar to `kubectl create`.
#!/bin/sh
BOOT2DOCKER_CERTS_DIR=/var/lib/boot2docker/certs
CERTS_DIR=/etc/ssl/certs
CAFILE=${CERTS_DIR}/ca-certificates.crt
for cert in $(/bin/ls -1 ${BOOT2DOCKER_CERTS_DIR}); do
SRC_CERT_FILE=${BOOT2DOCKER_CERTS_DIR}/${cert}
CERT_FILE=${CERTS_DIR}/${cert}
HASH_FILE=${CERTS_DIR}/$(/usr/local/bin/openssl x509 -noout -hash -in ${SRC_CERT_FILE} 2>/dev/null)
@gregsabo
gregsabo / intern_roundup.markdown
Last active January 2, 2016 03:49
Intern Retrospective Guidelines

We like to have our interns and co-ops summarize their experiences before they finish. Here are some guidelines to help develop a useful presentation.

Golden Rule: Convince us to hire you!

To be clear, your retrospective will have little impact on HubSpot's decision to make an offer. However, approaching your presentation this way will help you focus on making an impact that will give you a jump start on your career if you do join HubSpot in the future.

This is your chance to put yourself out there to make some very valuable professional connections. When you're choosing what to put on your slides, always think: "Will telling people this make them want to work with me again?"

Some things you might talk about

@lincolndbryant
lincolndbryant / work.scpt
Last active December 28, 2015 01:39
work.scpt
tell application "Terminal"
activate
do script "cd ~/dev/src/Content3/content_web/content_web"
do script "workon content" in front window
do script "sh admin.sh local runserver" in front window
my makeTab()
do script "cd ~/dev/src/Content3/content_web/content_web/public" in tab 2 of front window
do script "workon content" in tab 2 of front window
do script "sh admin.sh local runserver localhost:8001" in tab 2 of front window
@marcelom
marcelom / pysyslog.py
Created December 5, 2012 18:06
Tiny Python Syslog Server
#!/usr/bin/env python
## Tiny Syslog Server in Python.
##
## This is a tiny syslog server that is able to receive UDP based syslog
## entries on a specified port and save them to a file.
## That's it... it does nothing else...
## There are a few configuration parameters.
LOG_FILE = 'youlogfile.log'
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 31, 2024 22:29
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@gvx
gvx / mastermind.py
Created May 16, 2011 20:20
An implementation of Knuth's five-guess algorithm to solve a mastermind code [CC0]
from itertools import product
def score(self, other):
first = len([speg for speg, opeg in zip(self, other) if speg == opeg])
return first, sum([min(self.count(j), other.count(j)) for j in 'ABCDEF']) - first
possible = [''.join(p) for p in product('ABCDEF', repeat=4)]
results = [(right, wrong) for right in range(5) for wrong in range(5 - right) if not (right == 3 and wrong == 1)]
def solve(scorefun):
@endolith
endolith / Has weird right-to-left characters.txt
Last active June 1, 2024 10:58
Unicode kaomoji smileys emoticons emoji
ּ_בּ
בּ_בּ
טּ_טּ
כּ‗כּ
לּ_לּ
מּ_מּ
סּ_סּ
תּ_תּ
٩(×̯×)۶
٩(̾●̮̮̃̾•̃̾)۶