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 os | |
import constants | |
from langchain.vectorstores import FAISS | |
from langchain.embeddings.openai import OpenAIEmbeddings | |
from langchain.document_loaders import PyPDFLoader | |
from langchain.indexes import VectorstoreIndexCreator | |
os.environ['OPENAI_API_KEY'] = constants.APIKEY | |
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
1 - ############ built-in zip function for i, j in zip(list1, list2) | |
2 - ############ built-in enumerate function for i,j in enumerate(lista) i = indice j = element | |
3 - ############ accessing a global variable a = 10 def foo(): global a a = 10 | |
4 - ########### range performance | |
Python 2.7 |
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
# 1 - Ideal DRF View | |
from rest_framework import status | |
from rest_framework.decorators import detail_route | |
from rest_framework.response import Response | |
import logging | |
def do_log(e): | |
logger = logging.getLogger('django') | |
time = datetime.datetime.now() |
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
# T1 - Exceptions | |
In general keep exceptions in views, not in models. | |
Put exceptions in models just when very necessary like to make process atomic or multiples tasks, | |
even in this case think if is not better split the method in multiple methos and treat exception in each method | |
# T2 - Always try to name the relationships | |
# T3 - Concentrate business logic into models methods and Managers | |
# T4 - Always help_text |
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
In module 'UIKit' imported from /Users/gregorypacheco/Library/Developer/Xcode/DerivedData/Cataki-dxdbfptxbcfahtclbubecydrrlpk/Build/Intermediates.noindex/ArchiveIntermediates/Cataki/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/include/Cordova/CDVPlugin.h:21: | |
/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h:459 | |
:63: note: property 'statusBarHidden' is declared deprecated here | |
@property(readwrite, nonatomic,getter=isStatusBarHidden) BOOL statusBarHidden NS_DEPRECATED_IOS(2_0, 9_0, "Use -[UIViewController prefersStatusBarHidden]") __TVOS_PROHIBITED; | |
^ | |
/Applications/Xcode-beta.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS11.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIApplication.h:459:63: note: 'setStatusBarHidden:' has been explicitly marked deprecated here | |
/Users/gregorypach |
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
# 1 - Find file terminal | |
find ~/ -type f -name "generate_interval.py" | |
# 2 - Checking HD size | |
df -H | |
# 3 - Tailing a log in realtime | |
tailor -f file.log | |
# 4 - If else param script bash |
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
Roles | |
- Or you might want to allow a mobile app to use AWS resources, but not want to embed AWS keys within the | |
app (where they can be difficult to rotate and where users can potentially extract them). | |
Sometimes you want to give AWS access to users who already have identities defined outside of AWS, such as in your corporate | |
directory. Or, you might want to grant access to your account to third parties so that they can perform an audit on your resources. | |
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
Fixed Performance Instances (e.g. M3, C3, and R3) | |
Burstable Performance Instances | |
- T2 | |
- Accrue CPU Credits when they are idle | |
- It stores them in its CPU Credit balance for up to 24 hours. | |
- If and when your t2.small needs to burst to more than 20% of a core, it draws from its | |
CPU Credit balance to handle this surge seamlessly | |
Cluster |
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
# 1 - Promisses | |
p.then(onFulfilled[, onRejected]); | |
p.then(function(value) { | |
// fulfillment | |
}, function(reason) { | |
// rejection | |
}); | |
# 2 - Find an object in a array |
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
- obj, created = AppSettings.objects.get_or_create(name='DEFAULT_LANG') | |
- Uso do dir(obj) | |
- Dont use exception as a flow control | |
- every exception should do log | |
- Database tips from brazilian guy article |
NewerOlder