This file contains 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 swapi | |
get_character("name"): | |
for c in swapi.get_all("people"): | |
if c.name == name: | |
return c | |
This file contains 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
# Change your settings file to this: | |
SECRET_KEY = os.environ.get('SECRET_KEY', 'MY_DEFAULT_KEY') | |
# Export the SECRET_KEY variable like in the terminal like so: | |
$ export SECRET_KEY=my_secret_key_here |
This file contains 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
package main | |
import ( | |
"github.com/gin-gonic/gin" | |
"database/sql" | |
"github.com/coopernurse/gorp" | |
_ "github.com/mattn/go-sqlite3" | |
"log" | |
"time" | |
"strconv" |
This file contains 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 get_persistence(array_of_numbers): | |
for current_number in array_of_numbers: | |
if current_result is None: | |
current_result = current_number | |
else: | |
current_result = current_result * current_number | |
if len(current_result) == 1: |
This file contains 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
# A merge sort algorithm that is probably bigger than it needs to be. | |
# Uses binary trees to sort integers. | |
# Runtime is probably O(NlogN) | |
class Node(object): | |
def __init__(self, value): | |
self.value = value | |
self.left = None |
This file contains 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 LRUCache(object): | |
""" Implements a least-recently-used cache in Python | |
As the cache grows it will cap at some fixed size described by the max_size | |
property | |
When you attempt to add a new object into a full cache, it will discard the | |
Least Recently Used cached item. | |
Calling set('key', ...) or get('key') constitutes a "use" of 'key' |
This file contains 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
haystack = [5,3,2,4,1] | |
for i in range(1, len(haystack)): | |
x = haystack[i] | |
c = i | |
while c > 0 and haystack[c-1] > x: | |
haystack[c] = haystack[c-1] | |
c = c - 1 | |
haystack[c] = x |
This file contains 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 flask import Flask, request | |
app = Flask(__name__) | |
from twilio.rest import TwilioRestClient | |
client = TwilioRestClient() | |
@app.route('/error_trigger', methods=['POST']) | |
def error_triggers(): |
This file contains 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 flask import Flask, request | |
app = Flask(__name__) | |
@app.route('/error_trigger', methods=['POST']) | |
def error_triggers(): | |
error_code = request.values.get('ErrorCode', None) | |
description = request.values.get('Description', None) | |
if error_code: | |
msg = 'An error on Twilio occurred! ' + description |
This file contains 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 flask import Flask, request | |
app = Flask(__name__) | |
@app.route('/error_trigger', methods=['POST']) | |
def error_triggers(): | |
error_code = request.values.get('ErrorCode', None) | |
return 'The error is' + error_code | |
if __name__ == "__main__": |