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
$ cat .env | |
API_KEY=supersecretstuff | |
$ pipenv run python | |
Loading .env environment variables… | |
Python 3.6.3 (default, Oct 4 2017, 06:09:15) | |
[GCC 4.2.1 Compatible Apple LLVM 9.0.0 (clang-900.0.37)] on darwin | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> import os | |
>>> os.getenv['API_KEY'] |
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
$ pipenv check | |
Checking PEP 508 requirements… | |
Passed! | |
Checking installed package safety… | |
33300: django >=1.10,<1.10.7 resolved (1.10.1 installed)! | |
CVE-2017-7233: Open redirect and possible XSS attack via user-supplied numeric redirect URLs | |
============================================================================================ | |
Django relies on user input in some cases (e.g. |
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
[[source]] | |
url = 'https://pypi.python.org/simple' | |
verify_ssl = true | |
[requires] | |
python_version = '3.6' | |
[packages] | |
flask = "*" | |
boto3 = ">=1.4" |
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 LowerCaseJSONDecoder(JSONDecoder): | |
def _lower_keys(self, obj): | |
new = {} | |
for k, v in obj.items(): | |
if isinstance(v, dict): | |
v = self._lower_keys(v) | |
new[k.lower()] = v | |
return new |
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 currify(func): | |
""" | |
Decorator to curry a function, use it like this: | |
>>> @currify | |
... def sum(a, b, c): | |
... return a + b + c | |
It works on normal way: | |
>>> sum(1, 2, 3) | |
6 | |
And also binding the params: |
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 primesList(N): | |
""" | |
Generates a list of prime numbers from 2 to N. | |
N: an integer | |
""" | |
return [a for a in range(2, N) if not [b for b in range(2,a) if not a%b]] | |
def __main__(): | |
print primesList(100) |
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 AddUsStates < ActiveRecord::Migration | |
def up | |
create_table :states do |t| | |
t.string :iso_abbr, unique: true | |
t.string :name | |
t.timestamps | |
end | |
#: insert states here | |
states_data = [ |
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 PropertyStatusHistory < ActiveRecord::Migration | |
def change | |
create_table :property_history do |t| | |
t.references :property, index: true, null: false | |
t.references :user, null: false, index: true | |
t.string :status, null: false | |
t.datetime :datetime, null: false | |
end | |
end | |
end |
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 DataImportTables < ActiveRecord::Migration | |
def change | |
create_table :imports do |t| | |
t.string :for_model, null: false, default: 'Properties' | |
t.string :name, null: false | |
t.attachment :file, null: false | |
t.references :company, null: false | |
t.timestamps null: false | |
end |