Skip to content

Instantly share code, notes, and snippets.

View diogenesjup's full-sized avatar
🏠
Working from home

Diogenes Oliveira Junior diogenesjup

🏠
Working from home
View GitHub Profile
@diogenesjup
diogenesjup / gist:be0db0925970e45816814778794d2ed6
Created September 23, 2016 10:28 — forked from thegdshop/gist:3171026
WooCommerce - Add checkbox field to the checkout
<?php
/**
* Add checkbox field to the checkout
**/
add_action('woocommerce_after_order_notes', 'my_custom_checkout_field');
function my_custom_checkout_field( $checkout ) {
echo '<div id="my-new-field"><h3>'.__('My Checkbox: ').'</h3>';
@diogenesjup
diogenesjup / wordpress-create-user.php
Created January 20, 2017 16:22
Create a user in WordPress from a php page/script outside of the WordPress system.
<?php
// [wp insert user « WordPress Codex](http://codex.wordpress.org/Function_Reference/wp_insert_user)
require_once "wordpress/wp-load.php";
$user_info = array(
"user_pass" => "test123",
"user_login" => "username",
"user_nicename" => "username",
"user_email" => "[email protected]",
@diogenesjup
diogenesjup / bin-cc.md
Created October 27, 2017 00:48 — forked from erikhenrique/bin-cc.md
Bin de cartões de crédito para validação

Validação para cartão de crédito.

Bin e padrões para validação de cartão de crédito.

Bandeira Começa com Máximo de número Máximo de número cvc
Visa 4 13,16 3
Mastercard 5 16 3
@diogenesjup
diogenesjup / gist:f45adf670c87b18368dd6970392bc934
Created January 29, 2018 12:33 — forked from psdtohtml5/gist:5908031
jQuery: Drag and scroll horizontal div
<script type="text/javascript">
$(document).ready(function() {
$('.dragger').mousedown(function (event) {
$(this)
.data('down', true)
.data('x', event.clientX)
.data('scrollLeft', this.scrollLeft)
.addClass("dragging");
return false;
@diogenesjup
diogenesjup / wc_order_status_changes.php
Created May 27, 2018 03:22 — forked from abegit/wc_order_status_changes.php
WooCommerce Hooks for Order Status Changes
function mysite_pending($order_id) {
error_log("$order_id set to PENDING", 0);
}
function mysite_failed($order_id) {
error_log("$order_id set to FAILED", 0);
}
function mysite_hold($order_id) {
error_log("$order_id set to ON HOLD", 0);
}
function mysite_processing($order_id) {
@diogenesjup
diogenesjup / sqlsrv_test.php
Created October 9, 2019 00:57 — forked from MCF/sqlsrv_test.php
PDO sqlsrv PHP driver, connect and query SQL Server database - reduced test case.
<?php
$serverName = "sqlserver.example.com";
$database = "myDbName";
$uid = 'sqlserver_username';
$pwd = 'password';
try {
$conn = new PDO(
"sqlsrv:server=$serverName;Database=$database",
$uid,
@diogenesjup
diogenesjup / distance.sql
Created March 8, 2020 23:42 — forked from Usse/distance.sql
MySQL calculate distance between two latitude/longitude coordinates
CREATE FUNCTION `lat_lng_distance` (lat1 FLOAT, lng1 FLOAT, lat2 FLOAT, lng2 FLOAT)
RETURNS FLOAT
DETERMINISTIC
BEGIN
RETURN 6371 * 2 * ASIN(SQRT(
POWER(SIN((lat1 - abs(lat2)) * pi()/180 / 2),
2) + COS(lat1 * pi()/180 ) * COS(abs(lat2) *
pi()/180) * POWER(SIN((lng1 - lng2) *
pi()/180 / 2), 2) ));
END
@diogenesjup
diogenesjup / git.md
Created May 2, 2020 15:49 — forked from leocomelli/git.md
Lista de comandos úteis do GIT

GIT

Estados

  • Modificado (modified);
  • Preparado (staged/index)
  • Consolidado (comitted);

Ajuda

@diogenesjup
diogenesjup / gist:9f45072cf19a9c8b42c4ac17ba7aa5f5
Created May 13, 2020 14:17 — forked from jorgeguberte/gist:1275767
Cálculo de diferença de dias javascript
//Substituir por valores reais.
var data1 = new Date('YYYY', 'MM','DD');
var data2 = new Date('YYYY', 'MM','DD');
var diferenca = parseInt((data1-data2)/(24*3600*1000));
@diogenesjup
diogenesjup / remover-acentos.js
Created February 8, 2021 11:32 — forked from marioplumbarius/remover-acentos.js
Funcao marota para remover acentos de strings. Foi utilizado expressao regular em cima de caracteres representados na base hexadecimal.
/**
* Remove acentos de caracteres
* @param {String} stringComAcento [string que contem os acentos]
* @return {String} [string sem acentos]
*/
function removerAcentos( newStringComAcento ) {
var string = newStringComAcento;
var mapaAcentosHex = {
a : /[\xE0-\xE6]/g,
e : /[\xE8-\xEB]/g,