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
package main | |
import "flag" | |
var ( | |
cmd = flag.String("cmd", "", "list or add?") | |
address = flag.String("address", "", "mongodb address to connect to") | |
database = flag.String("db", "", "The name of the database to connect to") | |
collection = flag.String("collection", "", "The collection (in the db) to connect to") | |
key = flag.String("field", "", "The field you'd like to place an index on") |
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
package main | |
import ( | |
"context" | |
"flag" | |
"log" | |
"github.com/mongodb/mongo-go-driver/mongo" | |
) | |
var ( |
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
func PopulateIndex(database, collection string, client *mongo.Client) { | |
c := client.Database(database).Collection(collection) | |
opts := options.CreateIndexes().SetMaxTime(10 * time.Second) | |
index := yieldIndexModel() | |
c.Indexes().CreateOne(context.Background(), index, opts) | |
log.Println("Successfully create the index") | |
} | |
func yieldIndexModel() mongo.IndexModel { | |
keys := bsonx.Doc{{Key: *key, Value: bsonx.Int32(int32(*value))}} |
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
package main | |
import ( | |
"context" | |
"flag" | |
"fmt" | |
"log" | |
"time" | |
"github.com/mongodb/mongo-go-driver/bson" |
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
AllCops: | |
Exclude: | |
- "vendor/**/*" | |
- "db/**/*" | |
- "bin/**/*" | |
- "config/**/*" | |
- "app/assets/**/*" | |
- "Rakefile" | |
- "spec/spec_helper.rb" | |
- "spec/rails_helper.rb" |
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
// assuming something we had a collection called movies and movies has two categories, action, comedy, | |
// and comedy has three sections (kevin hart, mike epps, chris rock) and action has three sections (chuck norris, jet li, jackie chan). | |
// if we were going to insert a document (movie) into the movies collection. | |
let movieOne = { _id: "Jolade's movie log", path: null } // the path null marks this as a root node | |
const m = db.movies.insert(movieOne) | |
//to declare a node to the category | |
const a = db.movies.insert({ path: `,${m._id},`, _id: "Jolade's movie log (action)" }) |
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
// we can use this as an example in video 3 | |
const mapFunction = () => { | |
// this function will be called with the context of | |
// this locked to the record in iteration | |
emit(this.user_name, this.price) | |
} | |
// Video 3 | |
const reduceFunction = (key, values) => { | |
return values.reduce((a, b) => a + b) |
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
{ | |
"questions": { | |
"Onset Symptoms": [ | |
{ | |
"question": "Do you have a fever or a history of fever?", | |
"options": [ | |
"Yes", | |
"No", | |
"Unknown" | |
], |
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
import React, { PureComponent } from "react"; | |
// treating this as a parent component that has explicit knowledge of the presentation and behavior of it's | |
// children | |
class Dropdown extends PureComponent { | |
constructor(props) { | |
super(props); | |
this.state = { | |
isOpen: false, |
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
# example of using lookahead assertion to test password strength | |
# test if a given string contains at least a lowercase letter, a uppercase, a digit, a special char and 8+ chars | |
strong = "123ABCabc-" | |
strong[/^(?=.*[a-zA-Z])(?=.*[0-9])(?=.*[\W]).{8,}$/] | |
# test if a given string contains at least a lowercase letter, a uppercase, a digit and 8+ chars | |
medium = "123ABCabc" | |
medium[/^(?=.*[a-zA-Z])(?=.*[0-9]).{8,}$/] |
OlderNewer