Skip to content

Instantly share code, notes, and snippets.

View Mario-Duarte's full-sized avatar
:shipit:
Starting a new position

Mario Duarte Mario-Duarte

:shipit:
Starting a new position
View GitHub Profile
@Mario-Duarte
Mario-Duarte / share-urls.md
Created March 30, 2020 15:31 — forked from apisandipas/share-urls.md
Share url's for Facebook, Twitter, Pinterest and Linkedin with just get variables

Creating share buttons with just URL's

Twitter

http://twitter.com/share?text=<TITLE>&url=<URL>

E.g. http://twitter.com/share?text=This+is+google+a+search+engine&url=https%3A%2F%2Fwww.google.com

Facebook

http://www.facebook.com/sharer.php?u=&amp;p[title]=

@Mario-Duarte
Mario-Duarte / Markdown_Cheat_Sheet.MD
Created September 9, 2019 15:38
Simple markdown cheat sheet

Markdown Cheat Sheet

A simple cheat sheet for you day to day Markdown needs

Headers

# This is an <h1> tag
## This is an <h2> tag
@Mario-Duarte
Mario-Duarte / colliding.js
Created July 21, 2019 22:07 — forked from jtsternberg/colliding.js
Detect if two elements are colliding/overlapping
/**
* Detects if two elements are colliding
*
* Credit goes to BC on Stack Overflow, cleaned up a little bit
*
* @link http://stackoverflow.com/questions/5419134/how-to-detect-if-two-divs-touch-with-jquery
* @param $div1
* @param $div2
* @returns {boolean}
*/
@Mario-Duarte
Mario-Duarte / functions.php
Created January 29, 2019 23:17
Quick start functions.php for you WordPress installation
<?php
function wpEnqueueScripts(){
// Register styles
wp_enqueue_style("style.css", get_stylesheet_directory_uri() . "/css/style.css");
// Unregister wordpress vertion of jquery and add our Latest version
wp_deregister_script( 'jquery' );
wp_enqueue_script("jquery", get_stylesheet_directory_uri() . "/js/vendor/jquery.min.js");
@Mario-Duarte
Mario-Duarte / search_for_value.php
Created January 8, 2019 17:11 — forked from kjbrum/search_for_value.php
Check if a value exists in an array/object.
<?php
/**
* Check if an array is a multidimensional array.
*
* @param array $arr The array to check
* @return boolean Whether the the array is a multidimensional array or not
*/
function is_multi_array( $x ) {
if( count( array_filter( $x,'is_array' ) ) > 0 ) return true;
return false;
@Mario-Duarte
Mario-Duarte / request_no_curl.php
Created June 29, 2018 16:43 — forked from iNaD/request_no_curl.php
Sending a GET/POST Request via PHP without CURL (fopen needs to be enabled)
<?php
$url = 'http://server.com/path';
$data = array('key1' => 'value1', 'key2' => 'value2');
// use key 'http' even if you send the request to https://...
$options = array(
'http' => array(
'header' => "Content-type: application/x-www-form-urlencoded\r\n",
'method' => 'POST',
'content' => http_build_query($data),
@Mario-Duarte
Mario-Duarte / urlParam.js
Created May 11, 2018 09:00
jQuery plugin to get url parameters
$.urlParam = function(name){
var results = new RegExp('[\?&]' + name + '=([^]*)').exec(window.location.href);
if (results==null){
return null;
}
else{
return results[1] || 0;
}
}
@Mario-Duarte
Mario-Duarte / siblings.php
Created May 2, 2017 11:18
WORDPRESS function to get the sibling ID of a given post (grandparent id, greatparent id, etc)
// WORDPRESS function to get the sibling ID of a given post
// this was created to avoid using a repetition patern like:
// $current = $post->ID;
// $parent = $post->post_parent;
// $get_grandparent = get_post($parent);
// $grandparent = $get_grandparent->post_parent;
// $get_greatgrandparent = get_post($grandparent);
// $greatgrandparent = $get_greatgrandparent->post_parent;
// Like described in: http://andyweigel.com/great-grand-parent-ids-in-wordpress/
@Mario-Duarte
Mario-Duarte / .jshintrc
Last active October 8, 2018 10:29
Starter Gulpfile
{
"esversion": 6
}
@Mario-Duarte
Mario-Duarte / get_menu.php
Created January 3, 2017 12:14
WordPress function to get the menu items and wrap them in a before and after tag with an optional parameter for opening the same or new tab, usefull and light weight for when you have multiple menus within wordpress
function get_menu($menu, $before = "", $after = "", $blank = false) {
$menu_items = wp_get_nav_menu_items($menu);
foreach ($menu_items as $key => $menu_item) {
$title = $menu_item->title;
$url = $menu_item->url;
if ( $before === '' or $after === '') {
echo '<a href="' . $url . '">' . $title . '</a>';
} else {
echo $before . '<a href="' . $url . '">' . $title . '</a>' . $after;
}