This file contains hidden or 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
""" | |
requests | |
beautifulsoup4 | |
""" | |
import requests | |
from bs4 import BeautifulSoup | |
def to_rgb(hex): |
This file contains hidden or 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
fibonacci : function(n) { | |
// f(0) = 0 | |
// f(1) = 1 | |
// f(n) = f(n-1) + f(n-2) | |
if (n === 0) { | |
return 0; | |
} | |
if (n === 1) { | |
return 1; | |
} |
This file contains hidden or 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
import random | |
my_randoms = random.sample(xrange(100), 13) | |
def merge(first_half, second_half): | |
if len(first_half) == 0: | |
return second_half | |
elif len(second_half) == 0: | |
return first_half |
This file contains hidden or 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
<VirtualHost *:80> | |
ServerName HOSTNAME.DOMAIN | |
WSGIDaemonProcess threads=5 | |
WSGIScriptAlias / /PATH/TO/WSGI/DEFINITION/webapp.wsgi | |
<Directory /PATH/TO/WSGI/DEFINITION> | |
Order deny,allow | |
Require all granted | |
</Directory> |
This file contains hidden or 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
import argparse | |
import re | |
class Validator(object): | |
def __init__(self, pattern): | |
self._pattern = re.compile(pattern) | |
def __call__(self, value): |
This file contains hidden or 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
def confirm(): | |
""" | |
Ask user to enter Y or N (case-insensitive). | |
:return: True if the answer is Y. | |
:rtype: bool | |
""" | |
answer = "" | |
while answer not in ["y", "n"]: | |
answer = raw_input("OK to push to continue [Y/N]? ").lower() |
This file contains hidden or 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
""" | |
Publish the function to S3: | |
cd $DIR_WITH_THIS_SCRIPT | |
zip find_latest_ami_name.zip find_latest_ami_name.py | |
aws s3 cp find_latest_ami_name.zip s3://$YOUR_S3_BUCKET/find_latest_ami_name.zip | |
""" | |
import json |
This file contains hidden or 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
""" | |
Glossary used in the functions below: | |
Node can be virtually any hashable datatype. | |
:param start: starting node | |
:param end: ending node | |
:param weighted_graph: {"node1": {"node2": "weight", ...}, ...} | |
""" |
This file contains hidden or 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
#!/bin/sh | |
# Put to /usr/bin/sample-program | |
sleep 600 & | |
PID="$!" | |
# Trap is required to kill all child processes when the service is stopped | |
trap "kill $PID" exit INT TERM KILL TERM |
This file contains hidden or 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 abc import ABCMeta, abstractproperty | |
import unittest | |
import mock | |
class BaseTest(unittest.TestCase): | |
__metaclass__ = ABCMeta |
OlderNewer