Skip to content

Instantly share code, notes, and snippets.

View fxg42's full-sized avatar

François-Xavier Guillemette fxg42

View GitHub Profile
@fxg42
fxg42 / chart.groovy
Created December 14, 2011 00:34
JFreeChart with Kendo style
@Grab('org.jfree:jfreechart:1.0.14')
import java.awt.*
import java.awt.geom.*
import java.io.*
import java.text.*
import org.jfree.chart.*
import org.jfree.chart.annotations.*
import org.jfree.chart.axis.*
import org.jfree.chart.block.*
import org.jfree.chart.labels.*
@fxg42
fxg42 / index.md
Created October 1, 2012 20:24
MGL7361
@fxg42
fxg42 / bookmark.jade
Created November 16, 2012 17:22
Draw a ribbon-like bookmark
// see: http://jsfiddle.net/DBA4Q/
@import 'nib'
bookmark(color, width)
width width
height (width * 2)
background linear-gradient(top, lighten(color, 35%) 5%, color 12%)
position relative
@fxg42
fxg42 / wsd.coffee
Created December 10, 2012 18:32
build urls for websequencediagrams.com
qs = require 'querystring'
diagram = """
title Foo bar baz
a -> b: do b.m()
b -> c: do c.m()
"""
baseUrl = "http://www.websequencediagrams.com/cgi-bin/cdraw"
var CoffeeScript = require('coffee-script'); // make sure that coffee-script version is >= 1.5.0
var assets = require('connect-assets')({
jsCompilers: {
litcoffee: {
match: /\.js$/,
compileSync: function (sourcePath, source) {
return CoffeeScript.compile(source, { filename: sourcePath, literate: true });
}
}
assert = require 'assert'
reverse = (str) ->
(str.split '').reverse().join ''
format = (num) ->
reverse (reverse num.toString()).replace /\d{3}(?=\d)/g, '$& '
assert '1' is format 1
assert '10' is format 10
@fxg42
fxg42 / bonjour.coffee
Created March 24, 2013 18:30
Voici le premier programme de Jeanne - 4 ans et demi.
console.log "bonjour jeanne"
console.log "jaime mon amie jeanne-mangue"
console.log 2+7
console.log 6+18
console.log "jaime mon petit frère Louis"
@fxg42
fxg42 / rpctest.groovy
Created May 3, 2013 18:04
Check time between remote and local calls...
@Grab('org.codehaus.groovy.modules:groovyws:0.5.2')
import groovyx.net.ws.*
// Define a simple service with a single method that sums two numbers.
class MathService {
double add (double x, double y) { x + y }
}
// Start a server that exposes the service as a SOAP endpoint.
@fxg42
fxg42 / variables.coffee
Created May 11, 2013 15:45
Le deuxième programme de Jeanne, 4 ans 1/2.
age=4
nom="jeanne"
console.log "bonjour mon nom est #{nom} et j'ai #{age} ans."
nom="louis"
age=2
console.log "bonjour mon nom est #{nom} et j'ai #{age} ans."
folders = [
{id:1, parentId:2, childrenId:[]}
{id:2, parentId:null, childrenId:[]}
{id:3, parentId:2, childrenId:[]}
{id:4, parentId:5, childrenId:[]}
{id:5, parentId:3, childrenId:[]}
{id:6, parentId:5, childrenId:[]}
{id:7, parentId:999, childrenId:[]}
{id:8, parentId:7, childrenId:[]}
]