Skip to content

Instantly share code, notes, and snippets.

View hperantunes's full-sized avatar

Hilton Perantunes hperantunes

  • Montreal, Canada
View GitHub Profile

HOMEWORK: HOMEWORK 3.3

Download and extract the json file in products.zip

Then perform the following in the terminal (or at the command prompt):

mongoimport -d pcat -c products --drop products.json

If that looks somewhat familiar, that's because it's (nearly) the same command you used to import the pcat.products collection for Homework 2.1, with the only difference in the command being that it will drop the collection if it's already present. This version of the collection, however, contains the state of the collection as it would exist once you've solved all of the homework of chapter 2.

HOMEWORK: HOMEWORK 3.2

In a mongo shell run homework.b(). This will run in an infinite loop printing some output as it runs various statements against the server.

We'll now imagine that on this system a user has complained of slowness and we suspect there is a slow operation running. Find the slow operation and terminate it.

In order to do this, you'll want to open a second window (or tab) and there, run a second instance of the mongo shell, with something like:

$ mongo --shell localhost/performance performance.js

HOMEWORK: HOMEWORK 3.1

Start a mongod server instance (if you still have a replica set, that would work too).

Next, download the handout and run:

mongo --shell localhost/performance performance.js
homework.init()

Build an index on the "active" and "tstamp" fields. You can verify that you've done your job with

var request = new XMLHttpRequest();
request.open('GET', '/bar/foo.txt', false); // `false` makes the request synchronous
request.send(null);
if (request.status === 200) {
console.log(request.responseText);
}
import { useEffect } from "react";
const useScript = (url) => {
useEffect(() => {
const script = document.createElement("script");
script.src = url;
script.async = true;
document.body.appendChild(script);
HttpUtility.ParseQueryString(Request.UrlReferrer?.Query ?? string.Empty)["lang"];
@hperantunes
hperantunes / disableBackHistory.js
Last active April 24, 2020 05:04
Disable page from going back in navigation history
history.pushState(null, document.title, location.href);
window.addEventListener('popstate', function (event) {
history.pushState(null, document.title, location.href);
});
tiddlywiki ~/projects/flwiki --listen port=2999
const pattern = /[^\d.,-]|[.,]{2,}|(?<=.)-/;
console.log("1-1".match(pattern));
const a = {
CoolButton: {
fr: "Omelette du fromage",
en: "Black pudding"
},
NotSoCoolButton: {
fr: "Une baguette",
en: "Apple pie"
}
};