Skip to content

Instantly share code, notes, and snippets.

View mewben's full-sized avatar

Melvin Soldia mewben

View GitHub Profile
module.exports = {
get: function (req, res) {
res.sendfile(req.path.substr(1));
},
_config: {
rest: false,
shortcuts: false
}
};
// example.js
// ===============================
//
// Client-side (browser) example of how you might connect a socket.io client
// to your Sails backend.
// For the latest docs on talking to Sails via socket.io, check out the new reference section in the Sails docs:
// https://github.com/balderdashy/sails-docs/blob/master/reference/SocketClient.md
// As for some great tutorials, my best recommendation would be to check out @irlnathan's sailscasts:
@mewben
mewben / gist:2febd72fc82278a447b7
Created September 26, 2015 14:16 — forked from audy/gist:52215fc35ac163006f42
dokku postgresql rsync nightly backup

dokku postgresql rsync nightly backup

This is a rough guide to automating a nightly 7-day rolling remote backup of your PostgreSQL database(s) for your dokku app(s). There is a slight difference if you are using an older version of Dokku.

This will save the comprssed output of pg_dump as well as the contents of the /home directory on your dokku machine (just in case).

You will need to create a shell script in /root and edit the cron file.

@mewben
mewben / Makefile
Created October 7, 2015 05:10 — forked from lantins/Makefile
"Auto build & serve" of golang code :)
#
# Makefile to perform "live code reloading" after changes to .go files.
#
# n.b. you must install fswatch (OS X: `brew install fswatch`)
#
# To start live reloading run the following command:
# $ make serve
#
# binary name to kill/restart
@mewben
mewben / webdev_online_resources.md
Created July 17, 2018 13:31 — forked from bradtraversy/webdev_online_resources.md
Online Resources For Web Developers (No Downloading)
@mewben
mewben / rounding.java
Created August 23, 2018 15:55 — forked from aslakhellesoy/rounding.java
Rounding up and down to nearest multiple
/** round n down to nearest multiple of m */
long roundDown(long n, long m) {
return n >= 0 ? (n / m) * m : ((n - m + 1) / m) * m;
}
/** round n up to nearest multiple of m */
long roundUp(long n, long m) {
return n >= 0 ? ((n + m - 1) / m) * m : (n / m) * m;
}
@mewben
mewben / remove_documents_mongodb.js
Created February 13, 2019 13:10 — forked from Stoffo/remove_documents_mongodb.js
Remove Documents older than x days in MongoDB
var date = new Date();
var daysToDeletion = 120;
var deletionDate = new Date(date.setDate(date.getDate() - daysToDeletion));
printjson(deletionDate);
var db = db.getSiblingDB('db')
db.getMongo().setSlaveOk();
printjson(db.messages.find({insertDate : {$lt : deletionDate}}).count());
@mewben
mewben / building-sync-systems.md
Created December 15, 2023 15:37 — forked from pesterhazy/building-sync-systems.md
Building an offline realtime sync engine

So you want to write a sync system for a web app with offline and realtime support? Good luck. You might find the following resources useful.

Overview articles