Skip to content

Instantly share code, notes, and snippets.

View griiettner's full-sized avatar

Paulo Griiettner griiettner

View GitHub Profile
@griiettner
griiettner / fade_on_scroll.js
Created May 21, 2014 18:17
Fade an element relative to scroll, in one line
// Here's a neat jQuery trick to fade an element based on how far down
// the page you've scrolled (maybe you want an element to be fully visible
// when the user first encounters it, but become transparent as they move along):
$('h1').css({'opacity':( 100-$(window).scrollTop() )/100});
// Where $('h1') is the element to be faded, and the first '100'
// can be adjusted to allow for distance down the page.
@griiettner
griiettner / remove_unwanted_html_comments.php
Created May 20, 2014 13:23
Remove unwanted HTML comments
// Remove unwanted HTML comments
$data = preg_replace('/<!--(.|\s)*?-->/', '', $data);

Sublime Text 2 - Useful Shortcuts

*Tested in Windows 8

Open/Goto


  • ctrl+p: go to anything
  • ctrl+t: go to file
  • ctrl+ctrl+p: go to project
// Original code from http://www.blog.highub.com/mobile-2/a-fix-for-iphone-viewport-scale-bug/
var metas = document.getElementsByTagName('meta');
var i;
if (navigator.userAgent.match(/iPhone/i)) {
for (i=0; i<metas.length; i++) {
if (metas[i].name == "viewport") {
metas[i].content = "width=device-width, minimum-scale=1.0, maximum-scale=1.0";
}
}
@griiettner
griiettner / Clear Fix hack
Last active November 1, 2017 14:25
Hack to clear fix container
/**
* For modern browsers
* 1. The space content is one way to avoid an Opera bug when the
* contenteditable attribute is included anywhere else in the document.
* Otherwise it causes space to appear at the top and bottom of elements
* that are clearfixed.
* 2. The use of `table` rather than `block` is only necessary if using
* `:before` to contain the top-margins of child elements.
*/
.cf:before,
/* To target IE 6 and 7 */
@media screen\9 {
body { background: red; }
}
/* To target IE 6, 7 and 8 */
@media \0screen\,screen\9 {
body { background: green; }
}
@griiettner
griiettner / Bootstrap Smooth Scroll to Anchor
Last active November 1, 2017 14:23
Bootstrap Smooth Scroll to Anchor
!function ($) {
$(function(){
$('#home, #me, #footer').carousel({});
var $root = $('html, body');
$('a').click(function() {
var href = $.attr(this, 'href');
$root.animate({
scrollTop: $(href).offset().top
<?php
//Example : http://localhost/index.php?option=com_hello&view=item&task=add_tag&tags=1400,1783,1770,9
$data =JRequest::get( 'request' );
print_r($data);
?>
//Output :
//Array ( [option] => com_hello [view] => item [task] => add_tags [tags] => 1400,1783,1770,9)
<?php
function clean($string) {
$string = str_replace(" ", "-", $string); // Replaces all spaces with hyphens.
$string = preg_replace('/[^A-Za-z0-9\-]/', '', $string); // Removes special chars.
return preg_replace('/-+/', '_', $string); // Replaces multiple hyphens with single one.
}
@griiettner
griiettner / Redirect www urls to non-www
Created July 12, 2013 01:03
Redirect www urls to non-www
# Redirect www urls to non-www
RewriteCond %{HTTP_HOST} ^www\.yoursite\.com [NC]
RewriteRule (.*) http://yoursite.com/$1 [R=301,L]