Skip to content

Instantly share code, notes, and snippets.

# common
ufw allow ssh
ufw allow ftp
ufw allow 22
ufw allow from 15.15.15.0/24 to any port 22
ufw allow from 15.15.15.0/24 to any port 873
# ssl and http
ufw allow http
ufw allow https
@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 / 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 / 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 / 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 / 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",
var parseConfig;
var yourobj = {
_otherMethod: function() {
var text = this._requestText();
},
_requestText: function() {
var url = 'config.json';
$.ajax({
type: 'GET',
url: url,