Skip to content

Instantly share code, notes, and snippets.

View alireza-ahmadi's full-sized avatar

Alireza Ahmadi alireza-ahmadi

View GitHub Profile
@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 |
@abhishekdev
abhishekdev / com.edb.launchd.postgresql-9.1.plist
Created March 2, 2012 19:56
Disable/Enable PostgreSQL Autostart on Mac OS X Lion
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Disabled</key>
<false/>
<key>Label</key>
<string>com.edb.launchd.postgresql-9.1</string>
<key>ProgramArguments</key>
@paolorossi
paolorossi / html5-video-streamer.js
Created March 7, 2012 13:21
Node.js HTML5 video streamer
/*
* Inspired by: http://stackoverflow.com/questions/4360060/video-streaming-with-html-5-via-node-js
*/
var http = require('http'),
fs = require('fs'),
util = require('util');
http.createServer(function (req, res) {
var path = 'video.mp4';
@geta6
geta6 / partial.coffee
Created September 27, 2012 10:13
response partial content in node.js
#
# blob : Object from MongoDB
#
# blob.body: Buffer
# blob.size: length of buffer, substitute for blob.body.length
# blob.type: MIME (Eg. audio/x-wav)
#
# req : Object from http
# res : Object from http
# _ : Object from underscore
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
@desandro
desandro / require-js-discussion.md
Created January 31, 2013 20:26
Can you help me understand the benefit of require.js?

I'm having trouble understanding the benefit of require.js. Can you help me out? I imagine other developers have a similar interest.

From Require.js - Why AMD:

The AMD format comes from wanting a module format that was better than today's "write a bunch of script tags with implicit dependencies that you have to manually order"

I don't quite understand why this methodology is so bad. The difficult part is that you have to manually order dependencies. But the benefit is that you don't have an additional layer of abstraction.


@ospatil
ospatil / Gruntfile.js
Last active March 9, 2020 14:26
Yeoman + Angular + Express = Full-stack
'use strict';
module.exports = function (grunt) {
// load all grunt tasks
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
// configurable paths
var yeomanConfig = {
app: 'app',
dist: 'dist'
@plentz
plentz / nginx.conf
Last active April 24, 2024 11:15
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@JoelBesada
JoelBesada / README.md
Last active October 14, 2022 04:20
Backtick Example Command

This is an example command for Backtick. A Backtick command consists of some executable JavaScript and a bit of metadata in JSON.

Here are the required steps to create a command:

  1. Create a new Gist with a command.js and command.json file, or simply fork this one.

  2. Write your JavaScript in command.js. This will be injected into and executed on the page the user is currently on when they run it.

  3. Add some metadata to the command.json file:

  • name: The name of the command.