Skip to content

Instantly share code, notes, and snippets.

View kuroisuna's full-sized avatar
🐕
Probably working with javascript 🤔

Axel García kuroisuna

🐕
Probably working with javascript 🤔
  • Santiago, Chile
View GitHub Profile
@kuroisuna
kuroisuna / response_macros_service_provider.php
Created September 15, 2016 18:30
LARAVEL: Nicer responses with Response Macros
<?php
/** USAGE:
* return response()->success($data);
* return response()->notFound();
* return response()->created($createdResource);
* return response()->error($errorMessage, $errorCode);
*/
use Symfony\Component\HttpFoundation\Response as ResponseCode;
@kuroisuna
kuroisuna / run_cdm_command.php
Last active September 15, 2016 22:10
PHP: Executes a console command and returns success or failure
<?php
/**
* Validates a .zip file with unzip
* @param string $filePath
* @return boolean
*/
function validate($filePath)
{
// File is valid
@kerimdzhanov
kerimdzhanov / random.js
Last active September 21, 2024 11:44
JavaScript: get a random number from a specific range
/**
* Get a random floating point number between `min` and `max`.
*
* @param {number} min - min number
* @param {number} max - max number
* @return {number} a random floating point number
*/
function getRandomFloat(min, max) {
return Math.random() * (max - min) + min;
}