Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am smajda on github.
  • I am smajda (https://keybase.io/smajda) on keybase.
  • I have a public key ASA5k5YuTGsuCw51oeiZM8KHxrlHIxr7dKSpT40SO_QYRwo

To claim this, I am signing this object:

@smajda
smajda / pythonkc_coc.mkd
Last active December 29, 2015 14:27
PythonKC Code of Conduct Draft

PythonKC Code of Conduct

Like the technical community as a whole, the PythonKC community is made up of a mixture of professionals and volunteers from all over the world, working on every aspect of the mission - including mentorship, teaching, and connecting people.

Diversity is one of our huge strengths, but it can also lead to communication issues and unhappiness. To that end, we have a few ground rules that we ask people to adhere to. This code applies equally to founders, mentors and those seeking help and guidance.

This isn’t an exhaustive list of things that you can’t do. Rather, take it in the spirit in which it’s intended - a guide to make it easier to enrich all of us and the technical communities in which we participate.

This code of conduct applies to all spaces managed by the PythonKC. This includes PythonKC meetups and events, IRC, Slack, Github, the mailing list, and any other forums created by the PythonKC organizers which the community uses for communication. In addition, violations of th

@smajda
smajda / pytest_example.py
Last active December 7, 2021 11:45
Simple example of using pytest and requests to test http requests
# pip install pytest requests
# py.test
import requests
def test_home():
"GET request to url returns a 200"
url = 'https://monitorial.com/'
resp = requests.get(url)
assert resp.status_code == 200
set bind-tty-special-chars off
"\e[1~": beginning-of-line
"\e[4~": end-of-line
"\e[5~": beginning-of-history
"\e[6~": end-of-history
"\e[3~": delete-char
"\e[2~": quoted-insert
"\e[5C": forward-word
"\e[5D": backward-word
"\e\e[C": forward-word
@smajda
smajda / gulpfile.js
Last active September 28, 2016 13:47
Example gulpfile using babelify for es6 & jsx with minifify for minification and source maps
/*
* Directory structure:
*
* project/
* package.json
* gulpfile.js
* node_modules/
* src/
* dist/
*
@smajda
smajda / gist:35ec842de18b9f4d4fb7
Created June 3, 2014 17:17
Amazon S3 Bucket Policy: allow public read of any file in bucket. Note: replace 'bucket_name_here'. Source: http://stackoverflow.com/a/4709391
{
"Version": "2008-10-17",
"Statement": [
{
"Sid": "AllowPublicRead",
"Effect": "Allow",
"Principal": {
"AWS": "*"
},
"Action": "s3:GetObject",
@smajda
smajda / docker_cleanup.py
Last active January 15, 2022 18:06
Python script to delete any untagged Docker containers and images.
import re
import subprocess
import sys
from collections import namedtuple
def first_to_last(items):
"Return a new list where last item in items is moved to the front"
return items[-1:] + items[:-1]
@smajda
smajda / gist:6320194
Last active December 21, 2015 14:29
Beer song
from textwrap import dedent
def beer_song():
def describe(quantity):
if quantity > 1:
return '{} bottles'.format(quantity)
elif quantity == 1:
return '1 bottle'
else:
return 'No more bottles'
@smajda
smajda / gist:5388745
Created April 15, 2013 15:01
wget mirror with options I have to google for everytime.
#!/bin/sh
url='http://someurl.com/'
wait=2 # wait between each request
cutdirs=2 # i.e. if '/foo/bar/data' -> start at 'data'
wget \
--execute="robots=off" \
--mirror \
--convert-links \
"""
Converts source video files in `sources` to mp4, ogv, and webm 640x360.
Edit `sources` (list of filenames) and adjust `source_dir`, `output_dir`,
and `new_path` as needed.
Reference: http://paulrouget.com/e/converttohtml5video/
"""
import os
import subprocess