Skip to content

Instantly share code, notes, and snippets.

View digitalhydra's full-sized avatar
💭
please don't turn this into The MS social network

Jairo Mejia digitalhydra

💭
please don't turn this into The MS social network
View GitHub Profile
$push-top:2rem;
.push-top{
margin-top: $push-top;
&.x2{ margin-top: $push-top*2;}
&.x3{ margin-top: $push-top*3;}
&.x4{ margin-top: $push-top*4;}
&.x5{ margin-top: $push-top*5;}
&.x6{ margin-top: $push-top*6;}
&.x7{ margin-top: $push-top*7;}
@digitalhydra
digitalhydra / center-poly.js
Created December 1, 2017 22:52
get center of polygon in google maps
var bounds = new google.maps.LatLngBounds();
var i;
// The Bermuda Triangle
var polygonCoords = [
new google.maps.LatLng(25.774252, -80.190262),
new google.maps.LatLng(18.466465, -66.118292),
new google.maps.LatLng(32.321384, -64.757370),
new google.maps.LatLng(25.774252, -80.190262)
];
/**
* Like get_template_part() put lets you pass args to the template file
* Args are available in the template as $template_args array
* @param string filepart
* @param mixed wp_args style argument list
*/
function hm_get_template_part( $file, $template_args = array(), $cache_args = array() ) {
@digitalhydra
digitalhydra / timezones.php
Created July 10, 2017 15:26
array de timezones para php
$timezones = array(
'Pacific/Midway' => "(GMT-11:00) Midway Island",
'US/Samoa' => "(GMT-11:00) Samoa",
'US/Hawaii' => "(GMT-10:00) Hawaii",
'US/Alaska' => "(GMT-09:00) Alaska",
'US/Pacific' => "(GMT-08:00) Pacific Time (US & Canada)",
'America/Tijuana' => "(GMT-08:00) Tijuana",
'US/Arizona' => "(GMT-07:00) Arizona",
'US/Mountain' => "(GMT-07:00) Mountain Time (US & Canada)",
'America/Chihuahua' => "(GMT-07:00) Chihuahua",
@digitalhydra
digitalhydra / HashTable.js
Created June 7, 2017 00:50 — forked from alexhawkins/HashTable.js
Correct Implementation of a Hash Table in JavaScript
var HashTable = function() {
this._storage = [];
this._count = 0;
this._limit = 8;
}
HashTable.prototype.insert = function(key, value) {
//create an index for our storage location by passing it through our hashing function
var index = this.hashFunc(key, this._limit);
@digitalhydra
digitalhydra / check_cat.php
Created May 2, 2017 00:53
check if product is in cat
if( has_term( array( 'laptop', 'fridge', 'hats', 'magic wand' ), 'product_cat' ) ) :
// Do stuff here
else :
// Do some other stuff
endif;
@digitalhydra
digitalhydra / functions.php
Created March 25, 2017 05:16 — forked from kloon/functions.php
WooCommerce 2.1 Add confirm password option at checkout
<?php
// place the following code in your theme's functions.php file
// Add a second password field to the checkout page.
add_action( 'woocommerce_checkout_init', 'wc_add_confirm_password_checkout', 10, 1 );
function wc_add_confirm_password_checkout( $checkout ) {
if ( get_option( 'woocommerce_registration_generate_password' ) == 'no' ) {
$checkout->checkout_fields['account']['account_password2'] = array(
'type' => 'password',
'label' => __( 'Confirm password', 'woocommerce' ),
'required' => true,
@digitalhydra
digitalhydra / aleatorio.php
Last active December 1, 2017 22:51
Ordenar productos de manera aleatoria en woocomerce
add_filter( 'woocommerce_get_catalog_ordering_args', 'custom_woocommerce_get_catalog_ordering_args' );
function custom_woocommerce_get_catalog_ordering_args( $args ) {
$orderby_value = isset( $_GET['orderby'] ) ? woocommerce_clean( $_GET['orderby'] ) : apply_filters( 'woocommerce_default_catalog_orderby', get_option( 'woocommerce_default_catalog_orderby' ) );
if ( 'random_list' == $orderby_value ) {
$args['orderby'] = 'rand';
$args['order'] = '';
$args['meta_key'] = '';
}
@digitalhydra
digitalhydra / gist:b745f7d1ad730ff5f8a814edec0fe2af
Created September 13, 2016 16:28 — forked from mikejolley/gist:3b37b9cc19a774665f31
Example instance based shipping method
<?php
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Sample instance based method.
*/
class WC_Shipping_Test_Method extends WC_Shipping_Method {
@digitalhydra
digitalhydra / paises-iso.php
Last active August 30, 2016 01:21 — forked from vxnick/gist:380904
Array of country codes (ISO 3166-1 alpha-2) and corresponding names
<?php
$countries = array
(
'AF' => 'Afghanistan',
'AX' => 'Aland Islands',
'AL' => 'Albania',
'DZ' => 'Algeria',
'AS' => 'American Samoa',
'AD' => 'Andorra',