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
angular.module('stateMock', []); | |
angular.module('stateMock').service("$state", function($q) { | |
this.expectedTransitions = []; | |
this.transitionTo = function(stateName) { | |
if(this.expectedTransitions.length > 0) { | |
var expectedState = this.expectedTransitions.shift(); | |
if(expectedState !== stateName) { | |
throw Error("Expected transition to state: " + expectedState + " but transitioned to " + stateName ); | |
} | |
} else { |
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 json | |
from json import JSONEncoder | |
class Custom(object): | |
def serialize(self): | |
return 42 | |
class CustomEncoder(JSONEncoder): |
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 collections import Counter | |
def find_letter_distance(string, other): | |
string_counter = Counter(string) | |
other_counter = Counter(other) | |
unique_symbols = set(string + other) | |
distance = 0 | |
for char in unique_symbols: |
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
# Setup docs: http://boto3.readthedocs.org/en/latest/guide/quickstart.html | |
import boto3 | |
# List all regions | |
client = boto3.client('ec2') | |
regions = client.describe_regions()['Regions'] | |
for region in regions: | |
print('Name: %s. Endpoint: %s' % (region['RegionName'], region['Endpoint'])) |
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 math | |
from collections import defaultdict | |
words = ('the', 'quisck', 'brown', 'fox', 'quick') | |
class WordDistanceFinder(object): | |
def __init__(self, words): |
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
timetable = ( | |
('10:30', '11:30'), | |
('10:00', '11:00'), | |
('11:00', '12:00'), | |
('09:33', '12:00'), | |
('17:00', '19:00'), | |
('17:00', '19:00'), | |
('17:00', '19:00'), | |
('17:00', '19:00'), |
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 os | |
import time | |
import psutil | |
import humanfriendly | |
now = time.time() | |
pid = os.getgid() | |
ppid = os.getppid() |
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
class LinkedList(object): | |
def __init__(self): | |
self.head = None | |
self.tail = None | |
def add(self, node): | |
if self.tail is not None: | |
self.tail.next = node | |
self.tail = node | |
else: |
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
# -*- coding: utf-8 -*- | |
import os | |
from fabric.api import env, run, put, cd, local | |
env.user = '' | |
env.password = '' | |
env.hosts = ['127.0.0.1'] | |
env.shell = "bash -c" |
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 logging | |
def setup_logging(): | |
log = logging.getLogger(__name__) | |
log.setLevel(logging.DEBUG) | |
log.propagate = False | |
formatter = logging.Formatter('%(asctime)s :: line %(lineno)d, %(module)s [%(levelname)s] %(message)s') | |
formatter.datefmt = '%H:%M:%S %d/%m/%y' | |
handler = logging.StreamHandler() | |
file_handler = logging.FileHandler('file.log') |