Skip to content

Instantly share code, notes, and snippets.

@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');
@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)
var parseConfig;
var yourobj = {
_otherMethod: function() {
var text = this._requestText();
},
_requestText: function() {
var url = 'config.json';
$.ajax({
type: 'GET',
url: url,
@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 / 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 / index.html
Last active October 3, 2017 18:18
Gross UI
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>GistRun</title>
<link rel="stylesheet" href="styles.css">
</head>
<body class="ks-navbar-fixed ks-sidebar-empty ks-sidebar-position-fixed ks-page-header-fixed ks-theme-primary ks-page-loading {{title}}">
<!-- BEGIN HEADER -->
@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 / bytesToSize.js
Created December 3, 2017 17:07
convert bytes to readable string
function bytesToSize(bytes) {
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB']
if (bytes === 0) return 'n/a'
const i = parseInt(Math.floor(Math.log(bytes) / Math.log(1024)), 10)
if (i === 0) return `${bytes} ${sizes[i]})`
return `${(bytes / (1024 ** i)).toFixed(1)} ${sizes[i]}`
}
@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 / 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();