Skip to content

Instantly share code, notes, and snippets.

View bsevgin's full-sized avatar
💣
ready to explode

Bünyamin Sevgin bsevgin

💣
ready to explode
  • Istanbul, Turkey
View GitHub Profile
@drewjoh
drewjoh / Cors.php
Created June 13, 2016 22:47
Laravel CORS Middleware
<?php // /app/Http/Middleware/Cors.php
namespace App\Http\Middleware;
use Closure;
class Cors {
public function handle($request, Closure $next)
{
return $next($request)
@statickidz
statickidz / nearby-coordinates.sql
Last active January 31, 2024 20:31
Ordering with SQL by nearest latitude & longitude coordinates (MySQL & SQLite)
---
METHOD 1
This should roughly sort the items on distance in MySQL, and should work in SQLite.
If you need to sort them preciser, you could try using the Pythagorean theorem (a^2 + b^2 = c^2) to get the exact distance.
---
SELECT *
FROM table
ORDER BY ((lat-$user_lat)*(lat-$user_lat)) + ((lng - $user_lng)*(lng - $user_lng)) ASC
@PurpleBooth
PurpleBooth / README-Template.md
Last active July 22, 2024 02:29
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@outman
outman / curl_post_file
Created December 6, 2012 07:26
upload file to server by curl post
Client
<?php
class HTTPClient {
function __construct($url, $port = 80)
{
$this->url = $url;
$this->port = $port;
}
@searbe
searbe / parse_xlsx.php
Created August 7, 2012 09:48
Parse simple XLSX in PHP with SimpleXML and ZipArchive
<?php
/**
* I had to parse an XLSX spreadsheet (which should damn well have been a CSV!)
* but the usual tools were hitting the memory limit pretty quick. I found that
* manually parsing the XML worked pretty well. Note that this, most likely,
* won't work if cells contain anything more than text or a number (so formulas,
* graphs, etc ..., I don't know what'd happen).
*/
@outman
outman / export_image_to_excel
Created August 3, 2012 01:02
Exprot Online Image to Excel by PHPExcel
<?php
require_once __DIR__ . '/PHPExcel/Classes/PHPExcel.php';
$objPHPExcel = new PHPExcel();
// imagecreatefromXXX (XXX is jpeg png or gif)
$gdImage = imagecreatefromjpeg('http://678bt.com/PHPExcel/Tests/images/officelogo.jpg');
$objDrawing = new PHPExcel_Worksheet_MemoryDrawing();