Skip to content

Instantly share code, notes, and snippets.

View YurePereira's full-sized avatar
😀
Out sick

Yure Pereira YurePereira

😀
Out sick
View GitHub Profile
@YurePereira
YurePereira / foreign_key_mysql.sql
Last active September 28, 2016 20:06
Using Foreign Key with MySql and Constraint
-- Using Foreign Key with MySql and Constraint:
alter table <name_table>
add constraint <fk_name_constraint_1>
foreign key (<column_name_this_table>)
references <table_references> (<column_name_table_references>);
-- Not tested:
alter table <name_table>
add constraint <fk_name_constraint>
@YurePereira
YurePereira / validate_document_cpf.php
Last active June 3, 2025 15:00
Validate CPF in PHP (Validar CPF em PHP).
<?php
/**
*
* Função que faz a validação de CPF, verificando se ele está no formato certo, exemplo 'xxx.xxx.xxx-xx' ou 'xxxxxxxxxxx', e se
* ele é válido, caso as duas verificação sejam verdadeiras será retornado TRUE ou FALSE caso contrario.
*
* @param c: String CNPJ a se validado.
* @return Boolean
*
@YurePereira
YurePereira / get_value_option.js
Created August 29, 2016 19:34
Get value of selected option
//Selector: #selector_id option:selected
var select = $('#selector_id option:selected');
console.log(select.text());
@YurePereira
YurePereira / capturing_enter_key_jquery.js
Last active September 1, 2016 15:51
Capturing enter key in jQuery
//With ternary operator:
$(document).keypress(function(e){
var keycode = e.keyCode ? e.keyCode : e.which;
if(keycode === 13){
//Code action here.
}
});
@YurePereira
YurePereira / csrf_with_codeigniter_example_1.php
Created September 1, 2016 19:34
Codeigniter: Getting Codeigniter CSRF token without form_close()
<?php
//Example: 1:
$csrf_token_name = $this->security->get_csrf_token_name();
$get_csrf_hash = $this->security->get_csrf_hash();
?>
<input
type="hidden"
@YurePereira
YurePereira / add_and_remove_attribute_class.js
Last active September 7, 2016 18:22
Add and remove attribute class.js
var attrClass = (function() {
var _element = null,
_listener = [];
var setElement = function(element) {
_element = element;
_listener = _element.className.split(' ');
};
@YurePereira
YurePereira / loading_image.js
Last active March 7, 2017 19:22
Loading process image
var j = jQuery.noConflict();
var loadingImage = (function ($) {
var loadImage = $('body img.load-image');
var configDefault = {
callbacks: {
show: function() {},
hide: function() {}
@YurePereira
YurePereira / hexa_html_to_decimal.php
Created October 6, 2016 15:43
Converte código HTML hexadecimal para decimal.
/**
* Converte código HTML hexadecimal para decimal.
*
* @param $code String código HTML hexadecimal.
*
* @return Array
*/
function hexaHtmlToDecimal($code) {
if (strlen($code) == 7) {
@YurePereira
YurePereira / mymodal.js
Created December 19, 2016 14:55
Modal with bootstrap
var MyModal = (function() {
var alert = function(options) {
var modalConfirm = $('#modal_alert'),
titleModal = modalConfirm.find('.title-modal')
messageModal = modalConfirm.find('.message-modal'),
buttonOk = modalConfirm.find('.model-button-ok');
titleModal.text(options.title);
@YurePereira
YurePereira / manipulacao_data_1.php
Created January 5, 2017 16:07
Exibição básica de data em PHP com a classe DateTime.
<?php
$dt = new DateTime();
echo $dt->format('Y-d-m');