Skip to content

Instantly share code, notes, and snippets.

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

Sebastian Ortiz dsebao

🏠
Working from home
View GitHub Profile
@spsaucier
spsaucier / gist:6044023
Created July 20, 2013 05:52
jQuery - Form Validation without PHP
jQuery(document).ready(function(){
function randomgen()
{
var rannumber='';
for(ranNum=1; ranNum<=6; ranNum++){
rannumber+=Math.floor(Math.random()*10).toString();
}
$('#verifyNum').html(rannumber);
$('#verifyNumHidden').val(rannumber);
}
@paulund
paulund / html-email-boilerplate.html
Created July 4, 2013 13:49
A boilerplate when working with HTML emails.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title><?php echo $subject; ?></title>
<style type="text/css">
#outlook a {padding:0;}
body{width:100% !important; -webkit-text-size-adjust:100%; -ms-text-size-adjust:100%; margin:0; padding:0;}
.ExternalClass {width:100%;}
@joyrexus
joyrexus / jq_vs_js.md
Last active April 12, 2025 09:10
Comparison of jQuery and vanilla JS for basic DOM manipulation.

jQuery vs native JS

Selecting Elements

var divs = $("div");

var divs = document.querySelectorAll("div");
@jasdeepkhalsa
jasdeepkhalsa / facebook.html
Last active December 15, 2015 19:09
Get back the latest post from a Facebook page by Jasdeep Khalsa
<div id="fb-text">Like us on Facebook for the very latest updates, exclusives, offers and competitions!</div>
@l2aelba
l2aelba / functions.php
Last active September 28, 2022 09:28
This is a Multilingual Wordpress functions to detect a language by pretty URLs like.. `domain.com/en/` `domain.com/postname/en/` `domain.com/pagetname/en/` Add this code in your `functions.php` After added code go to `wp-admin/options-permalink.php` press `Save Changes` So you can use `<?php echo lang();?>` `<?php if( lang() === "en" ) ?>` In yo…
function lang_support() {
return array('en','fr'); // Add your support lang-code (1st place is a default)
}
function rewrite_lang(){
$langs = lang_support();
foreach($langs as $lang) {
add_rewrite_endpoint($lang,EP_PERMALINK|EP_PAGES|EP_ROOT|EP_CATEGORIES);
}
}
@ChaseFlorell
ChaseFlorell / uriSchemeWithHyperlinkFallback.js
Last active February 21, 2023 11:22
Ever want to launch a mobile app from within the browser, but ensure that the browser still redirects the user to the link if the app isn't installed? This took some fiddling around, but when the "ah ha" moment hit, the solution is really quite simple.
// tries to execute the uri:scheme
function uriSchemeWithHyperlinkFallback(uri, href) {
// set up a timer and start it
var start = new Date().getTime(),
end,
elapsed;
// attempt to redirect to the uri:scheme
// the lovely thing about javascript is that it's single threadded.
// if this WORKS, it'll stutter for a split second, causing the timer to be off
<?php
/*
This function assumes a custom field named 'expiration' with a human friendly date/time.
*/
function is_post_expired($post_ID = null){
if(!$post_ID) global $post;
@leoken
leoken / expiration-time-posts.php
Created October 14, 2012 05:27
Set An Expiration Time For WordPress Posts
<?php
if (have_posts()) :
while (have_posts()) : the_post(); ?>
$expirationtime = get_post_custom_values('expiration');
if (is_array($expirationtime)) {
$expirestring = implode($expirationtime);
}
$secondsbetween = strtotime($expirestring)-time();
if ( $secondsbetween > 0 ) {
@billerickson
billerickson / mobile.php
Created October 4, 2012 21:00
Mobile Theme Switcher
<?php
/**
*
* Mobile theme switcher code - pulled from Mobile theme switch
* Original URI: http://wordpress.org/extend/plugins/mobile-theme-switcher/
* Original Author: Jonas Vorwerk, http://www.jonasvorwerk.com/
*
*
* Bypass this check in any browser by using http://myurl/?mobile=on or http://myurl/?mobile=off This is locally being stored using a cookie.
@sugarknowledge
sugarknowledge / REST_PHP_get_entry_list_example.php
Created June 28, 2012 19:42
PHP Example using cURL with the v4 SOAP API to retrieve a list of records with get_entry_list
<?php
$url = "http://{site_url}/service/v4/rest.php";
$username = "admin";
$password = "password";
//function to make cURL request
function call($method, $parameters, $url)
{
ob_start();