Skip to content

Instantly share code, notes, and snippets.

@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
@crazy4groovy
crazy4groovy / jquery.newsTicker.plugin.js
Created January 12, 2012 00:40
rotate list of items, with many options
/*
* author: Steven Olsen
* contact: @crazy4groovy, crazy4groovy.blogspot.com
* version: 1.2.0
* license: MIT -- no guarantees, can't sue me (!), use it with due credit.
*/
(function ($) { $.fn.newsTicker = function (options) {
return this.each(function () {
@crazy4groovy
crazy4groovy / gist:1684615
Created January 26, 2012 19:38 — forked from fennb/gist:1124535
node.js proxy server in 20 lines of JS (via http://www.catonmat.net/http-proxy-in-nodejs/)
var http = require('http');
http.createServer(function(request, response) {
var proxy = http.createClient(80, request.headers['host'])
var proxy_request = proxy.request(request.method, request.url, request.headers);
proxy_request.addListener('response', function (proxy_response) {
proxy_response.addListener('data', function(chunk) {
response.write(chunk, 'binary');
});
proxy_response.addListener('end', function() {
@crazy4groovy
crazy4groovy / switchy_mclayout.js
Created January 31, 2012 16:48
adaptive html layout via css body class
window.onload = setScreenClass; // may break $(document).ready()?
window.onresize = setScreenClass;
// credit: http://www.alistapart.com/articles/switchymclayout
// example: http://paulwreid.com/about/
// Following transition classes will be declared:
//
// classname screenwidth
// ------------------------------------------
// pda_ver 240px
@crazy4groovy
crazy4groovy / googleWebFonts.js
Created February 2, 2012 14:10
Embed Google Web Fonts Via API
/**
* see: https://developers.google.com/webfonts/docs/webfont_loader
**/
WebFontConfig = {
google: { families: [ 'Merriweather', 'Nobile', 'Nobile', 'Nobile'] }
};
(function() {
var wf = document.createElement('script');
wf.src = '//ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
@crazy4groovy
crazy4groovy / gebTest.groovy
Created February 7, 2012 17:50
Sample Geb driver for Firefox
@Grapes([
@Grab("org.codehaus.geb:geb-junit4:0.6.2"),
@Grab("junit:junit-dep:4.8.2"),
@Grab("org.seleniumhq.selenium:selenium-firefox-driver:2.15.0"),
@Grab("org.seleniumhq.selenium:selenium-support:2.15.0")
])
import geb.Browser
Browser.drive {
go "http://www.google.ca/"
@crazy4groovy
crazy4groovy / dedupeFiles-withSize.groovy
Last active June 16, 2018 19:06
Duplicate file finder (and deleter) via MD5 hash
import java.util.regex.Pattern
import java.security.MessageDigest
import groovy.io.FileType
import groovy.transform.*
def input = System.console().&readLine
@Field minFileSize
@Field maxFileSize
String ROOT_DIRS = ( input("Enter the root directory [./] ") ?: "./" )
@crazy4groovy
crazy4groovy / ht_redirect.txt
Created March 28, 2012 03:00
Rules for htaccess redirect
I would recommend inserting this code just after the line reading "RewriteEngine On":
[Redirect www to non-www]
RewriteCond %{HTTP_HOST} ^www.yourdomain.com [NC]
RewriteRule ^(.*)$ http://yourdomain.com/$1 [L,R=301]
[Redirect non-www to www]
RewriteCond %{HTTP_HOST} ^yourdomain.com [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]
@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()
@crazy4groovy
crazy4groovy / gist:2370716
Created April 12, 2012 20:19 — forked from Mottie/gist:1491097
jQuery images loaded function
/*
Check if all images are loaded
- Callback occurs when all images are loaded
- image load errors are ignored (complete will be true)
- Use:
$('.wrap img').imagesLoaded(function(){
alert('all images loaded');
});
*/