Skip to content

Instantly share code, notes, and snippets.

View alireza-ahmadi's full-sized avatar

Alireza Ahmadi alireza-ahmadi

View GitHub Profile
@reshadman
reshadman / Loop.java
Created May 3, 2015 17:15
Simple loop in programming languages -- for permance benchmarking of a WHILE LOOP --
public class Loop {
public static void main(String[] args)
{
Integer total = 500000000;
Integer chunk = 50000000;
Integer i = 0;
var spawn = require('child_process').spawn;
worker = spawn('node',['worker.js']);
worker.stdout.on('data',function(data){
console.log('worker sent:',data.toString());
});
@xcambar
xcambar / LICENSE
Last active November 20, 2015 12:57
Authenticated routing using AngularJS
Copyright (c) 2015 - Xavier Cambar <@ xcambar_gmail.com>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
@mauricecruz
mauricecruz / Custom.css
Last active January 2, 2016 23:28
Zero Dark Matrix Theme for v.32.0.1700
/*****************************************************************************/
/* Zero-Dark-Matrix
/* Optimized for Chrome Stable Channel v32.0.1700
/* https://github.com/mauricecruz/chrome-devtools-zerodarkmatrix-theme
/*************************************************************************/
/**********************************************
/* Animations
/* -------------------------------------------
/* If you are experiencing performance issues,
/* remove the animations section below.
@lyndell
lyndell / by.sh
Last active July 10, 2016 02:49
Open a new file in ByWord
#/bin/bash -x
#
# Copyright (c) 2015 Lyndell Rottmann
#
# Debug mode on/off: (default off)
set +x
if [[ "$OSTYPE" == "darwin"* ]]; then
if [ ! $1 ]
@benyaminsalimi
benyaminsalimi / Flask-raspberryPi-GPIO-camera-model.py
Created September 15, 2016 17:42
simple RestApi for RaspberryPi RPIO & camera model with flask
# BPi restFull-api by @BenyaminSalimi
# you can see log of this program in "BPi.log"
from flask import Flask,jsonify,send_file
import picamera
import time
import RPi.GPIO as GPIO
app = Flask(__name__)
@aaronthorp
aaronthorp / mail-sendgrid.js
Last active November 9, 2017 03:23
SMTP via SendGrid using Email package with Meteor
if (Meteor.isServer) {
Meteor.startup(function () {
process.env.MAIL_URL = 'smtp://username:password@smtp.sendgrid.net';
Accounts.emailTemplates.siteName = "My Website Name";
Accounts.emailTemplates.from = "My Website Name <noreply@mywebsite.com>";
Accounts.emailTemplates.resetPassword.subject = function(user) {
return "How to reset your password for My Website Name";

Private members in ES6 classes

"Let's create an ES6 class!" you say. "Let's give it a private variable x."

class Foo {
  constructor(x) {
    this.x = x;
  }
  getX() {
@latompa
latompa / bayesian rating
Created January 8, 2009 01:02
bayesian rating
-- building on data from my scenario http://gist.github.com/44489
-- and bayesian rating http://www.thebroth.com/blog/118/bayesian-rating
assume we have a products table and we want to sort products based on their rating.
With bayesian rating, you get better weighting, so that a single 5 star vote won't show up as "top product"
select * from products;
mysql> select * from products;
+------+--------+---------------+--------------+---------+
| id | name | ratings_count | total_rating | weight |
@ratik
ratik / disableAllMethods.js
Last active October 12, 2018 09:52
LoopbackJs disable all remote methods and enable only selected
/**
* Based on @ericprieto code https://github.com/strongloop/loopback/issues/651#issuecomment-140879983
* place this file into common/mixins/disableAllMethods.js
*
**/
module.exports = function(Model, options) {
if(Model && Model.sharedClass) {
var methodsToExpose = options.expose || [];