Skip to content

Commit

Permalink
new questions, category, schema fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Tim Becker committed Mar 15, 2012
1 parent 157c8fc commit 91155b6
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 8 deletions.
4 changes: 2 additions & 2 deletions questions/map_parseInt.json
@@ -1,10 +1,10 @@
{
"question": {
"sub_category": "javascript",
"category": "backend",
"category": "programming",
"nerd_level": 2,
"text": "What does `['3','2','1','0'].map(parseInt)` evaluate to?",
"creator": "Tim Becker",
"creator": "a2800276",
"created_at": "2011-10-09",
"right_answer": "a2",
"a1": "['3', '2', '1', '0']",
Expand Down
4 changes: 2 additions & 2 deletions questions/png.json
@@ -1,5 +1,5 @@
{ "question" : {
"sub_category": "grafix",
"sub_category": "graphics",
"category": "design",
"nerd_level": 1,
"text": "What are the advantages of PNGs?",
Expand All @@ -11,4 +11,4 @@
"created_at": "2011-06-07",
"creator": "Philipp"
}
}
}
2 changes: 1 addition & 1 deletion questions/ps_save_for_web.json
@@ -1,5 +1,5 @@
{ "question" : {
"sub_category": "grafix",
"sub_category": "graphics",
"category": "design",
"nerd_level": 1,
"text": "What is the photoshop shortcut to save a web-optimized version of an image (Win/Mac)",
Expand Down
2 changes: 1 addition & 1 deletion questions/screen_image_resolution.json
@@ -1,5 +1,5 @@
{ "question" : {
"sub_category": "grafix",
"sub_category": "graphics",
"category": "design",
"nerd_level": 1,
"text": "Which image resolution should be used for screen layouts/images?",
Expand Down
15 changes: 15 additions & 0 deletions questions/size_t_header.json
@@ -0,0 +1,15 @@
{
"question": {
"sub_category": "C",
"category": "programming",
"created_at": "2012-03-15",
"right_answer": "a1",
"creator": "a2800276",
"nerd_level": 1,
"text": "Where is `size_t` defined?",
"a1": "stddef.h",
"a2": "stdarg.h",
"a3": "stdlib.h",
"a4": "stdio.h"
}
}
15 changes: 15 additions & 0 deletions questions/string_v_strings.h
@@ -0,0 +1,15 @@
{
"question": {
"sub_category": "C",
"category": "programming",
"created_at": "2012-03-15",
"right_answer": "a1",
"creator": "a2800276",
"nerd_level": 1,
"text": "Which of the following functions is NOT defined in `string.h`",
"a1": "strncasecmp",
"a2": "strncmp",
"a3": "strncat",
"a4": "memccpy"
}
}
4 changes: 2 additions & 2 deletions schema/question.json
Expand Up @@ -8,14 +8,14 @@
"type":"string",
"description":"The questions main sub_category",
"maxLength": 30,
"enum": ["culture", "backend", "frontend", "design", "startup & founding", "social" ],
"enum": ["programming", "culture", "backend", "frontend", "design", "startup & founding", "social" ],
"required":true
},
"sub_category":{
"type":"string",
"description":"The questions main sub_category",
"maxLength": 30,
"enum": ["algorithms","bash","couchdb","css", "culture", "data", "flash", "grafix", "html","http","javascript", "php", "python","rails","ruby","regex" ],
"enum": ["algorithms","bash","couchdb","css", "culture", "data", "flash", "graphics", "html","http","javascript", "php", "python","rails","ruby","regex", "C" ],
"required":true
},
"nerd_level":{
Expand Down
64 changes: 64 additions & 0 deletions tools/qbuilder.rb
@@ -0,0 +1,64 @@
#q = { question: {
#:category => "culture",
#:sub_category => "oreilly",
#:nerd_level => 1,
#:text => "The #{key} is associated with which O'Reilly books?",
#:a1 => "#{$hh[key]}",
#:created_at => "2012-03-10",
#:right_answer => "a1",
#:creator => "a2800276"
#}
#}


def read_ini
iNI = %w{creator creator_twitter creator_github nerd_level}
ini = {}
ini["created_at"] = Time.new.strftime("%Y-%m-%d")
ini["right_answer"] = "a1"
begin
_ini = File.readlines("#{ENV["HOME"]}/.nerdpursuit")
_ini.each_with_index{|l, i|
key = iNI[i]
ini[key] = l.strip if l.strip != ""
}
rescue
puts $!
puts $!.backtrace
# create_ini # TODO
STDERR.puts "please create a `~/.nerdpursuit` file containing values for:"
STDERR.puts "creator"
STDERR.puts "creator_twitter (optional)"
STDERR.puts "creator_github (optional)"
STDERR.puts "nerd_level (optional)"

exit 1
end
@ini = ini
end

def die msg
STDERR.puts msg
exit 1
end

def make_q lns
h = {}
flds = %w{text a1 a2 a3 a4 category sub_category nerd_level}
lns.each_with_index {|l,i|
die "empty line #{i}" if l.strip! == ""
h[flds[i]] = l
}
q = @ini.merge(h)
q["nerd_level"] = q["nerd_level"].to_i if q["nerd_level"]
require 'json'
JSON.pretty_generate({:question => q})
end

if $0 == __FILE__
read_ini
fn = ARGV[0]
ln = File.readlines(fn)
puts make_q ln

end

0 comments on commit 91155b6

Please sign in to comment.