Skip to content

Instantly share code, notes, and snippets.

View weidali's full-sized avatar
⌨️

Vitaliy weidali

⌨️
  • Moscow, Russia
View GitHub Profile
@azagniotov
azagniotov / beautiful.rest.api.docs.in.markdown.md
Last active July 22, 2024 18:34
Example to create beautiful REST API docs in Markdown, inspired by Swagger API docs.
@jeffochoa
jeffochoa / Response.php
Last active May 22, 2024 04:06
Laravel HTTP status code
<?php
// This can be found in the Symfony\Component\HttpFoundation\Response class
const HTTP_CONTINUE = 100;
const HTTP_SWITCHING_PROTOCOLS = 101;
const HTTP_PROCESSING = 102; // RFC2518
const HTTP_OK = 200;
const HTTP_CREATED = 201;
const HTTP_ACCEPTED = 202;
@CMCDragonkai
CMCDragonkai / bisecting_binary_search.php
Last active April 2, 2023 01:57
PHP: Bisect Left & Bisect Right using Binary Search (similar to Python's bisect_left & bisect_right). Binary search only works on sorted arrays. Arrays must be first sorted with quick sort. Bisect right finds the index of a value where all the elements from left to right up to the index is less or equal to the value: Array: [1, 1, 2, 2, 3, 4] Va…
<?php
// sorted array must be a 0 indexed
// left most index, right most index all inclusive
// finds all of the elements coming from the left to the right that is less or equal to the key
function bisect_right($sorted_array, $key, $left = null, $right = null){
if(is_null($left)){
reset($sorted_array);
$left = key($sorted_array);
@ranacseruet
ranacseruet / VideoStream.php
Last active June 17, 2024 11:54
PHP VideoStream class for HTML5 video streaming
<?php
/**
* Description of VideoStream
*
* @author Rana
* @link http://codesamplez.com/programming/php-html5-video-streaming-tutorial
*/
class VideoStream
{
private $path = "";
@jaywilliams
jaywilliams / csv_to_array.php
Created April 30, 2010 23:18
Convert a comma separated file into an associated array.
<?php
/**
* Convert a comma separated file into an associated array.
* The first row should contain the array keys.
*
* Example:
*
* @param string $filename Path to the CSV file
* @param string $delimiter The separator used in the file
* @return array