Skip to content

Instantly share code, notes, and snippets.

View ProteanDev's full-sized avatar
🏠
Working from home

Chan D ProteanDev

🏠
Working from home
View GitHub Profile
(() => {
let count = 0;
function getAllButtons() {
return document.querySelectorAll('button.is-following') || [];
}
async function unfollowAll() {
const buttons = getAllButtons();
for (let button of buttons) {
count = count + 1;
@ProteanDev
ProteanDev / mongo-cheat-sheet.js
Created September 14, 2021 15:32 — forked from raineorshine/mongo-cheat-sheet.js
Cheat Sheet: MongoDB
/* COMMAND LINE */
mongod & // start mongo server on port 27017 by default
mongo mydb // launch mongo shell using the specified database
// importing & exporting
mongoimport -d mydb -c mycollection --jsonArray --file input.json
mongoimport -d mydb -c mycollection --headerline --type csv --file input.csv
mongoexport -d mydb -c mycollection --out output.json
/* MONGO SHELL */

Definitely not comprehensive. This is meant to be a basic memory aid with links to get more details. I'll add to it over time.

Install

$ npm install mongoose --save

Connect

const mongoose = require('mongoose');
// NOTE: if you save this into a file on your local machine you can run these using nodeJS on your terminal using this command:
// node [filename].js
// JAVASCRIPT CODING CHALLENGE 1
const people = [
{
name: "Arisa",
department: "BP",
gender: "F",

MongoDB Cheat Sheet

Show All Databases

show dbs

Show Current Database

@ProteanDev
ProteanDev / StronglyTypedIDs.swift
Created October 18, 2017 19:24
Strongly typed identifiers Cheat Sheet
struct Person {
struct Identifier: RawRepresentable, Hashable, Equatable {
let rawValue: String
init(rawValue: String) { self.rawValue = rawValue }
}
let id: Identifier
var name: String
var age: Int?
}
// Indigo Entertainment Exam for the 1000 size array
int[] _theArray = new int[1000];
for (int i = 1; i < 1000; i++)
{
int result;
bool divisibleBy2 = (i % 2) == 0;
bool divisibleBy3 = (i % 3) == 0;
if (divisibleBy2)