This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function(){ | |
$('#getDatos').click(function(){ | |
$.ajax({ | |
url: 'consulta.php', | |
success: function(data){ | |
$("p").remove(); | |
console.log(data); //<=== Esta puede ser removida; | |
var datos = $.parseJSON(data); | |
console.log(datos); //<=== Esta puede ser removida; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!function_exists('get_similar_key')) { | |
/** | |
* Devuelve el elemento de un array que tenga la llave más parecida | |
* al string que le especifiquemos | |
* | |
* Uso: | |
* $array = ['azul' => 264, 'verde': 164, 'amarillo' => 25]; | |
* get_similar_key('azulado', $array); // 264 | |
* get_similar_key('casi verde', $array); // 164 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!function_exists('split_words')) { | |
/** | |
* Separa una oración en pedazos basado en un límite de letras, | |
* si existe un punto separa también | |
* | |
* Uso: | |
* $text = "Según The Hitchhiker's Guide to the Galaxy, un grupo de exploradores de una raza de seres pandimensionales e hiperinteligentes construyen Pensamiento Profundo, la segunda mejor computadora de todos los tiempos, para obtener la respuesta al sentido de la vida, el universo y todo lo demás. Después de siete millones y medio de años meditando la pregunta, Pensamiento Profundo declara que la respuesta es cuarenta y dos, razonando que la pregunta fue mal planteada y debe ser formulada correctamente para entender la respuesta."; | |
* split_words($text, 100); | |
* // Según The Hitchhiker's Guide to the Galaxy, un grupo de exploradores de una raza de seres pandimensionales e hiperinteligentes \n |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>JS Bin</title> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/3.0.3/normalize.min.css"> | |
<style id="jsbin-css"> | |
header { | |
padding: 60px 0; | |
text-align: center; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$text = 'Hola soy {name} y mi edad es {age}'; | |
$vars = [ | |
'name' => 'Daniel', | |
'age' => 16, | |
]; | |
foreach ($vars as $varKey => $varValue) { | |
$pattern = "/{{$varKey}}/"; | |
$text = preg_replace($pattern, $varValue, $text); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get Ingredients | |
window.ingredientsContainer = jQuery('.acf-field[data-name=ingredients]'); | |
window.editorContainer = jQuery("#wp-content-editor-container iframe").contents().find("body").get(0); | |
// Set time hold | |
window.timeHold = 3; | |
if (!window.editorContainer) { | |
console.error('TinyMCE is not here :('); | |
} | |
var ingredientsText = window.editorContainer.innerText.trim(); | |
console.log(ingredientsText) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Validates a .zip file with unzip | |
* @param string $filePath | |
* @return boolean | |
*/ | |
function validate($filePath) | |
{ | |
// File is valid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Say we have this table called selected_colors: | |
-- +----------------+ | |
-- | type | value | | |
-- +--------+-------+ | |
-- | blue | 1 | | |
-- | red | 4 | | |
-- | yellow | 8 | | |
-- | red | 12 | | |
-- | blue | 5 | | |
-- | blue | 0 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var helper = function (element) { | |
/** | |
* [private] Base HTML div | |
* @type {HTMLDivElement} | |
*/ | |
var element = element; | |
/** | |
* [public] Count of base element childrens | |
* @type {Number} |
OlderNewer