Skip to content

Instantly share code, notes, and snippets.

@grosscorporation
grosscorporation / mongodb-s3-backup.sh
Last active August 9, 2019 01:12 — forked from eladnava/mongodb-s3-backup.sh
Automatically backup a MongoDB database to S3 using mongodump, tar, and awscli (Ubuntu 14.04 LTS)
#!/bin/sh
# Make sure to:
# 1) Name this file `backup.sh` and place it in /home/ubuntu
# 2) Run sudo apt-get install awscli to install the AWSCLI
# 3) Run aws configure (enter s3-authorized IAM user and specify region)
# 4) Fill in DB host + name
# 5) Create S3 bucket for the backups and fill it in below (set a lifecycle rule to expire files older than X days in the bucket)
# 6) Run chmod +x backup.sh
# 7) Test it out via ./backup.sh
@grosscorporation
grosscorporation / 1.mongodb-aws-setup-guide.md
Created December 25, 2018 07:23 — forked from calvinh8/1.mongodb-aws-setup-guide.md
MongoDB Setup Guide for AWS EC2 Instances with Auth Enabled
@grosscorporation
grosscorporation / dropall.js
Created February 28, 2018 16:42 — forked from cschlyter/dropall.js
MongoDB: Drop all mongodb databases
// Usage: $ mongo dropAll.js
var dbs = db.getMongo().getDBNames()
for(var i in dbs){
db = db.getMongo().getDB( dbs[i] );
print( "dropping db " + db.getName() );
db.dropDatabase();
@grosscorporation
grosscorporation / mongodb_searchAll.js
Created December 8, 2017 03:19 — forked from fkiller/mongodb_searchAll.js
This is a set of functions to search entire DB by simple keyword. If you need to find something from any records from any collections that you don't remember names, just load this functions and `searchAll('any keyword')` in Mongo console.
/************************************************************************
* This is a set of functions to search entire DB by simple keyword. *
* *
* Developered by Won Dong(fkiller@gmail.com) *
* *
* * Usage: searchAll('any keyword') *
* *
*************************************************************************/
function createOR(fieldNames, keyword) {
@grosscorporation
grosscorporation / sample.js
Created December 5, 2017 02:48 — forked from pulkitsinghal/sample.js
Validate X-Parse-Session-Token in NodeJS before calling background jobs
var deferred = q.defer();
request.get({
url: 'https://api.parse.com/1/users/me', // validate session token
headers: {
'X-Parse-Session-Token': req.header('X-Parse-Session-Token'),
'X-Parse-Application-Id': 'secret',
'X-Parse-REST-API-Key': 'secret'
}
},
@grosscorporation
grosscorporation / app.js
Created November 23, 2017 11:52 — forked from eleda/app.js
06 Handlebars
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var hbs = require('express-handlebars');
var index = require('./routes/index');
var users = require('./routes/users');
@grosscorporation
grosscorporation / angularjs_directive_attribute_explanation.md
Created September 27, 2017 18:04 — forked from CMCDragonkai/angularjs_directive_attribute_explanation.md
JS: AngularJS Directive Attribute Binding Explanation

AngularJS Directive Attribute Binding Explanation

When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.

  1. Raw Attribute Strings

    <div my-directive="some string" another-param="another string"></div>
@grosscorporation
grosscorporation / gross-bootstrap-config.json
Last active August 7, 2017 10:38 — forked from anonymous/config.json
Bootstrap Customizer Config
{
"vars": {
"@gray-base": "#000",
"@gray-darker": "lighten(@gray-base, 13.5%)",
"@gray-dark": "lighten(@gray-base, 20%)",
"@gray": "lighten(@gray-base, 33.5%)",
"@gray-light": "lighten(@gray-base, 46.7%)",
"@gray-lighter": "lighten(@gray-base, 93.5%)",
"@brand-primary": "darken(#428bca, 6.5%)",
"@brand-success": "#5cb85c",
@grosscorporation
grosscorporation / app.js
Last active January 24, 2017 01:15 — forked from cgkio/app.js
Parse Sever Upload photo
Parse.initialize("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX", "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX");
var file;
function fileSelected() {
var file = document.getElementById('fileToUpload').files[0];
if (file) {
var fileSize = 0;
if (file.size > 1024 * 1024)
@grosscorporation
grosscorporation / importParseJson.js
Created January 24, 2017 00:29 — forked from pascalgiguere/importParseJson.js
Node.js script using the Parse REST API to import a JSON file to Parse. Useful when dropping an entire class then reloading it from a JSON backup (Parse export). Will also update pointers of a second Parse class pointing to the imported class so that pointers don't break despite the imported data having different objectIds.
var PARSE_APPLICATION_ID = '';
var PARSE_REST_API_KEY = '';
var JSON_FILE_PATH = ''; // Path to JSON file to import
var IMPORTED_CLASS_NAME = ''; // Class to import
var POINTING_CLASS_NAME = ''; // Class with pointers to imported class
var POINTING_CLASS_PROPERTY = ''; // Name of pointer property
var request = require('request');
var fs = require('fs');