Skip to content

Instantly share code, notes, and snippets.

View JalaliDate.js
// jalali date
JalaliDate = {
month_names: ["فروردین", "اردیبهشت", "خرداد", "تیر", "مرداد", "شهریور", "مهر", "آبان", "آذر", "دی", "بهمن", "اسفند"],
g_days_in_month: [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31],
j_days_in_month: [31, 31, 31, 31, 31, 31, 30, 30, 30, 30, 30, 29]
};
JalaliDate.jalaliToGregorian = function(j_y, j_m, j_d) {
j_y = parseInt(j_y);
j_m = parseInt(j_m);
j_d = parseInt(j_d);
View rank_metrics.py
"""Information Retrieval metrics
Useful Resources:
http://www.cs.utexas.edu/~mooney/ir-course/slides/Evaluation.ppt
http://www.nii.ac.jp/TechReports/05-014E.pdf
http://www.stanford.edu/class/cs276/handouts/EvaluationNew-handout-6-per.pdf
http://hal.archives-ouvertes.fr/docs/00/72/67/60/PDF/07-busa-fekete.pdf
Learning to Rank for Information Retrieval (Tie-Yan Liu)
"""
import numpy as np
@farnabaz
farnabaz / randomColor.swift
Created Oct 13, 2015
Generate random UIColor in swift
View randomColor.swift
/* usage:
* UIColor.randomColor()
*/
extension UIColor {
class func randomColor() -> UIColor{
let r:CGFloat = CGFloat(drand48())
let g:CGFloat = CGFloat(drand48())
let b:CGFloat = CGFloat(drand48())
return UIColor(red: r, green: g, blue: b, alpha: 1.0)
@farnabaz
farnabaz / spinner.html
Last active Sep 21, 2015
Simple Number Spinner with jQuery & Font-Awesome. DEMO: http://codepen.io/farnabaz/pen/xwOPVR
View spinner.html
<span class="spinner">
<i class="fa fa-chevron-up" onclick="var el = $(this).siblings('input')[0]; el.value = Math.min(5, parseInt(el.value)+1)"></i>
<input type="text" name="day" value="0">
<i class="fa fa-chevron-down" onclick="var el = $(this).siblings('input')[0]; el.value = Math.max(0, parseInt(el.value)-1)"></i>
</span>
<style>
.spinner {
position: relative;
display: inline-block;
}
View gist:4eb4c265020ff3bea2a9
# Persian Lorem Ipsum
'.text, .source':
'Lorem Ipsum':
'prefix': "لورم"
'body' : "لورم ایپسوم متن ساختگی با تولید سادگی نامفهوم از صنعت چاپ و با استفاده از طراحان گرافیک است. چاپگرها و متون بلکه روزنامه و مجله در ستون و سطرآنچنان که لازم است و برای شرایط فعلی تکنولوژی مورد نیاز و کاربردهای متنوع با هدف بهبود ابزارهای کاربردی می باشد."
@farnabaz
farnabaz / gist:d4bdee0f51a890b2266b
Created May 23, 2015
Simple Angular timer filter
View gist:d4bdee0f51a890b2266b
// usage {{ 122 | timer }}
.filter("timer", function () {
return function (time) {
var sec = time % 60,
min = parseInt(time/60) % 60,
hou = parseInt(time/3600) % 60
sec < 10 && (sec = '0'+sec)
min < 10 && (min = '0'+min)
hou < 10 && (hou = '0'+hou)
@farnabaz
farnabaz / arrow.fabric.js
Created May 22, 2015
fabric.js arrow shape
View arrow.fabric.js
//
// Arrow for fabric.js
//
(function($){
$.Arrow = $.util.createClass($.Line, $.Observable, {
initialize: function(e,t) {
this.callSuper("initialize", e, t)
this.set({type:'arrow'});
},
_render: function(e) {