Skip to content

Instantly share code, notes, and snippets.

View calevano's full-sized avatar
🍕
eating pizza and being happy making code.

Carlos Levano calevano

🍕
eating pizza and being happy making code.
View GitHub Profile
@calevano
calevano / php mb_ucfirst
Created March 23, 2020 17:44
Perform a word ucfirst in php with special characters to UTF-8. Example: área to Área
if (!function_exists('mb_ucfirst')) {
/**
* @param $str
* @param string $encoding
* @param bool $lower_str_end
* @return string
*/
function mb_ucfirst($str, $encoding = "UTF-8", $lower_str_end = false)
{
$first_letter = mb_strtoupper(mb_substr($str, 0, 1, $encoding), $encoding);
@calevano
calevano / array_multidimensional.php
Created August 19, 2019 23:51
search value in array multidimensional
$key = array_search('100', array_column($userdb, 'uid'));
@calevano
calevano / order_array_to_value
Created August 19, 2019 18:13
Array order to value
$new = [
[
'hashtag' => 'a7e87329b5eab8578f4f1098a152d6f4',
'title' => 'Flower',
'order' => 3,
],
[
'hashtag' => 'b24ce0cd392a5b0b8dedc66c25213594',
'title' => 'Free',
@calevano
calevano / removeIndexArray.js
Created May 16, 2018 16:44
function to remove index in array
function remove(array, element) {
const index = array.indexOf(element);
if (index !== -1) {
array.splice(index, 1);
}
}
@calevano
calevano / execute_search_key_list_store_procedure.sql
Created February 21, 2018 00:03
Search definition in Store Procedure in sqlServer
SELECT
ROUTINE_NAME ,ROUTINE_DEFINITION
FROM
INFORMATION_SCHEMA.ROUTINES
WHERE
ROUTINE_DEFINITION LIKE '%Letter%'
AND ROUTINE_TYPE = 'PROCEDURE'
ORDER BY ROUTINE_NAME
@calevano
calevano / openModal.js
Last active January 30, 2018 16:08
Create simple openModal
#In view
<a href="[_route_]"
class="btn btn btn-success btn-circle btn-xs zmdi zmdi-edit"
data-toggle='modal'
data-target="#openModal"
data-tamanio='lg'>
</a>
#OpenModal
@calevano
calevano / ChangeColumnLength
Created December 26, 2017 19:59
Laravel 5.2 Console Comand, Alter table with arguments, options... php artisan change-column-table [argument] [--options]
public function handle()
{
$tableName = $this->argument('table');
if ($tableName != null) {
$table = Schema::hasTable($tableName);
if ($table) {
$columnName = $this->option('column');
if ($columnName != null) {
$column = Schema::hasColumn($tableName, $columnName);
if ($column) {
<?hp
function url_amigable($url) {
//$urlMinuscula = strtolower($url);
$buscarLetra = array('Á', 'É', 'Í', 'Ó', 'Ú', 'Ñ', 'á', 'é', 'í', 'ó', 'ú', 'ñ');
$reemplazar = array('A', 'E', 'i', 'O', 'U', 'N', 'a', 'e', 'i', 'o', 'u', 'n');
$urlNueva = str_replace($buscarLetra, $reemplazar, $url);
$buscarCaracteres = array(' ', '&', '\r\n', '\n', '+');
$urlAceptable = str_replace($buscarCaracteres, ' ', $urlNueva);
//$find = array('/[^a-z0-9\-<>]/', '/[\-]+/', '/<[^>]*>/');
//$repl = array('', '-', '');
@calevano
calevano / distritos.sql
Created July 20, 2017 05:26
Tabla de Distrito asociado a una provincia
INSERT INTO `distritos` (`id`, `distrito`, `provincia_id`) VALUES
(1, 'CHACHAPOYAS', 1),
(2, 'ASUNCION', 1),
(3, 'BALSAS', 1),
(4, 'CHETO', 1),
(5, 'CHILIQUIN', 1),
(6, 'CHUQUIBAMBA', 1),
(7, 'GRANADA', 1),
(8, 'HUANCAS', 1),
(9, 'LA JALCA', 1),
@calevano
calevano / provincias.sql
Created July 20, 2017 05:23
Tabla de Provincias asociados a una region
INSERT INTO `provincias` (`id`, `provincia`, `region_id`) VALUES
(1, 'CHACHAPOYAS ', 1),
(2, 'BAGUA', 1),
(3, 'BONGARA', 1),
(4, 'CONDORCANQUI', 1),
(5, 'LUYA', 1),
(6, 'RODRIGUEZ DE MENDOZA', 1),
(7, 'UTCUBAMBA', 1),
(8, 'HUARAZ', 2),
(9, 'AIJA', 2),