Skip to content

Instantly share code, notes, and snippets.

@crazy4groovy
crazy4groovy / restApi.groovy
Last active August 29, 2015 14:23 — forked from chiquitinxx/gist:2a89987fe4e611803a7b
Create a Rest API fake in Groovy, using javascript npm modules (faker and json-server)
import org.grooscript.asts.GsNative
class Faker {
private _faker
@GsNative
private faker() {/*
if (!this._faker) {
this._faker = require('faker');
}
@crazy4groovy
crazy4groovy / refreshListDOMTest.html
Created September 15, 2014 18:17
Test refresh DOM performance in various browsers.
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
body {
min-height: 2000px;
}
.book {
@crazy4groovy
crazy4groovy / PrettyPrinter.groovy
Last active September 9, 2015 20:01 — forked from esycat/PrettyPrinter.groovy
A simple way to pretty print nested lists and maps in Groovy.
import static groovy.json.JsonOutput.*
def config = ['test': 'lalala']
println prettyPrint(toJson(config))
@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 / 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]