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 django.core.files.base import ContentFile | |
from django.db import models | |
file_storage = FileSystemStorage(location='/archive') | |
class MyFileModel(models.Model): | |
""" | |
A sample model | |
""" |
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
// Say this is /utils/auth.js | |
import firebase from './firebase' | |
export async function signInWithFacebook() { | |
const appId = Expo.Constants.manifest.extra.facebook.appId; | |
const permissions = ['public_profile', 'email']; // Permissions required, consult Facebook docs | |
const { | |
type, | |
token, |
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 /utils/firebase.js | |
// We should import firebase from this module instead of the default package. | |
import * as firebase from 'firebase' // Should not be used elsewhere in the project | |
firebase.initializeApp(Expo.Constants.manifest.extra.firebase); | |
export default firebase; |
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
{ | |
"expo": { | |
... | |
"extra": { | |
"firebase": { | |
"apiKey": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", | |
"authDomain": "xxxxxxxxxx.firebaseapp.com", | |
"databaseURL": "xxxxxxxxxxxxxxxxxxxxxxxxxx", | |
"projectId": "xxxxxxxxxx", | |
"storageBucket": "xxxxxxxxxx.appspot.com", |
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
// Full Repo: https://bitbucket.org/melvinkcx/mongoose_lean_virtuals_profiler/src/master/ | |
const mongoose = require('mongoose'); | |
const mongooseLeanVirtuals = require('mongoose-lean-virtuals'); | |
const Schema = mongoose.Schema; | |
// Modelled after imdb title dataset | |
// Link: https://datasets.imdbws.com/title.basics.tsv.gz | |
const titleSchema = new Schema({ | |
genres: String, |
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
async function runProfiler(numberOfTimes, limit) { | |
const mongoose = require('mongoose'); | |
const TitleModel = require('./title.model'); | |
const mongodb = "mongodb://root:root@localhost/imdb?authSource=admin" | |
mongoose.connection.once('open', function () {console.log('connected to mongoDB');}); | |
await mongoose.connect(mongodb, {useNewUrlParser: true}) | |
mongoose.Promise = global.Promise; |
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 mongooseLeanVirtuals from 'mongoose-lean-virtuals'; | |
export default (app) => { | |
const mongooseClient = app.get('mongooseClient'); | |
const {Schema} = mongooseClient; | |
const {ObjectId} = Schema.Types; | |
const user = new Schema({ | |
// ... | |
}); |
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
// user.service.js | |
import createService from 'feathers-mongoose'; | |
// other imports... | |
export default (app) => { | |
const Model = createModel(app); | |
// ... | |
const options = { | |
Model, |
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
{ | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"type": "node", | |
"request": "launch", | |
"name": "Run yarn test", | |
"runtimeExecutable": "yarn", | |
"runtimeArgs": [ | |
"test" |
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 google.oauth2 import service_account | |
from googleapiclient.discovery import build | |
SCOPES = ['https://www.googleapis.com/auth/calendar'] | |
SERVICE_ACCOUNT_FILE = './xxxxxxxxxxxx.json' # You should make it an environment variable | |
credentials = service_account.Credentials.from_service_account_file(SERVICE_ACCOUNT_FILE, scopes=SCOPES) | |
delegated_credentials = credentials.with_subject('melvin@xxxxxxxx.xx') | |
service = build('calendar', 'v3', credentials=delegated_credentials) |
OlderNewer