Skip to content

Instantly share code, notes, and snippets.

View Mause's full-sized avatar
:shipit:
Still trying to figure out what I'm doing

Elliana May Mause

:shipit:
Still trying to figure out what I'm doing
View GitHub Profile
import re
import requests
from os.path import basename
from urllib.parse import urljoin
def generate_files(filenames):
return [
(
'input_files[]',
import math
def area_of_circle(diameter):
return math.pi * (diameter / 2 ** 2)
def volume_of_pipe(inner_diameter, outer_diameter, length):
area_of_pipe_end = (
area_of_circle(outer_diameter) -
list(A) ::= LIST_ITEM(B). { A=B; }
list(A) ::= LIST_ITEM(B) list_clause(C). {
A=B;
append_contents of C to B
}
list_clause(A) ::= COMMA list(B). { A=B; }
>>> l = ['key1', 'value1', 'key2', 'value2']
>>> l = map(str.strip, l)
>>> l = iter(l) # if not already an iterator
>>> d = dict(zip(l, l))
>>> d
{
'key1': 'value1',
'key2': 'value2'
}
>>> l = [' key1 ', ' value1 ', ' \tkey2', 'value2\t\n']
>>> l = [s.strip() for s in l]
>>> d = dict(zip(l[::2], [1::2]))
>>> d
{
'key1': 'value1',
'key2': 'value2'
}
@Mause
Mause / client.py
Created June 14, 2014 07:06
A as simple as possible example of a ZMQ ROUTER-to-REQ configuration with curve authentication; ironhouse
import logging
logging.basicConfig(level=logging.DEBUG)
import zmq
import zmq.auth
def main(recreate):
if recreate:
zmq.auth.create_certificates('.curve', 'client')
def clean_json(google_json):
# delete anti-xss junk ")]}'\n" (5 chars);
google_json = google_json[4:]
# pass through result and turn empty elements into nulls
instring = False
inescape = False
lastchar = ''
normal_json = ""
#include <string.h>
bool startswith(char* poss, char* chunk) {
char* result = strstr(poss, chunk);
return result != NULL && result == poss;
}
#!/bin/bash
chown www-data:www-data /var/www/docs;
chmod go+rx -R /var/www/docs;
chmod go+rw -R /var/www/builds;
int main() {
system("chown www-data:www-data /var/www/docs;");
system("chmod go+rx -R /var/www/docs");
system("chmod go+rw -R /var/www/builds");
return 0;
}