Skip to content

Instantly share code, notes, and snippets.

View aliirz's full-sized avatar
🦄
People over Processes

Ali Raza aliirz

🦄
People over Processes
View GitHub Profile
MAX_DISTANCE_AWAY_IN_KM = 100.0
RAD_PER_DEG = 0.017453293
Rmiles = 3956 # radius of the great circle in miles
Rkm = 6371 # radius in kilometers, some algorithms use 6367
Rfeet = Rmiles * 5282 # radius in feet
Rmeters = Rkm * 1000 # radius in meters
def haversine_distance( lat1, lon1, lat2, lon2 )
dlon = lon2 - lon1
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
/* */
/* Simple node js module to get distance between two coordinates. */
/* */
/* Code transformed from Chris Veness example code - please refer to his website for licensing */
/* questions. */
/* */
/* */
/* Latitude/longitude spherical geodesy formulae & scripts (c) Chris Veness 2002-2011 */
/* - www.movable-type.co.uk/scripts/latlong.html */
@aliirz
aliirz / UIImage+Tools.h
Created January 18, 2014 14:28
UIIMage+Tools
//
// UIImage+Tools.h
// FTLibrary
//
// Created by Ondrej Rafaj on 26/09/2011.
// Copyright (c) 2011 Fuerte International. All rights reserved.
//
#import <UIKit/UIKit.h>
@aliirz
aliirz / EmailValidator.js
Created November 5, 2013 11:53
Javascript email validation checker
tab.emailValidation = function checkMail(email) {
var filter = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
if (filter.test(email)) {
return true;
}
return false;
};
@aliirz
aliirz / localstorage.js
Created November 4, 2013 12:54
Using Local storage or jquery cookie
tab.Storage = _.extend({
setItem: function (itemID, value) {
if('localStorage' in window && window['localStorage'] !== null){
localStorage.setItem(itemID, value);
}else{
$.cookie(itemID, value, { path: '/' });
}
},
getItem: function (itemID) {
if('localStorage' in window && window['localStorage'] !== null){
@aliirz
aliirz / JSON-Output
Last active December 27, 2015 07:48
API Output
[
{"id":0,"startDate":"04/11/2013","serviceID":241,"providerID":223,"timeSlots":["09:00","10:00","11:00","12:00","13:00","14:00","15:00","16:00"]},
{"id":0,"startDate":"05/11/2013","serviceID":241,"providerID":223,"timeSlots":["09:00","10:00","11:00","12:00","13:00","14:00","15:00","16:00"]},{"id":0,"startDate":"06/11/2013","serviceID":241,"providerID":223,"timeSlots":["09:00","12:00","13:00","14:00","15:00","16:00"]},{"id":0,"startDate":"07/11/2013","serviceID":241,"providerID":223,"timeSlots":["09:00","10:00","11:00","12:00","13:00","14:00","15:00","16:00"]},{"id":0,"startDate":"08/11/2013","serviceID":241,"providerID":223,"timeSlots":["09:00","10:00","11:00","12:00","13:00","14:00","15:00","16:00"]},{"id":0,"startDate":"11/11/2013","serviceID":241,"providerID":223,"timeSlots":["09:00","10:00","11:00","12:00","13:00","14:00","15:00","16:00"]},{"id":0,"startDate":"12/11/2013","serviceID":241,"providerID":223,"timeSlots":["09:00","10:00","11:00","12:00","13:00","14:00","15:00","16:00"]}]
@aliirz
aliirz / Controller.cs
Created September 14, 2013 15:33
MVC File Upload Example
[Authorize(Roles = "Manager")]
public ActionResult Logo()
{
return View();
}
[Authorize(Roles = "Manager")]
[HttpPost]
public ActionResult Logo(HttpPostedFileBase file)
{
<!-- using the truncate filter -->
{% for post in site.posts limit:10 %}
<h2><a href="{{ post.url }}">{{ post.title }}</a></h2>
<span class="post-date">{{ post.date | date: "%B %d, %Y" }}</span>
{% if post.content.size > 2000 %}
{{ post.content | truncatewords: 300 }} <!-- bad! content gives you rendered html and you will truncate in the middle of a node -->
<a href="{{ post.url }}">read more</a>
{% else %}
{{ post.content }}
{% endif %}
@aliirz
aliirz / deploy.rb
Created July 28, 2013 15:26
My deploy script for rails websites
require "bundler/capistrano"
server "<Server-name>", :web, :app, :db, primary: true
set :application, "<Site-Name>"
set :user, "deployer"
set :deploy_to, "/home/#{user}/apps/#{application}"
set :deploy_via, :remote_cache
set :use_sudo, false
@aliirz
aliirz / unicorn_init
Created July 28, 2013 15:25
unicorn_init.sh for websites
#!/bin/sh
### BEGIN INIT INFO
# Provides: unicorn
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Manage unicorn server
# Description: Start, stop, restart unicorn server for a specific application.
### END INIT INFO