Skip to content

Instantly share code, notes, and snippets.

View leowebguy's full-sized avatar

Leo Leoncio leowebguy

View GitHub Profile
@leowebguy
leowebguy / fancybox.js
Last active February 18, 2020 15:27
fancybox + iframe with device size > screen detection and resize.
var width = window.innerWidth;
$(document).ready(function() {
$(".fancybox").fancybox({
beforeShow : function() {
var alt = "Watch more <a href='mypage.html'>videos</a>";
this.title = alt;
},
helpers : {
title: {
@leowebguy
leowebguy / wp_config.php
Created May 4, 2016 19:56
WordPress wp_config with Tweaks
<?php
/** The name of the database for WordPress */
define('DB_NAME', 'mydb_wp1');
define('DB_USER', 'mydb_usr1');
define('DB_PASSWORD', 'lalalalala');
define('DB_HOST', 'localhost');
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', '');
@leowebguy
leowebguy / bash_profile.sh
Created May 4, 2016 19:37
My bash_profile for linux
export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\$ "
export CLICOLOR=1
export LSCOLORS=ExFxBxDxCxegedabagacad
alias ls='ls -GFh'
# alias ls='ls --color'
# Aliases
# alias ls='ls -al'
# alias pl='pwd; ls'
@leowebguy
leowebguy / scripts.js
Created April 14, 2016 15:05
open a centered pop-up window, sending arguments url, title, width, height
/*
usage > centerPop('http://mypage.com/','mypage','575','440');"
*/
function centerPop(url, title, w, h) {
var dualScreenLeft = window.screenLeft != undefined ? window.screenLeft : screen.left;
var dualScreenTop = window.screenTop != undefined ? window.screenTop : screen.top;
var width = window.innerWidth ? window.innerWidth : document.documentElement.clientWidth ? document.documentElement.clientWidth : screen.width;
var height = window.innerHeight ? window.innerHeight : document.documentElement.clientHeight ? document.documentElement.clientHeight : screen.height;
@leowebguy
leowebguy / functions.php
Created April 11, 2016 17:46
Here is a hook to add the featured image to your rss feed on WordPress
/*********** ADD IMAGES TO RSS FEED
you can set the position of the image changing the order like this
$content = $content . get_the_post_thumbnail( $post->ID, 'thumbnail' );
*/
function featured_images_rss($content) {
global $post;
if ( has_post_thumbnail( $post->ID ) ){
$content = get_the_post_thumbnail( $post->ID, 'thumbnail' ) . $content;
}
@leowebguy
leowebguy / _mixins.scss
Last active February 1, 2016 01:24
Complete Sass mixin for Bootstrap 3 Projects > media queries, transitions, border-radius, box-shadow, rotate, scale, translate, skew, translate3d, opacity...
/******************
Sass Processor */
@mixin processor($function, $params) {
-webkit-#{$function}: $params;
-moz-#{$function}: $params;
-ms-#{$function}: $params;
-o-#{$function}: $params;
#{$function}: $params;
}
@leowebguy
leowebguy / medium-xml-reader.php
Last active January 17, 2016 23:50
A simple php code to read medium.com xml rss feed and return data (title, content, image, date) into a page
<div class="content">
<h3>MEDIUM POSTS</h3>
<div class="row">
<?php
$xml = simplexml_load_file('https://medium.com/feed/@leowebdev', null, LIBXML_NOCDATA);
function get_image($handler) { //get image from post body
preg_match('/src="([^"]*)"/', $handler, $matches);
return str_replace('/600/200/','/300/150/',$matches[1]); //change image size from 600x200 into 300x150
}
@leowebguy
leowebguy / functions.php
Created January 16, 2016 04:49
wordpress change/add post types on default theme search
add_filter('pre_get_posts','search_filter', 99); //use 99 to override/priorize this filter
function search_filter( $query )
{
if ( $query->is_search )
{
//use this for more than one post type;
$query->set( 'post_type', array('post','page','jobpost') );
//use this (uncomment) for only one post type
//$query->set( 'post_type', 'post' );
@leowebguy
leowebguy / scripts.js
Last active January 16, 2016 04:52
Textbox validation with jQuery (required field)
$(document).ready(function () {
$('#submit').click(function (e) {
var isValid = true;
$('#firstname,#lastname,#email,#password').each(function () {
if ($.trim($(this).val()) == '')
{
isValid = false;
$(this).css({
"border": "1px solid red",
"background": "#FFCECE"
@leowebguy
leowebguy / functions.php
Created December 14, 2015 14:18
Remove core updates notice in WordPress
function remove_core_updates(){
global $wp_version;return(object) array('last_checked'=> time(),'version_checked'=> $wp_version,);
}
add_filter('pre_site_transient_update_core','remove_core_updates');
add_filter('pre_site_transient_update_plugins','remove_core_updates');
add_filter('pre_site_transient_update_themes','remove_core_updates');