Skip to content

Instantly share code, notes, and snippets.

// Mixin
@mixin keyframes($name) {
@-moz-keyframes #{$name} { @content; }
@-webkit-keyframes #{$name} { @content; }
@-o-keyframes #{$name} { @content; }
@-ms-keyframes #{$name} { @content; }
@-khtml-keyframes #{$name} { @content; }
@keyframes #{$name} { @content; }
}
@ricardodantas
ricardodantas / README.md
Created August 30, 2013 16:38 — forked from oodavid/README.md
deploy with git

Deploy your site with git

This gist assumes:

  • you have a local git repo
  • with an online remote repository (github / bitbucket etc)
  • and a cloud server (Rackspace cloud / Amazon EC2 etc)
    • your (PHP) scripts are served from /var/www/html/
    • your webpages are executed by apache
  • apache's home directory is /var/www/
#!/bin/sh
#
# This hook does two things:
#
# 1. update the "info" files that allow the list of references to be
# queries over dumb transports such as http
#
# 2. if this repository looks like it is a non-bare repository, and
# the checked-out branch is pushed to, then update the working copy.
# This makes "push" function somewhat similarly to darcs and bzr.
@ricardodantas
ricardodantas / fullscreenapi.helper.js
Last active January 29, 2025 05:24
Javascript fullscreen API helper
var requestFullscreen = function (ele) {
if (ele.requestFullscreen) {
ele.requestFullscreen();
} else if (ele.webkitRequestFullscreen) {
ele.webkitRequestFullscreen();
} else if (ele.mozRequestFullScreen) {
ele.mozRequestFullScreen();
} else if (ele.msRequestFullscreen) {
ele.msRequestFullscreen();
} else {
@ricardodantas
ricardodantas / float_truncate.js
Last active January 3, 2016 05:59
Truncar float para 2 casas sem fazer arrendodamento.
Number.prototype.toFixedDown = function(digits) {
var n = this - Math.pow(10, -digits)/2;
n += n / Math.pow(2, 53);
return n.toFixed(digits);
}
<?php
/*
// Example usage:
echo byteFormat(4096, "B");
echo byteFormat(8, "B", 2);
echo byteFormat(1, "KB", 5);
echo byteFormat(1073741824, "B", 0);
echo byteFormat(1073741824, "KB", 0);
echo byteFormat(1073741824, "MB");
@ricardodantas
ricardodantas / php-email-to.utf8.php
Created January 31, 2014 13:43
Função para codificar email para UTF8 no envio de emails pela função "mail()" do PHP.
function utf8mail($to,$s,$body,$from_name="x",$from_a = "[email protected]", $reply="[email protected]")
{
$s= "=?utf-8?b?".base64_encode($s)."?=";
$headers = "MIME-Version: 1.0\r\n";
$headers.= "From: =?utf-8?b?".base64_encode($from_name)."?= <".$from_a.">\r\n";
$headers.= "Content-Type: text/plain;charset=utf-8\r\n";
$headers.= "Reply-To: $reply\r\n";
$headers.= "X-Mailer: PHP/" . phpversion();
mail($to, $s, $body, $headers);
}
@ricardodantas
ricardodantas / hide-text.css
Created February 17, 2014 14:59
Esconde texto de elementos HTML.
.hide-text {
text-indent: 100%;
white-space: nowrap;
overflow: hidden;
}
@ricardodantas
ricardodantas / hide-text.scss
Last active August 29, 2015 13:56 — forked from anonymous/mycode.js
A hide text SCSS mixin.
// How to use: @include hide-text;
@mixin hide-text() {
text-indent: 100%;
white-space: nowrap;
overflow: hidden;
}
@ricardodantas
ricardodantas / gmaps-lat-lon.js
Created March 11, 2014 18:35
Google Maps API - Pegar a latitude e longitude de um endereço
window.geocoder = new google.maps.ClientGeocoder();
geocoder.getLocations('rua xyz, sp', function(result){
var placemark = result.Placemark[0]; // Only use first result
var accuracy = placemark.AddressDetails.Accuracy;
var zoomLevel = 1;
var lon = placemark.Point.coordinates[0];
var lat = placemark.Point.coordinates[1];
gmap.setCenter(new google.maps.LatLng(lat, lon), zoomLevel);
});