Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am afshinm on github.
  • I am afshinmeh (https://keybase.io/afshinmeh) on keybase.
  • I have a public key ASBU6wKVVsdRJH9Ecn99A266KVt_N18VKcC-W2XC6sjx5Qo

To claim this, I am signing this object:

@afshinm
afshinm / mysql.conf
Last active March 2, 2017 14:52
Monit configuration for MySQL and nginx on Ubuntu
check process mysqld with pidfile /var/run/mysqld/mysqld.pid
group database
start program = "/etc/init.d/mysql start"
stop program = "/etc/init.d/mysql stop"
if failed host 127.0.0.1 port 3306 then restart
if 5 restarts within 5 cycles then timeout
var intro = introJs();
intro.setOptions({
steps: [
{
intro: "Hello world!"
},
{
element: document.querySelector('#step1'),
intro: "This is a tooltip."
},
flight(london,dublin,aerlingus,500,45,150).
flight(rome,london,ba,1500,150,400).
flight(rome,paris,airfrance,1200,120,500).
flight(paris,dublin,airfrance,600,60,200).
flight(berlin,moscow,lufthansa,3000,300,900).
flight(paris,amsterdam,airfrance,400,30,100).
flight(berlin,dublin,lufthansa,1200,120,900).
flight(london,newyork,ba,5000,700,1100).
flight(dublin,newyork,aerlingus,4500,360,800).
flight(dublin,cork,ryanair,300,50,50).
{
"rating_value_fs": {
"type": "number"
},
"language_ss": {
"type": "string"
},
"review_text_en_s": {
"type": "string"
},
@afshinm
afshinm / example-connection.js
Created April 5, 2013 11:03
Example of MongoDb singleton connection
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
});
});
});
@afshinm
afshinm / mongodb-singleton.js
Created April 5, 2013 10:57
MongoDb singleton connection in NodeJs
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) {
callback(connectionInstance);
@afshinm
afshinm / javascript-false-expressions.markdown
Created March 5, 2013 08:48
JavaScript false expressions

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
afshinm / gist:5045272
Last active December 14, 2015 06:49
WebMaker.org has problem with Google Chrome?

##WebMaker.org has problem with Google Chrome.

If you try to open https://webmaker.org/ 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) {

while(1);

@afshinm
afshinm / gist:5023576
Created February 24, 2013 12:04
using PersianJs in ASP.NET web form
<script type="text/javascript" src="scripts/persian.js"></script>
<asp:TextBox ID="TextBox1" runat="server" Text = "" ForeColor = "Gray"></asp:TextBox>
<div id="output"></div>
<script type="text/javascript">
$("#<%=TextBox1.ClientID%>").keypress(function () {
if ($("#<%=TextBox1.ClientID%>").val() != "") {
console.log("key pressed");
$("#output").html(persianJs($("#<%=TextBox1.ClientID%>").val()).englishNumber());
}
});