Skip to content

Instantly share code, notes, and snippets.

afshinm / mongodb-singleton.js
Created Apr 5, 2013
MongoDb singleton connection in NodeJs
View mongodb-singleton.js
var Db = require('mongodb').Db;
var Connection = require('mongodb').Connection;
var Server = require('mongodb').Server;
//the MongoDB connection
var connectionInstance;
module.exports = function(callback) {
//if already we have a connection, don't connect to database again
if (connectionInstance) {
afshinm / bootstrap.messagebox.js
Created Oct 8, 2012
Twitter Bootstrap Message Box Plugin
View bootstrap.messagebox.js
(function ($) {
/* Twitter Bootstrap Message Helper
** Usage: Just select an element with `alert` class and then pass this object for options.
** Example: $("#messagebox").message({text: "Hello world!", type: "error"});
** Author: Afshin Mehrabani <>
** Date: Monday, 08 October 2012
$.fn.message = function(options) {
//remove all previous bootstrap alert box classes
this[0].className = this[0].className.replace(/alert-(success|error|warning|info)/g , '');

Keybase proof

I hereby claim:

  • I am afshinm on github.
  • I am afshinmeh ( on keybase.
  • I have a public key ASBU6wKVVsdRJH9Ecn99A266KVt_N18VKcC-W2XC6sjx5Qo

To claim this, I am signing this object:

afshinm / mysql.conf
Last active Mar 2, 2017
Monit configuration for MySQL and nginx on Ubuntu
View mysql.conf
check process mysqld with pidfile /var/run/mysqld/
group database
start program = "/etc/init.d/mysql start"
stop program = "/etc/init.d/mysql stop"
if failed host port 3306 then restart
if 5 restarts within 5 cycles then timeout
View introjs-example-json.js
var intro = introJs();
steps: [
intro: "Hello world!"
element: document.querySelector('#step1'),
intro: "This is a tooltip."
View a.json
"rating_value_fs": {
"type": "number"
"language_ss": {
"type": "string"
"review_text_en_s": {
"type": "string"
afshinm / example-connection.js
Created Apr 5, 2013
Example of MongoDb singleton connection
View example-connection.js
var mongoDbConnection = require('./lib/connection.js');
exports.index = function(req, res, next) {
mongoDbConnection(function(databaseConnection) {
databaseConnection.collection('collectionName', function(error, collection) {
collection.find().toArray(function(error, results) {
//blah blah
View javascript-false-expressions.markdown

If you put these expressions in your condition (Or somehow the condition equals to one of these), you will get false in JavaScript:

  • false
  • undefined
  • null
  • 0
  • ""
  • NaN
afshinm / gist:5045272
Last active Dec 14, 2015 has problem with Google Chrome?
View gist:5045272 has problem with Google Chrome.

If you try to open in your Google Chrome browser, you probably see "Aw, Snap!" page. Chrome suddenly crashed.

If you open this page, exactly in Mozilla Firefox, it works like a charm.

So, is that something like this in their code?

if(isGoogleChrome) {