Skip to content

Instantly share code, notes, and snippets.

Avatar

Afshin Mehrabani afshinm

View GitHub Profile
View keybase.md

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 Mar 2, 2017
Monit configuration for MySQL and nginx on Ubuntu
View mysql.conf
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
View introjs-example-json.js
var intro = introJs();
intro.setOptions({
steps: [
{
intro: "Hello world!"
},
{
element: document.querySelector('#step1'),
intro: "This is a tooltip."
},
View flights.pro
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).
View a.json
{
"rating_value_fs": {
"type": "number"
},
"language_ss": {
"type": "string"
},
"review_text_en_s": {
"type": "string"
},
@afshinm
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
});
});
});
@afshinm
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) {
callback(connectionInstance);
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
afshinm / gist:5045272
Last active Dec 14, 2015
WebMaker.org has problem with Google Chrome?
View gist:5045272

##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 Feb 24, 2013
using PersianJs in ASP.NET web form
View gist:5023576
<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());
}
});
You can’t perform that action at this time.