Skip to content

Instantly share code, notes, and snippets.

@mosufy
mosufy / MySQL-Nearby-Radial-Distance.md
Last active August 29, 2015 14:05
Fetch places of interest within radial distance using Haversine formula.

MySQL Nearby Radial Distance

Fetch places of interest within $dist (radial distance) of $fLat (latitude) and $fLon (longitude) using Haversine formula.

SELECT name,
  ACOS( SIN( RADIANS( `lat` ) ) * SIN( RADIANS( $fLat ) ) + COS( RADIANS( `lat` ) )
  * COS( RADIANS( $fLat )) * COS( RADIANS( `lon` ) - RADIANS( $fLon )) ) * 6380 AS `distance`
FROM `places_of_interests`
WHERE
@mosufy
mosufy / VirtualBox-Setup-Guide.md
Last active August 29, 2015 14:06
Create your own virtual linux box on your current OS Windows

VirtualBox Setup Guide

A VirtualBox is the best way to allow for local development for your web projects. Easily mimic an exact replica of your actual physical remote servers (or that of any cloud hosting providers) and test out your development frameworks before pushing it to your production or staging environments.

Warning: This guide is only meant to serve local installation of a virtual machine and not meant for 'live' or remote actual servers.

VirtualBox Setup

  1. Download and Install VirtualBox from Oracle website https://www.virtualbox.org/wiki/Downloads
@mosufy
mosufy / LEMP-Stack-Installation-Guide.md
Last active August 14, 2023 17:03
LEMP Stack Installation Guide. Linux (Ubuntu), Nginx, MySQL, PHP

LEMP Stack Installation Guide

LEMP is the new LAMP. If you were an Apache user like most of us, simply follow this guide to easily deploy and learn develop to develop on Nginx.

Pre-requisites

Be sure that you are already running Linux be it Ubuntu, CentOS or RHEL. However, this guide will demonstrate installation guide for Ubuntu Server 14.04 LTS.

Step 1. Install Nginx

@mosufy
mosufy / Setup-Local-Development-Server.md
Last active August 29, 2015 14:06
Setup Local Development Server Environment (LEMP on VirtualBox)

Setup Local Development Server Environment

Be sure to have VirtualBox Setup and LEMP Stack installed on it before proceeding. Also ensure your guest (VirtualBox) have access to host's (your computer) Shared folder (You can find the instructions on VirtualBox Setup Guide.

Pre-requisite: Shared Folders Setup

Having a Shared Folder will allow your guest (the VirtualBox) access to any folders on your host. A simple use case is to allow your local development folder access to guest. Simply change the files on this folder to update your web app. This step is optional but is highly encouraged.

Step 1. Declare shared folder (on Host machine)

  1. Create a folder on Host machine
@mosufy
mosufy / Install-phpMyAdmin-LEMP.md
Last active August 29, 2015 14:06
phpMyAdmin Installation Guide on LEMP Stack

phpMyAdmin Installation Guide (LEMP)

phpMyAdmin provides a popular an easy to use open-source MySQL management GUI.

  1. Install phpMyAdmin

     $ sudo apt-get update
     $ sudo apt-get install phpmyadmin
    

When prompted for server type, hit tab and choose neither one.

@mosufy
mosufy / Install-Composer.md
Created September 15, 2014 05:39
Composer Installation Guide

Install Composer

Composer is a dependency management tool for your PHP projects.

  1. Install PHP5 CLI

     $ sudo apt-get install php5-cli
    
  2. Get the Composer installer

@mosufy
mosufy / routes.php
Last active August 29, 2015 14:07 — forked from coreymcmahon/routes.php
Returns response for export in CSV format for laravel
<?php
/**
* Returns response in CSV format
*
* Call this class from Controller as below
* return Response::csv($data, $filename);
*/
Response::macro('csv', function($data, $filename = 'data.csv', $status = 200, $delimiter = ",", $linebreak = "\n", $headers = array())
{
@mosufy
mosufy / git-push-to-deploy.md
Last active August 29, 2015 14:13
Git Push to deploy setup

Setup GIT push-to-deploy

Push to remote repo will automagically update the files.

  1. Set-up bare git on remote

     $ cd /var/www/{appfolder}
     $ sudo mkdir .git
     $ cd .git
    

$ sudo git init --bare

@mosufy
mosufy / Vagrant-LEMP-ubuntu.sh
Created January 20, 2015 05:38
Vagrant LEMP Stack Installation Bash Script for Ubuntu 14.0.4
#!/usr/bin/env bash
# Variables
APPNAME=appname
DBHOST=localhost
DBNAME=db_app
DBUSER=user1
DBPASSWD=password1
# Update the box
@mosufy
mosufy / default-server-block-Nginx-LEMP
Created January 20, 2015 05:40
Default Server Block for NGINX in LEMP Stack Configuration
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.php index.html index.htm;
server_name localhost;
location / {