Skip to content

Instantly share code, notes, and snippets.

View andreruffert's full-sized avatar

André Ruffert andreruffert

View GitHub Profile
@andreruffert
andreruffert / gist:673934
Created November 12, 2010 10:00
Useful snippet for displaying plaintext Twitter updates...
<ul id="twitter_update_list"></ul>
<script type="text/javascript" src="http://twitter.com/javascripts/blogger.js"></script>
<script type="text/javascript" src="http://twitter.com/statuses/user_timeline/andreruffert.json?callback=twitterCallback2&amp;count=5"></script>
@andreruffert
andreruffert / media_queries.css
Created November 12, 2010 13:55
CSS3 Media Queries
/**
* Max Width
* The following CSS will apply if the viewing area is smaller than 600px.
* Separate stylesheet: <link rel="stylesheet" media="screen and (max-width: 600px)" href="small.css" />
*/
@media screen and (max-width: 600px) {
.class {
background: #ccc;
}
}
@andreruffert
andreruffert / gist:674211
Created November 12, 2010 15:25
SEO Friendly 301 Permanent Redirect
Redirect 301 http://www.foo.bar/home http://www.foo.bar/
@andreruffert
andreruffert / display_filesize.php
Created November 17, 2010 17:03
Returns a file-size in a more legible format
function display_filesize($filesize){
if(is_numeric($filesize)){
$decr = 1024; $step = 0;
$prefix = array('Byte','KB','MB','GB','TB','PB');
while(($filesize / $decr) > 0.9){
$filesize = $filesize / $decr;
$step++;
}
@andreruffert
andreruffert / gist:712006
Created November 23, 2010 16:16
C# Elo Rating Class used on Facemash as seen in the Social Network Movie :-)
public class EloRating
{
public double Point1 { get; set; }
public double Point2 { get; set; }
public double FinalResult1 { get; set; }
public double FinalResult2 { get; set; }
public EloRating(double CurrentRating1, double CurrentRating2, double Score1, double Score2)
{
@andreruffert
andreruffert / gist:712074
Created November 23, 2010 16:44
Sick of alert();
console.debug("This is a Debug message");
console.info("This is just info");
console.warn("This is a warning");
console.error("This is an Error");
// Console in Chrome
Ctrl+Shift+J
// Also works in the console in Firebug + Safari
*:hover
{
-moz-transition: all 1s ease;
-moz-transition: rotate(180deg);
-webkit-transition: all 1s ease;
-webkit-transform: rotate(180deg);
-o-transition: all 1s ease;
-o-transition: rotate(180deg);
}
@andreruffert
andreruffert / gist:736054
Created December 10, 2010 10:20
Get your latest twitter updates without using a plugin...
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<ul id="twitter_update_list">
</ul> <!-- end twitter_update_list -->
@andreruffert
andreruffert / .htaccess
Created February 18, 2011 10:37
Minify CSS
RewriteEngine On
RewriteRule ^styles.min.css$ styles.min.php [L]
@andreruffert
andreruffert / gist:833549
Created February 18, 2011 11:12
Clear input fields on focus with text replacement if nothing is entered
$('input').each(function(){
$(this)
.data('default', $(this).val())
.focus(function(){
if ($(this).val() == $(this).data('default') || ''){
$(this).val('');
}
})
.blur(function(){
if ($(this).val() == '') {