Skip to content

Instantly share code, notes, and snippets.

View toanalien's full-sized avatar
🎯
Focusing

Thiên Toán toanalien

🎯
Focusing
View GitHub Profile
@toanalien
toanalien / cli.sh
Created September 4, 2017 14:52
setup loopback cli
$ npm install -g loopback-cli
@toanalien
toanalien / step1.sh
Created September 4, 2017 14:51
loopback create app
$ lb
? What's the name of your application? hello-world
? Enter name of the directory to contain the project: hello-world
? Which version of LoopBack would you like to use? 3.x (current)
? What kind of application do you have in mind? hello-world (A project containing a controller,
including a single vanilla Message and a single remote method)
...
I'm all done. Running npm install for you to install the required dependencies.
If this fails, try running the command yourself.
@toanalien
toanalien / request-example.js
Created August 19, 2017 14:47
request example
// Be sure to run "npm install request" in this directory
// before running this script
var request = require('request');
request('http://www.cjs.vn/', function(error, response, body) {
if (!error && response.statusCode === 200) {
console.log(body);
}
});
@toanalien
toanalien / one-2.js
Last active August 19, 2017 14:34
import module
var count = 2;
var doIt = function(i, callback) {
callback(null, i * 2);
}
module.exports.doIt = doIt;
module.exports.foo = 'bar';
@toanalien
toanalien / build-ins.js
Created August 19, 2017 14:07
build-ins.js
var os = require('os');
var toMb = function(f) {
return(Math.round((f/1024/1024)*100)/100);
}
console.log('Host: ' + os.hostname());
console.log('15 min. load average: ' + os.loadavg()[2]);
console.log(toMb(os.freemem()) + ' of ' + toMb(os.totalmem()) + ' Mb free');
# generated from http://pgtune.leopard.in.ua/
max_connections = 1000
shared_buffers = 6GB
effective_cache_size = 18GB
work_mem = 6291kB
maintenance_work_mem = 1536MB
min_wal_size = 2GB
max_wal_size = 4GB
checkpoint_completion_target = 0.9
sudo apt-get install virtualenv python-pip libpq-dev python-dev
cd
virtualenv pgadmin4
cd pgadmin4
source bin/activate
pip install https://ftp.postgresql.org/pub/pgadmin/pgadmin4/v1.6/pip/pgadmin4-1.6-py2.py3-none-any.whl
echo "SERVER_MODE = False" >> lib/python2.7/site-packages/pgadmin4/config_local.py
DATABASE_POOL_ARGS = {
'max_overflow': os.environ.get('max_overflow', 220), #please don't remove this.
'pool_size': os.environ.get('pool_size', 28),
'recycle': 300
}
@toanalien
toanalien / url_to_drive.js
Created June 15, 2017 08:12 — forked from denilsonsa/url_to_drive.js
Google Apps Script to upload a file from an URL directly to Google Drive.
// url_to_drive.gs
// Google Apps Script
// Allows uploading a URL directly to Google Drive.
//
// Live link:
// https://script.google.com/macros/s/AKfycbzvhbHS4hnWPVBDHjQzZHA0qWq0GR-6hY7TbYsNto6hZ0MeAFZt/exec
//
// Source-code:
// https://gist.github.com/denilsonsa/8134679
// https://script.google.com/d/1Ye-OEn1bDPcmeKSe4gb0YSK83RPMc4sZJt79SRt-GRY653gm2qVUptoE/edit
@toanalien
toanalien / slugify.js
Created June 6, 2017 10:01 — forked from mathewbyrne/slugify.js
Javascript Slugify
function slugify(text)
{
return text.toString().toLowerCase()
.replace(/\s+/g, '-') // Replace spaces with -
.replace(/[^\w\-]+/g, '') // Remove all non-word chars
.replace(/\-\-+/g, '-') // Replace multiple - with single -
.replace(/^-+/, '') // Trim - from start of text
.replace(/-+$/, ''); // Trim - from end of text
}