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
<?php | |
require_once '3rdparty/phpass/PasswordHash.php'; | |
class MyDB extends SQLite3 | |
{ | |
function __construct() | |
{ | |
$this->open('data/owncloud.db'); | |
} |
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, jsonify | |
from oauth1.authorize import Oauth1 | |
from oauth1.errors.oauth import Oauth1Errors | |
from oauth1.store.sql import Oauth1StoreSQLAlchemy | |
BASE_URL = "http://localhost:5000/" | |
auth = None | |
app = Flask(__name__) | |
app.config['SQLALCHEMY_DATABASE_URI'] = "mysql://root:somepassword@127.0.0.1:3306/oauth" # Change this to a valid URI |
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
""" | |
I know that parsing json values for SQLAlchemy models is a pain in the ass. | |
The following two helpers will get you cleaner code and handles the json while converting it into code. | |
This is commonly use in Flask-SQLAlchemy applications. My latest backyard release already included these functions | |
""" | |
import json | |
# this import is just an example of an SQLAlchemy module, it can be any model that you wish to use | |
from app.models import User |
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 parser(passed_object, request_data): | |
for item in request_data.values: | |
if hasattr(passed_object, item) and request_data.values.get(item) != None: | |
inputval = request_data.values.get(item) | |
#TODO: check the corresponding class variable type before typecasting | |
setattr(passed_object, item, inputval) | |
return passed_object |
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
COMMON: | |
DEBUG: false | |
TESTING: false | |
IS_PRODUCTION: False | |
TEST: | |
TESTING: true | |
DEVELOPMENT: | |
DEBUG: true | |
TESTING: false | |
STAGING: |
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 mothernature import Environment | |
env = Environment("config.yml") | |
# This will provide the config based on the environment you set when starting the application | |
# and then you can do | |
test_env.get("DB_CONNECTION") |
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 mothernature import Environment | |
env = Environment("someyml.yaml", environment='DEV') | |
test_env.get("DB_CONNECTION") |
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
<div id="prism-widget"></div> | |
<script src="https://prismapp-files.s3.amazonaws.com/widget/prism.js"></script> | |
<script type="text/javascript"> | |
(function(e, b, c) { | |
e.Shamu = { | |
merchant_id: '', | |
initialize: function(a) { | |
a.merchant_id ? this.merchant_id = a.merchant_id : console.log("Shamu: Please initialize Shamu with a merchat_id"); | |
}, | |
display: function() { |
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
#create the key-value object | |
class KeyValue: | |
def __init__(self,key,value): | |
self.key=key | |
self.value=value | |
class HashTable: | |
#initiate an empty list that will store all key value pair based on the KeyValue object | |
def __init__(self): |
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 quicksort(input_list): | |
higher = [] | |
lower = [] | |
if len(input_list) > 2: | |
pivot = (len(input_list) - 1)/2 | |
mid = [input_list[pivot]] | |
i = 0 | |
while i < len(input_list): | |
if i != pivot: | |
if input_list[i] <= input_list[pivot]: |