Skip to content

Instantly share code, notes, and snippets.

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

Victor Coulon Victa

🏠
Working from home
View GitHub Profile
@Victa
Victa / canvas.html
Created May 17, 2011 09:23
Apple-esque toolbar (navbar) CSS3 & canvas
<!doctype html>
<title>Tabbar canvas</title>
<canvas id="toolbar"></canvas>
<script>
var canvas = document.getElementById("toolbar");
var context = canvas.getContext("2d");
var gradient = context.createLinearGradient(0, 0, 0, 44);
gradient.addColorStop(0,'#2F2F2F');
gradient.addColorStop(0.5,'#151515');
gradient.addColorStop(0.51,'#000000');
@Victa
Victa / scripts.js
Created May 23, 2011 15:06
Get URL parameters
function getUrlParameters(search) {
var search = search ? search : window.location.search;
var vars = {};
if (search.length > 0) {
var hash, hashes = search.slice(1).split('&');
for (var i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
vars[hash[0]] = hash[1];
}
}
@Victa
Victa / slide.html
Created May 23, 2011 17:21
Slide toggle - CSS3 only
<!doctype html>
<html>
<head>
<title>Slide CSS3</title>
<meta charset="UTF-8">
<style>
body {background:#FFF;text-align:center;font-family:sans-serif;}
p {margin:10px 150px;}
@Victa
Victa / gist:988876
Created May 24, 2011 15:04
Extends JS array sort functions
Array.prototype.sortIntAsc = function(field){
this.sort(function(a,b){
var v1 = parseInt(a[field]);
var v2 = parseInt(b[field]);
if (v1<v2) return -1;
if (v1>v2) return 1;
return 0;
});
}
@Victa
Victa / gist:994985
Created May 27, 2011 10:04
Placeholder support for shitty browsers
$('[placeholder]').parents('form').submit(function() {
$(this).find('[placeholder]').each(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
}
})
});
@Victa
Victa / .htaccess
Created May 30, 2011 17:41
Remove www in url
RewriteEngine On
RewriteCond %{HTTP_HOST} !^your-site.com$ [NC]
RewriteRule ^(.*)$ http://your-site.com/$1 [L,R=301]
@Victa
Victa / .htaccess
Created May 30, 2011 17:42
Redirect all WordPress feeds to feedburner
<IfModule mod_alias.c>
RedirectMatch 301 /feed/(atom|rdf|rss|rss2)/?$ http://feedburner.com/yourfeed/
RedirectMatch 301 /comments/feed/(atom|rdf|rss|rss2)/?$ http://feedburner.com/yourfeed/
</IfModule>
@Victa
Victa / .htaccess
Created May 30, 2011 17:43
Create custom error pages
ErrorDocument 400 /errors/badrequest.html
ErrorDocument 401 /errors/authreqd.html
ErrorDocument 403 /errors/forbid.html
ErrorDocument 404 /errors/notfound.html
ErrorDocument 500 /errors/serverr.html
@Victa
Victa / .htaccess
Created May 30, 2011 17:44
Remove file extensions from urls
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME}\.html -f
RewriteRule ^(.*)$ $1.html
# Replace html with your file extension, eg: php, htm, asp
@Victa
Victa / gist:999304
Created May 30, 2011 18:49
HTML5 form validation messages
::-webkit-validation-bubble{}
::-webkit-validation-bubble-top-outer-arrow{}
::-webkit-validation-bubble-top-inner-arrow{}
::-webkit-validation-bubble-message{}