Skip to content

Instantly share code, notes, and snippets.

View amadeus's full-sized avatar
🕶️
out here livin

Amadeus Demarzi amadeus

🕶️
out here livin
View GitHub Profile
@amadeus
amadeus / gist:845696
Created February 26, 2011 22:35
JS Prefix Tests
var prefix = (function(){
var list = ['', 'webkit', 'Moz', 'O', 'ms'],
element = document.html;
for (var i = 0; i < list.length; i++){
var prefix = list[i];
if (element.style[prefix ? prefix + 'Transform' : 'transform'] != null)
return prefix.toLowerCase();
}
return '';
@amadeus
amadeus / gist:983364
Created May 20, 2011 17:24
Penner's easing methods in CSS
'linear:in': cubic-bezier(0,0,1,1)
'linear:out': cubic-bezier(0,0,1,1)
'linear:in:out': cubic-bezier(0,0,1,1)
'expo:in': cubic-bezier(0.71,0.01,0.83,0)
'expo:out': cubic-bezier(0.14,1,0.32,0.99)
'expo:in:out': cubic-bezier(0.85,0,0.15,1)
'circ:in': cubic-bezier(0.34,0,0.96,0.23)
'circ:out': cubic-bezier(0,0.5,0.37,0.98)
'circ:in:out': cubic-bezier(0.88,0.1,0.12,0.9)
'sine:in': cubic-bezier(0.22,0.04,0.36,0)
@amadeus
amadeus / SimpleJSONDecoder.js
Created September 29, 2011 16:36
A simple way to parse JSON.
(function(){
if (!this.JSON) this.JSON = {};
var decode = window.JSON.parse || function(str){
return window.eval('(' + str + ')');
};
this.JSON.decode = function(str){
var json = null;
try {
@amadeus
amadeus / server.py
Created May 17, 2012 18:08
A simple static asset python server
import SimpleHTTPServer
import SocketServer
PORT = 8888
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
httpd = SocketServer.TCPServer(("", PORT), Handler)
print 'Serving at localhost:' + str(PORT)
httpd.serve_forever()
@amadeus
amadeus / clone.js
Created July 26, 2012 22:08
A nice and simple clone function.
var clone = function clone(src) {
var r, i, l,
mixin = function(dest, source, copyFunc) {
var name, s, i, empty = {};
for(name in source){
s = source[name];
if(!(name in dest) || (dest[name] !== s && (!(name in empty) || empty[name] !== s))){
dest[name] = copyFunc ? copyFunc(s) : s;
}
}
@amadeus
amadeus / gist:3420258
Created August 21, 2012 23:12
Ghetto Slideshow
<!DOCTYPE HTML>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Slideshow</title>
<style type="text/css">
html, body { margin:0; padding:0; }
img { display:block; margin:0 auto; }
</style>
</head>
@amadeus
amadeus / backingStoreNotes.md
Created September 13, 2012 08:08
Notes on context.webkitBackingStorePixelRatio

Notes on context.webkitBackingStorePixelRatio

Basically the intended use for this new API is the following.

You have your canvas as is, forget the world of retina displays, just think of CSS units, not physical pixels. Physical pixels have now been abstracted away.

You create your canvas in your document, you set your canvas to be 940px wide since your website is on a 940 pixel grid (for example).

You begin drawing to your canvas, and everything just works. You get high resolution lines, high resolution circles, shapes, etc. The canvas, while you interact with it in a lower resolution, is automagically upscaled internally for you, as if you where drawing vectors.

#
# Configuration File for JavaScript Lint 0.3.0
# Developed by Matthias Miller (http://www.JavaScriptLint.com)
#
# This configuration file can be used to lint a collection of scripts, or to enable
# or disable warnings for scripts that are linted via the command line.
#
### Warnings
# Enable or disable warnings based on requirements.
" TESTING: Entity Escaper
command Entities :call Entities()
function Entities()
silent %s/&/\&amp;/eg
silent %s/"/\&quot;/eg
silent %s/'/\&apos;/eg
silent %s/</\&lt;/eg
silent %s/>/\&gt;/eg
silent %s/¡/\&iexcl;/eg
silent %s/¢/\&cent;/eg
@amadeus
amadeus / buffdelete.vim
Created November 8, 2012 23:47
CtrlP Buffer Delete
" TESTING: CtrlPBuf Delete
let g:ctrlp_buffer_func = { 'enter': 'MyCtrlPMappings' }
func! MyCtrlPMappings()
nnoremap <buffer> <silent> <c-@> :call <sid>DeleteBuffer()<cr>
endfunc
func! s:DeleteBuffer()
exec "bd" fnamemodify(getline('.')[2:], ':p')
exec "norm \<F5>"