From f60d547ea0ce4df57873d8b7ea90670ba040b5e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ga=C3=9F?= Date: Sun, 9 Oct 2011 20:14:57 +0200 Subject: [PATCH] Rewrite in CoffeeScript --- .gitignore | 1 + genregen.coffee | 195 +++++++++++++++++++++++++++++++++ gg.pl | 285 ------------------------------------------------ index.html | 25 +++++ style.css | 37 +++++++ 5 files changed, 258 insertions(+), 285 deletions(-) create mode 100644 .gitignore create mode 100644 genregen.coffee delete mode 100755 gg.pl create mode 100644 index.html create mode 100644 style.css diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..49cb98a --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/genregen.js diff --git a/genregen.coffee b/genregen.coffee new file mode 100644 index 0000000..eb7246a --- /dev/null +++ b/genregen.coffee @@ -0,0 +1,195 @@ +genres = [ + 'Aggrotech', + 'Ambient', + 'Beat', + 'Bluegrass', + 'Blues', + 'Chiptune', + 'Core', + 'Country', + 'Cumbia', + 'Dance', + 'Dancehall', + 'Drum and Bass', + 'Dub', + 'Dubstep', + 'EBM', + 'Flamenco', + 'Grunge', + 'Goa', + 'Gospel', + 'Hardstyle', + 'Hip-hop', + 'House', + 'Humppa', + 'Industrial', + 'Jazz', + 'Metal', + 'Oi!', + 'Polka', + 'Pop', + 'Punk', + 'Rap', + 'Rave', + 'Reggae', + 'Rockabilly', + 'Samba', + 'Schranz', + 'Ska', + 'Soul', + 'Techhouse', + 'Techno', + 'Tekkno', + 'Trance', + 'Triphop', + 'Twostep', + 'Western', +] + +subgenres = [ + '30s', + '40s', + '50s', + '60s', + '70s', + '80s', + 'Acid', + 'Alternative', + 'Ambient', + 'Anatolian', + 'Arena', + 'Art', + 'Australian', + 'Australian', + 'Avantgarde', + 'Balearic', + 'Balkan', + 'Battle', + 'Black', + 'Body', + 'Bossa nova', + 'Brit', + 'Celtic', + 'Chinese', + 'Christian', + 'Comedy', + 'Conscious', + 'Cow', + 'Crust', + 'Dark', + 'Death', + 'Dirty', + 'Doom', + 'Drone', + 'East Coast', + 'Electroclash', + 'Electronic', + 'Emo', + 'Euro', + 'Experimental', + 'Extreme', + 'Flower', + 'Folk', + 'Free', + 'Freestyle', + 'Fucking', + 'Fun', + 'Funk', + 'Fusion', + 'Future', + 'Gangsta', + 'Garage', + 'Ghetto', + 'Glam', + 'Gospel', + 'Gothic', + 'Grind', + 'Groove', + 'Happy', + 'Hard', + 'Hardcore', + 'Harmonica', + 'Handsup', + 'Heavy', + 'Horror', + 'Indian', + 'Indie', + 'Independent', + 'Industrial', + 'Instrumental', + 'Latin', + 'Lounge', + 'Mainstream', + 'Medieval', + 'Melodic', + 'Minimal', + 'Neo', + 'New age', + 'Ninja', + 'Nintendo', + 'Noise', + 'Nu', + 'Pagan', + 'Pirate', + 'Post', + 'Power', + 'Progressive', + 'Psychedelic', + 'Skate', + 'Sludge', + 'Southern', + 'Space', + 'Speed', + 'Stoner', + 'Street', + 'Sunshine', + 'Surf', + 'Swedish', + 'Swing', + 'Symphonic', + 'Synth', + 'Teutonic', + 'Traditional', + 'Trash', + 'Viking', + 'Vocal', + 'Wave', + 'West Coast', + 'World', +] + +cities = [ + 'Berlin', + 'Bakersfield', + 'Detroit', + 'Frankfurt', + 'Gothenburg', + 'Ibiza', + 'London', + 'New Orleans', + 'Rio', + 'Rotterdam', + 'San Francisco', +] + +rand_choose = (array) -> + array[Math.floor(Math.random() * array.length)] + +chance = (percent) -> + Math.floor(Math.random() * 100) < percent + +generate_genre = -> + parts = [] + parts.push rand_choose(cities) if chance 20 + parts.push rand_choose(subgenres) if chance 70 + parts.push rand_choose(subgenres) + parts.push rand_choose(genres) + genre = parts.join(' ') + $('#genre a').text(genre) + $('title').text('Listen to ' + genre) + +$(document).ready -> + $('#genre a').click(generate_genre) + generate_genre() + + diff --git a/gg.pl b/gg.pl deleted file mode 100755 index 0df4ef6..0000000 --- a/gg.pl +++ /dev/null @@ -1,285 +0,0 @@ -#!/usr/bin/env perl -use Mojolicious::Lite; -use Data::Random qw(rand_enum); - -my @genres = ( - 'Aggrotech', - 'Ambient', - 'Beat', - 'Bluegrass', - 'Blues', - 'Chiptune', - 'Core', - 'Country', - 'Cumbia', - 'Dance', - 'Dancehall', - 'Drum and Bass', - 'Dub', - 'Dubstep', - 'EBM', - 'Flamenco', - 'Grunge', - 'Goa', - 'Gospel', - 'Hardstyle', - 'Hip-hop', - 'House', - 'Humppa', - 'Industrial', - 'Jazz', - 'Metal', - 'Oi!', - 'Polka', - 'Pop', - 'Punk', - 'Rap', - 'Rave', - 'Reggae', - 'Rockabilly', - 'Samba', - 'Schranz', - 'Ska', - 'Soul', - 'Techhouse', - 'Techno', - 'Tekkno', - 'Trance', - 'Triphop', - 'Twostep', - 'Western', -); - -my @subgenres = ( - '30s', - '40s', - '50s', - '60s', - '70s', - '80s', - 'Acid', - 'Alternative', - 'Ambient', - 'Anatolian', - 'Arena', - 'Art', - 'Australian', - 'Australian', - 'Avantgarde', - 'Balearic', - 'Balkan', - 'Battle', - 'Black', - 'Body', - 'Bossa nova', - 'Brit', - 'Celtic', - 'Chinese', - 'Christian', - 'Comedy', - 'Conscious', - 'Cow', - 'Crust', - 'Dark', - 'Death', - 'Dirty', - 'Doom', - 'Drone', - 'East Coast', - 'Electroclash', - 'Electronic', - 'Emo', - 'Euro', - 'Experimental', - 'Extreme', - 'Flower', - 'Folk', - 'Free', - 'Freestyle', - 'Fucking', - 'Fun', - 'Funk', - 'Fusion', - 'Future', - 'Gangsta', - 'Garage', - 'Ghetto', - 'Glam', - 'Gospel', - 'Gothic', - 'Grind', - 'Groove', - 'Happy', - 'Hard', - 'Hardcore', - 'Harmonica', - 'Handsup', - 'Heavy', - 'Horror', - 'Indian', - 'Indie', - 'Independent', - 'Industrial', - 'Instrumental', - 'Latin', - 'Lounge', - 'Mainstream', - 'Medieval', - 'Melodic', - 'Minimal', - 'Neo', - 'New age', - 'Ninja', - 'Nintendo', - 'Noise', - 'Nu', - 'Pagan', - 'Pirate', - 'Post', - 'Power', - 'Progressive', - 'Psychedelic', - 'Skate', - 'Sludge', - 'Southern', - 'Space', - 'Speed', - 'Stoner', - 'Street', - 'Sunshine', - 'Surf', - 'Swedish', - 'Swing', - 'Symphonic', - 'Synth', - 'Teutonic', - 'Traditional', - 'Trash', - 'Viking', - 'Vocal', - 'Wave', - 'West Coast', - 'World', -); - -my @cities = ( - 'Berlin', - 'Bakersfield', - 'Detroit', - 'Frankfurt', - 'Gothenburg', - 'Ibiza', - 'London', - 'New Orleans', - 'Rio', - 'Rotterdam', - 'San Francisco', -); - -sub chance { - my ($percent) = @_; - return int(rand 101) <= $percent; -} - -sub generate { - my @genre; - - push @genre, rand_enum(set => \@cities) if chance 10; - push @genre, rand_enum(set => \@subgenres) if chance 70; - push @genre, rand_enum(set => \@subgenres); - push @genre, rand_enum(set => \@genres); - - return join ' ', @genre; -} - -get '/' => sub { - my ($self) = @_; - $self->render('index', genre => generate()); -}; - -get '/plain' => sub { - my ($self) = @_; - $self->render(text => generate()); -}; - -app->start; - -__DATA__ - -@@ index.html.ep - - - - - Listen to <%= $genre %> - - - - - -
Listen to
- -
<%= $genre %>
- -
- - -
-
- -
- Created by - xeno - and - mxey - | - fork me on github -
- - - - -@@ style.css - -* { - margin: 0px; - padding: 0px; -} - -body, html { - font-family: sans-serif; - text-align: center; -} - -#title { - margin-top: 50px; - font-size: 50px; -} - -#genre { - margin-top: 50px; - font-size: 50px; - font-weight: bold; - color: #666; -} - -#twitter { - margin-top: 80px; - margin-left: 18px; -} - -#impressum { - margin-top: 5px; - font-size: 10px; - color: #999; -} - -a { - color: #666; - text-decoration: none; -} diff --git a/index.html b/index.html new file mode 100644 index 0000000..d9efcec --- /dev/null +++ b/index.html @@ -0,0 +1,25 @@ + + + + + + + + + + +
Listen to
+ +
+ +
+ Created by + xeno + and + mxey + | + fork me on github +
+ + + diff --git a/style.css b/style.css new file mode 100644 index 0000000..79f391a --- /dev/null +++ b/style.css @@ -0,0 +1,37 @@ +* { + margin: 0px; + padding: 0px; +} + +body, html { + font-family: sans-serif; + text-align: center; +} + +#title { + margin-top: 50px; + font-size: 50px; +} + +#genre { + margin-top: 50px; + font-size: 50px; + font-weight: bold; + color: #666; +} + +#twitter { + margin-top: 80px; + margin-left: 18px; +} + +#impressum { + margin-top: 5px; + font-size: 10px; + color: #999; +} + +a { + color: #666; + text-decoration: none; +}