Skip to content

Instantly share code, notes, and snippets.

@meltingice
meltingice / gist:1674915
Created January 25, 2012 05:28
Example output from psd.js. You can see how it errors at the end.
➜ psd.js git:(master) ✗ coffee test/test.coffee
Beginning parsing
### Header ###
{ sig: '8BPS',
version: 1,
r0: 0,
r1: 0,
r2: 0,
r3: 0,
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="apple-touch-icon" href="/path/to/icon.png" />
<link rel="apple-touch-startup-image" href="/path/to/startup-image.png">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
.background-gradient(@start, @stop) {
background-image:-moz-linear-gradient(top, @start, @stop);
background-image:-o-linear-gradient(top, @start, @stop);
background-image:-webkit-gradient(linear, left top, left bottom, from(@start), to(@stop));
background-image:-webkit-linear-gradient(@start, @stop);
background-image:linear-gradient(top, @start, @stop);
filter: ~"progid:DXImageTransform.Microsoft.gradient(startColorStr='@{start}', EndColorStr='@{stop}')";
}
.transition(@element, @duration, @easing) {
@meltingice
meltingice / singleton.coffee
Created May 18, 2011 19:55
Example singleton class and example for Coffeescript
class Singleton
# We can make private variables!
instance = null
# Static singleton retriever/loader
@get: ->
if not @instance?
instance = new @
instance.init()
@meltingice
meltingice / uniqid.coffee
Created May 5, 2011 04:04
Minimal unique ID generator written in Coffeescript
uniqid = (->
id = 0
{ get: -> id++ }
)()
uniqid.get() #= 0
uniqid.get() #= 1
uniqid.get() #= 2, and so on...
@meltingice
meltingice / css3.less
Created April 28, 2011 18:48
CSS3 LESS Mini-Library
.background-gradient(@start, @stop) {
background-image:-moz-linear-gradient(top, @start, @stop);
background-image:-o-linear-gradient(top, @start, @stop);
background-image:-webkit-gradient(linear, lefttop, leftbottom, color-stop(0, @start), color-stop(1, @stop));
background-image:-webkit-linear-gradient(@start, @stop);
background-image:linear-gradient(top, @start, @stop);
filter: e("progid:DXImageTransform.Microsoft.gradient(startColorStr='") @start e("',EndColorStr='") @stop e("')");
}
.transition(@element, @duration, @easing) {
@meltingice
meltingice / gist:875484
Created March 18, 2011 01:43
What I wish JS could do.
function render() {
var pixels = get_pixels();
new Thread(function () {
for (i = 0, len = pixels.length; i < len; i +=4) {
// holy shared process memory batman!
// manipulate pixels here
}
finished();
});
@meltingice
meltingice / gist:854220
Created March 4, 2011 05:23
Top 50 photos on TwitPic
short_id | views
----------------------
1NOZY | 6046885
1LRVYZ | 5500375
402GUX | 4774205
3VT0AX | 4014450
39P29E | 3621020
2TQFKV | 3075355
I98R2 | 1782350
3XS45P | 1749605
<!-- Place in your the <head> of your page -->
<script src='https://githubanywhere.appspot.com/github-anywhere.js'></script>
<script>
GitHubAnywhere(function() {
// use `this` instead of passing the object?
this.buttons();
});
</script>
<!-- Place anywhere on your page replaceing :name with a GitHub username and :repo with a repository name. -->
@meltingice
meltingice / usernode.php
Created November 15, 2010 03:15
Social graph functions implemented using Redis.
<?
/*
* This example would probably work best if you're using
* an MVC framework, but it can be used standalone as well.
*
* This example also assumes you are using Predis, the excellent
* PHP Redis library available here:
* https://github.com/nrk/predis
*/