Skip to content

Instantly share code, notes, and snippets.

@gabouh
gabouh / .gitignore
Created Jan 6, 2019 — forked from madzak/.gitignore
Sample Application using Module, Facade, and Mediator Patterns
@gabouh
gabouh / README.md
Created Dec 30, 2018 — forked from jimothyGator/README.md
Nginx configuration for Mac OS X with Homebrew, using sites-enabled directory.
View README.md
mkdir -p /usr/local/etc/nginx/sites-{enabled,available}
cd /usr/local/etc/nginx/sites-enabled
ln -s ../sites-available/default.conf
ln -s ../sites-available/default-ssl.conf

File locations:

  • nginx.conf to /usr/local/etc/nginx/
  • default.conf and default-ssl.conf to /usr/local/etc/nginx/sites-available
  • homebrew.mxcl.nginx.plist to /Library/LaunchDaemons/
@gabouh
gabouh / generate_cert.sh
Created Dec 28, 2018 — forked from alexgorbatchev/generate_cert.sh
Generate self signed https certificates for node.js express/hapi/etc
View generate_cert.sh
#!/bin/bash
openssl genrsa -out key.pem
openssl req -new -key key.pem -out csr.pem
openssl x509 -req -days 9999 -in csr.pem -signkey key.pem -out cert.pem
rm csr.pem
@gabouh
gabouh / export-chrome-bookmarks.js
Created Nov 26, 2018 — forked from bgrins/export-chrome-bookmarks.js
Reminder of how to export bookmarks from Chrome as text.
View export-chrome-bookmarks.js
/*
Export bookmarks from Chrome as text.
Go to Bookmarks Manager->Organize->Export to HTML file.
Then open that file, open console and run this command:
*/
[].map.call(document.querySelectorAll("dt a"), function(a) {
return a.textContent + " - " + a.href
}).join("\n");
View sql-mongo_comparison.md

SQL to MongoDB Mapping Chart

SQL to MongoDB Mapping Chart

In addition to the charts that follow, you might want to consider the Frequently Asked Questions section for a selection of common questions about MongoDB.

Executables

The following table presents the MySQL/Oracle executables and the corresponding MongoDB executables.

View import_json_appsscript.js
/**
* Retrieves all the rows in the active spreadsheet that contain data and logs the
* values for each row.
* For more information on using the Spreadsheet API, see
* https://developers.google.com/apps-script/service_spreadsheet
*/
function readRows() {
var sheet = SpreadsheetApp.getActiveSheet();
var rows = sheet.getDataRange();
var numRows = rows.getNumRows();
@gabouh
gabouh / retrieve-indexeddb-file-create-object-url.js
Created May 28, 2018 — forked from robnyman/retrieve-indexeddb-file-create-object-url.js
Retrieve stored file from IndexedDB and create an ObjectURL
View retrieve-indexeddb-file-create-object-url.js
// Retrieve the file that was just stored
transaction.objectStore("elephants").get("image").onsuccess = function (event) {
var imgFile = event.target.result;
console.log("Got elephant!" + imgFile);
// Get window.URL object
var URL = window.URL || window.webkitURL;
// Create and revoke ObjectURL
var imgURL = URL.createObjectURL(imgFile);
@gabouh
gabouh / IndexedDB-storing-and-retrieving-files.js
Created May 6, 2018 — forked from tantaman/IndexedDB-storing-and-retrieving-files.js
Download an image, save it to IndexedDB, read it out, display the image via createObjectURL - works in Chrome and Firefox. Based on https://hacks.mozilla.org/2012/02/storing-images-and-files-in-indexeddb/ but with fixes made for Chrome.
View IndexedDB-storing-and-retrieving-files.js
(function () {
// IndexedDB
function BrowserType() {
var n = navigator.appName;
var ua = navigator.userAgent;
var tem;
var m = ua.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i);
if (m && (tem = ua.match(/version\/([\.\d]+)/i)) != null) m[2] = tem[1];
m = m ? [m[1], m[2]] : [n, navigator.appVersion, '-?'];
@gabouh
gabouh / PoorMansCodeEditor.html
Created Feb 26, 2018 — forked from deanebarker/PoorMansCodeEditor.html
Poor man's code editor in pure JavaScript.
View PoorMansCodeEditor.html
<!--
This is a textarea that:
(1) Is styled(-ish) like a code editor
(2) Catches tabs and converts them to four (4) spaces
(3) Duplicates leading spaces from the last line
(4) Auto-expands to input
Pure inline HTML and JavaScript. No external dependencies. Has issues pre-IE-8, but should be otherwise okay.
@gabouh
gabouh / vesta-user-fix-permission.sh
Created Oct 11, 2017 — forked from 0x00dec0de/vesta-user-fix-permission.sh
Fix user permissions to vesta control panel
View vesta-user-fix-permission.sh
#!/bin/bash
cd /home/
for i in `ls | grep -v 'lost+found'`; do
if id "$i" &>/dev/null ; then
chattr -i /home/$i/conf
chown -R ${i}:${i} $i
chown root:root /home/$i/conf
chown root:root /home/$i/conf/*
chown root:bind /home/$i/conf/dns/* &>/dev/null
chown Debian-exim:mail /home/$i/conf/mail/* &>/dev/null