Skip to content

Instantly share code, notes, and snippets.

@neilj
neilj / gist:1532562
Created December 29, 2011 07:22
Sugared DOM: Better Than Templates
var el = ( function () {
var doc = document;
var directProperties = {
'class': 'className',
className: 'className',
defaultValue: 'defaultValue',
'for': 'htmlFor',
html: 'innerHTML',
@crazy4groovy
crazy4groovy / ASCII Art.groovy
Created January 5, 2012 17:57
Convert image(s) (http or local) to colour or b/w ascii art, via Groovy!
/**
* Groovy ASCII Art. Converts an image into ASCII.
* This doesn't work under the web console due to missing AWT classes.
*
* Author : Cedric Champeau (http://twitter.com/CedricChampeau)
* Updated : Steven Olsen (http://crazy4groovy.blogspot.com)
*/
import java.awt.color.ColorSpace as CS
import java.awt.geom.AffineTransform
import javax.imageio.ImageIO
@deanriverson
deanriverson / helloGroovyFX.groovy
Created March 3, 2012 16:57
A basic GroovyFX HelloWorld program
@Grab('org.codehaus.groovyfx:groovyfx:0.1')
import groovyx.javafx.GroovyFX
import groovyx.javafx.SceneGraphBuilder
GroovyFX.start {
def sg = new SceneGraphBuilder()
sg.stage(title: "GroovyFX Hello World", visible: true) {
scene(fill: black, width: 530, height: 300) {
@deanriverson
deanriverson / build.gradle
Created March 4, 2012 17:56
Basic Gradle build file for a project using GroovyFX 0.1
apply plugin:'groovy'
javafxHome = System.env['JAVAFX_HOME']
repositories { mavenCentral() }
dependencies {
groovy 'org.codehaus.groovy:groovy-all:1.8.2'
compile 'org.codehaus.groovyfx:groovyfx:0.1'
compile files("${javafxHome}/rt/lib/jfxrt.jar")
@crazy4groovy
crazy4groovy / helloGroovyFX.groovy
Created April 3, 2012 15:55 — forked from deanriverson/helloGroovyFX.groovy
A basic GroovyFX HelloWorld program
@Grab('org.codehaus.groovyfx:groovyfx:0.1')
import groovyx.javafx.GroovyFX
import groovyx.javafx.SceneGraphBuilder
//source: http://pleasingsoftware.blogspot.ca/2012/03/groovyfx-first-official-release.html
//run: groovy -classpath $JAVAFX_HOME/rt/lib/jfxrt.jar helloGroovyFX.groovy
GroovyFX.start {
def sg = new SceneGraphBuilder()
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@kiy0taka
kiy0taka / tree.md
Created April 24, 2012 09:56 — forked from timyates/tree.md
A one-line tree in Groovy

One line Tree in Groovy

The other day, I saw Harold Cooper's One-line tree in Python via autovivication, and wondered if the same thing was possible in Groovy.

The answer is yes! But you need to define the variable tree before you can assign it to the self-referential withDefault closure, hence with Groovy, it's a two-line solution ;-)

Anyway, given:

def tree = { [:].withDefault{ owner.call() } }
@crazy4groovy
crazy4groovy / TimeAvatar.groovy
Created May 22, 2012 19:26 — forked from mike-neck/TimeAvatar.groovy
inspired by image change script git://gist.github.com/1481409.git written by Yusuke Yamamoto. see https://gist.github.com/1481409
/**
* Copyright (C) 2011 Yusuke Yamamoto
* Licensed under the Apache License, Version 2.0 (the "License");
* http://www.apache.org/licenses/LICENSE-2.0
*
*
**/
@Grab(group='quartz', module='quartz', version='1.5.2')
@Grab(group='org.twitter4j', module='twitter4j-core', version='2.2.5')
@timyates
timyates / match.groovy
Created June 27, 2012 09:17
match/when implemented with Groovy's GEP-3
// No commas
def a = 'tim'
def nocom = match( a ) {
when 'dave' 'Hi Dave'
when 'tim' 'Hi Tim'
otherwise 'none of the above'
}
assert nocom == 'Hi Tim'
// Commas
@alimd
alimd / gist:3344523
Created August 13, 2012 22:28
All github Emoji (Smiles)

All github Emoji (Smiles)

ali.md/emoji

:bowtie: | πŸ˜„ | πŸ˜† | 😊 | πŸ˜ƒ | ☺️ | 😏 | 😍 | 😘 | :kissing_face: | 😳 | 😌 | πŸ˜† | 😁 | πŸ˜‰ | :wink2: | πŸ‘… | πŸ˜’ | πŸ˜… | πŸ˜“

😩 | πŸ˜” | 😞 | πŸ˜– | 😨 | 😰 | 😣 | 😒 | 😭 | πŸ˜‚ | 😲 | 😱 | :neckbeard: | 😫 | 😠 | 😑 | 😀 | πŸ˜ͺ | πŸ˜‹ | 😷

😎 | 😡 | πŸ‘Ώ | 😈 | 😐 | 😢 | πŸ˜‡ | πŸ‘½ | πŸ’› | πŸ’™ | πŸ’œ | ❀️ | πŸ’š | πŸ’” | πŸ’“ | πŸ’— | πŸ’• | πŸ’ž | πŸ’˜ | ✨