Skip to content

Instantly share code, notes, and snippets.

View jonabaptistella's full-sized avatar

Jonathan Baptistella jonabaptistella

View GitHub Profile
<?php if($pagination->countItems() > 10): ?>
<!-- site/snippets/pagination.php -->
<nav role="pagination">
<div class="count">
<?php if($pagination->countItems() < 10): ?>
<strong><?php echo $pagination->countItems() ?></strong> Results / showing <strong><?php echo $pagination->numStart() ?></strong> - <strong><?php echo $pagination->countItems() ?></strong>
<?php else: ?>
@jonabaptistella
jonabaptistella / s3.sh
Created March 18, 2017 22:14 — forked from chrismdp/s3.sh
Uploading to S3 in 18 lines of Shell (used to upload builds for http://soltrader.net)
# You don't need Fog in Ruby or some other library to upload to S3 -- shell works perfectly fine
# This is how I upload my new Sol Trader builds (http://soltrader.net)
# Based on a modified script from here: http://tmont.com/blargh/2014/1/uploading-to-s3-in-bash
S3KEY="my aws key"
S3SECRET="my aws secret" # pass these in
function putS3
{
path=$1
@jonabaptistella
jonabaptistella / radius.php
Created January 14, 2018 03:13 — forked from bastianallgeier/radius.php
Radius search
<?php
/**
* Simple helper to fetch the bounding boxes
* for a point on the map (lat,lng) by radius.
*
* @param double $lat Latitude
* @param double $lng Longitude
* @param int $radius Radius in km
* @return array
@jonabaptistella
jonabaptistella / javascript-localstorage-expiry.js
Created March 4, 2018 01:26 — forked from shaik2many/javascript-localstorage-expiry.js
set timeout for localStorage or sessionStorage
http://apassant.net/2012/01/16/timeout-for-html5-localstorage/
var hours = 24; // Reset when storage is more than 24hours
var now = new Date().getTime();
var setupTime = localStorage.getItem('setupTime');
if (setupTime == null) {
localStorage.setItem('setupTime', now)
} else {
if(now-setupTime > hours*60*60*1000) {
localStorage.clear()
@jonabaptistella
jonabaptistella / .htaccess
Created March 6, 2018 03:20 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
#301 Redirects for .htaccess
#Redirect a single page:
Redirect 301 /pagename.php http://www.domain.com/pagename.html
#Redirect an entire site:
Redirect 301 / http://www.domain.com/
#Redirect an entire site to a sub folder
Redirect 301 / http://www.domain.com/subfolder/
@jonabaptistella
jonabaptistella / rotating.css
Created March 8, 2018 18:09 — forked from krizpoon/rotating.css
Infinite rotation by CSS. Useful for loading spinners.
@keyframes rotating
{
from
{
transform: rotate(0deg);
-o-transform: rotate(0deg);
-ms-transform: rotate(0deg);
-moz-transform: rotate(0deg);
-webkit-transform: rotate(0deg);
}
@jonabaptistella
jonabaptistella / .htaccess
Created March 12, 2018 13:07 — forked from jonathonbyrdziak/.htaccess
htaccess mod_expires / mod_cache / mod_deflate / mod_headers
# ------------------------------------------------------------------------------
#
# Curtousy of the Magento Support Center
# http://magentosupport.help/what-are-expires-headers-and-how-do-i-implement-them/
#
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
# | Mod Caching via Apache |
@jonabaptistella
jonabaptistella / target_blank.js
Created June 5, 2018 00:36 — forked from allybee/target_blank.js
Add target="_blank" to external links with pure JavaScript.
function targetBlank() {
// remove subdomain of current site's url and setup regex
var internal = location.host.replace("www.", "");
internal = new RegExp(internal, "i");
var a = document.getElementsByTagName('a'); // then, grab every link on the page
for (var i = 0; i < a.length; i++) {
var href = a[i].host; // set the host of each link
if( !internal.test(href) ) { // make sure the href doesn't contain current site's host
a[i].setAttribute('target', '_blank'); // if it doesn't, set attributes
@jonabaptistella
jonabaptistella / fields.php
Created June 18, 2018 11:30 — forked from ian-cox/fields.php
Adding panel fields to front end Kirby templates
<?php if($user = $site->user() and $user->hasRole('admin')):?>
<form autocomplete="off" class="form" method="post" action="/panel/api/pages/update/<?php echo kirby()->request()->path();?>">
<label class="label" for="form-field-title">Title</label>
<input autocomplete="on" class="input" id= "form-field-title" name="title" required="" type="title" value="<?php echo $page->title() ?>">
<input type="submit" value="Save">
</form>
<?php endif;?>
@jonabaptistella
jonabaptistella / assets_css_editor.css
Created June 29, 2018 01:11 — forked from fabianmichael/assets_css_editor.css
Simple Inline Editor for Kirby
input[type="text"],
textarea {
-webkit-appearance: none;
border: 0;
border-radius: 0;
font: inherit;
line-height: inherit;
resize: none;
width: 100%;
padding: 0;