-
Notifications
You must be signed in to change notification settings - Fork 1
/
badideas.js
202 lines (192 loc) · 3.78 KB
/
badideas.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
var words = {
noun: [
"gerbils",
"monkeys",
"textbooks",
"classes",
"sexual encounters",
"taxes",
"bad ideas",
"lamps",
"drink bottles",
"groceries",
"cars",
"apartments",
"drugs",
"hitmen",
"telephones",
"electronics",
"iPhones",
"escorts",
"restraunts",
"laptops",
"televisions",
"software development confrences",
"IP addresses",
"bitcoin",
"hard drugs",
"perscriptions",
"love"
],
platform: [
"web app",
"cloud platform",
"REST api",
"framework",
"SaaS",
"platform",
"Pebble watch face",
"iOS app",
"Andorid app",
"Windows Phone app",
"BlackBerry app",
"frontend",
"integrated development environment",
"Facebook app",
"Twiter bot",
"Reddit bot",
"Hacker News bot",
"esoteric programming language",
"serious programming language",
"domain specific langauge",
"DOS program",
"GUI",
"WYSIWYG editor",
"Widget",
"Wiki",
"Distributed cyrptocurrency",
"website",
"social media platform",
"IRC"
],
market: [
"teenagers",
"students",
"toddlers",
"single moms",
"married moms",
"couples",
"baby boomers",
"retirees",
"elderly people",
"professors",
"immigrants",
"socially disadvantaged people",
"geeks",
"nerds",
"dorks",
"Facebook addicts",
"everyone"
],
language: [
"Brainfuck",
"Ruby",
"Scala",
"Go",
"Erlang",
"Dart",
"Common Lisp",
"Rust",
"APL",
"C#",
"C++",
"C",
"Java",
"JavaScript",
"Clojure",
"Turbo Pascal",
"BASIC",
"QBasic",
"SQL",
"ASP.net",
"ASP.net on Asure",
"Git",
"Python 3.4",
"Lua",
"TI-BASIC",
"F#",
"ClojureScript",
"Ada",
"PL/I",
"AppleScript",
"ActionScript",
"PowerShell",
"Bash",
"Perl",
"Zsh",
"Csh",
"Algol",
"OCaml",
"Visual Basic"
],
verb: [
"finding",
"rating",
"creating",
"browsing",
"aggregating",
"crowdsourcing",
"connecting with",
"selling",
"buying",
"trading",
"fabricating",
"calling",
"chatting with",
"avoiding",
"generating",
"tracking"
],
helpingverb: [
"easing",
"facilitating",
"expiditing",
"monitizing"
]
};
var templates = [
"A {platform} in {language} for {verb} {noun} designed for {market}",
"A {platform} for {verb} {noun} designed by {market}, for {market}",
"A {platform} in {language} for {verb} {noun} designed by {market}",
"The next {language}",
"The next big {platform}",
"A {platform} for {market} {helpingverb} the {verb} of {noun}",
"A {noun} {verb} {platform}"
];
function random_item(array, random) {
return array[Math.floor((random / 10000) * array.length)];
}
function random_numbers() {
var numbers = [];
for (var i=0; i<7; i++) {
numbers.push((Math.random() * 10000) | 0);
}
return numbers;
}
function generate_bad_idea(randoms) {
var i = 1;
var template = random_item(templates, randoms[0]);
return template.replace(/\{([a-z]+)\}/g, function(m, k) {
return k in words ? random_item(words[k], randoms[i++]) : m;
});
}
function new_bad_idea() {
var randoms = random_numbers();
var bad_idea = generate_bad_idea(randoms);
location.hash = randoms.join(',');
document.getElementById('bad-idea').innerHTML = bad_idea;
}
if (location.hash === '')
new_bad_idea();
else
read_hash();
function read_hash() {
var randoms = location.hash.substring(1).split(',');
for (var i=0; i<randoms.length; i++) {
randoms[i] = parseInt(randoms[i]);
}
document.getElementById('bad-idea').innerHTML = generate_bad_idea(randoms);
}
window.addEventListener('hashchange', function(e) {
read_hash();
});