Skip to content

Instantly share code, notes, and snippets.

View leocaseiro's full-sized avatar
💭
I',m probably studying...

Leo Caseiro leocaseiro

💭
I',m probably studying...
View GitHub Profile
@leocaseiro
leocaseiro / class-wp-cpt-plugin-base-singleton.php
Created August 20, 2014 01:23
WordPress Plugin with Custom Post and Metabox using Singleton
<?php
if ( !class_exists('Primped_Base_Singleton') ):
abstract class Primped_Base_Singleton {
/**
* Parsed options for module
*
* @var array
(function($) {
if ($.fn.style) {
return;
}
// Escape regex chars with \
var escape = function(text) {
return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
};
//Usage
try {
$(window).on('load', function() {
equalize_height($('#parent'), '.element');
});
$(window).resize(function(){
equalize_height($('#parent'), '.element');
});
} catch(err) {console.log(err);}
@leocaseiro
leocaseiro / add_hours.js
Created July 31, 2014 23:22
Add Hours to Javascript Time
function addHourTo(start, duration) {
start = start.split(':');
duration = duration.split(':');
totalHours = parseInt(start[0], 10) + parseInt(duration[0], 10);
totalMinutes = parseInt(start[1], 10) + parseInt(duration[1], 10);
if (totalMinutes >= 60) {
totalMinutes -= 60;
totalHours += 1;
functions.php
<?php
function my_custom_queries($query) {
//Never in admin mode, only the main query(the URL one) and in this case on custom post 'event'
if ( !is_admin() && $query->is_main_query() && $query->is_post_type_archive('event')) {
$paged = ( get_query_var( 'page' ) ) ? absint( get_query_var( 'page' ) ) : 1; //URL /page
@leocaseiro
leocaseiro / jquery-ui-sortable-remove-dragged-item-out.js
Created July 4, 2014 00:12
jQuery UI Sortable Remove Dragged Item out
$( "#sortable" ).sortable({
forcePlaceholderSize: true,
tolerance: 'pointer',
cursor: 'pointer',
over: function () {
removeIntent = false;
},
out: function () {
removeIntent = true;
},
@leocaseiro
leocaseiro / hosts
Last active August 29, 2015 14:03
Apache PHP VHOSTS on Maverick 10.9
## /private/etc/hosts
#
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
@leocaseiro
leocaseiro / datetime.php
Created June 25, 2014 06:51
Create timestamp from dd/mm/yyyy H:m with PHP >= 5.3
<?php
$datetime = '01/06/1985 15:45';
$timestamp = DateTime::createFromFormat('d/m/Y H:i', $datetime)->getTimestamp();
echo $timestamp;
$datetime = date('d-m-Y H:i', $timestamp);
var_dump($datetime);
@leocaseiro
leocaseiro / leocaseiro.terminal
Created June 24, 2014 04:49
Mac My Own Terminal
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>BackgroundAlphaInactive</key>
<real>0.73665552745664742</real>
<key>BackgroundBlur</key>
<real>0.091763005780346824</real>
<key>BackgroundColor</key>
<data>
function codeAddress(address) {
geocoder = new google.maps.Geocoder();
geocoder.geocode({
'address': address
}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
var myOptions = {
zoom: 14,
center: results[0].geometry.location,
disableDoubleClickZoom: true, //not zoom