Skip to content

Instantly share code, notes, and snippets.

Avatar
👋

Massimiliano Marcon mmarcon

👋
View GitHub Profile
@mmarcon
mmarcon / mongosh-fle-local-kms.js
Last active Feb 17, 2021
Simple mongosh script to insert a document into MongoDB with Client-side Field-level Encryption and a local KMS.
View mongosh-fle-local-kms.js
// To run this script you can start the shell with `mongosh --nodb`
// Wrap everything into a function so we don't
// affect the shell's scope
(function insertTestData() {
// Config DB and Collection names
const dbName = '<TEST_DBNAME>';
const collectionName = '<TEST_COLLNAME>';
const mongoDBConnectionString = '<MONGODB_CONNECTION_STRING>';
@mmarcon
mmarcon / mongosh-fle-gcp-kms.js
Last active Feb 17, 2021
Simple mongosh script to insert a document into MongoDB with Client-side Field-level Encryption and KMS in GCP.
View mongosh-fle-gcp-kms.js
// To run this script you can start the shell with `mongosh --nodb`
// Wrap everything into a function so we don't
// affect the shell's scope
(function insertTestData() {
// Config DB and Collection names
const dbName = '<TEST_DBNAME>';
const collectionName = '<TEST_COLLNAME>';
const mongoDBAtlasConnectionString = '<MONGODB_ATLAS_CONNECTION_STRING>';
View sales.mongodb.js
// MongoDB Playground
// To disable this template go to Settings | MongoDB | Use Default Template For Playground.
// Make sure you are connected to enable completions and to be able to run a playground.
// Use Ctrl+Space inside a snippet or a string literal to trigger completions.
// Select the database to use.
use('mongodbVSCodePlaygroundDB');
// The drop() command destroys all data from a collection.
// Make sure you run it against proper database and collection.
@mmarcon
mmarcon / youtube-helium.js
Last active Nov 11, 2016
A bookmarklet to convert youtube video links into links that can be opened with Helium on macOS (http://heliumfloats.com/)
View youtube-helium.js
[].slice.apply(document.querySelectorAll('.yt-lockup-title a.spf-link')).forEach(l => {const h = l.getAttribute('href'); l.setAttribute('href', `helium://https://www.youtube.com${h}`)})
View Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "ubuntu/trusty64"
config.vm.network "forwarded_port", guest: 80, host: 8080
# No need to sync the vagrant folder, everything gets deployed
# with the ansible playbook
View playbook.yml
- name: link to Keymetrics
command: pm2 link {{ keymetrics_secret_key }} {{ keymetrics_public_key }}
when: keymetrics
become: yes
become_user: apps
ignore_errors: yes
View playbook.yml
tasks:
- name: install nginx
apt: name=nginx state=present update_cache=yes
notify:
- start nginx
- name: configure nginx
copy: src={{ item }} dest=/etc/nginx/sites-available/
with_fileglob:
- ./nginx/*
notify:
View app.conf
location /app {
proxy_pass http://localhost:3001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
View default
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
View app.conf
location /app {
proxy_pass http://localhost:3001;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}