basics 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/basics +67 -0
- metadata +122 -0
data/bin/basics
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'open-uri'
|
4
|
+
require 'json'
|
5
|
+
require 'rainbow'
|
6
|
+
require 'console_renderer'
|
7
|
+
require 'redcarpet'
|
8
|
+
|
9
|
+
URL = "http://basics.adit.io/"
|
10
|
+
markdown = Redcarpet::Markdown.new(ConsoleRenderer)
|
11
|
+
|
12
|
+
def get(url)
|
13
|
+
begin
|
14
|
+
JSON.parse(open(url).read)
|
15
|
+
rescue OpenURI::HTTPError => e
|
16
|
+
puts (e.to_s + " with url: #{url}").color(:red)
|
17
|
+
puts "file a bug report at https://github.com/egonschiele/basics".color(:yellow)
|
18
|
+
exit
|
19
|
+
rescue
|
20
|
+
puts "ERROR! with url: #{url}".color(:red)
|
21
|
+
puts "file a bug report at https://github.com/egonschiele/basics".color(:yellow)
|
22
|
+
exit
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
case ARGV.size
|
27
|
+
when 0
|
28
|
+
puts "usage: #{$0} [term to search] [category (optional)]\nSee a list of available categories with #{$0} -l"
|
29
|
+
exit
|
30
|
+
when 1
|
31
|
+
if ARGV[0] == "-l"
|
32
|
+
puts get(URL + "categories").sort.inspect
|
33
|
+
exit
|
34
|
+
end
|
35
|
+
tips = get(URL + "search/#{ARGV[0]}")
|
36
|
+
when 2
|
37
|
+
tips = get(URL + "category_search/#{ARGV[1]}/#{ARGV[0]}")
|
38
|
+
end
|
39
|
+
|
40
|
+
if tips.size == 0
|
41
|
+
puts "NO CONTENT".color(:yellow)
|
42
|
+
exit
|
43
|
+
end
|
44
|
+
|
45
|
+
puts "CONTENTS:".color(:yellow)
|
46
|
+
|
47
|
+
prev_category = nil
|
48
|
+
|
49
|
+
tips.each do |tip|
|
50
|
+
if tip["category"] != prev_category
|
51
|
+
prev_category = tip["category"]
|
52
|
+
puts tip["category"].upcase.background(:red).foreground("#000000")
|
53
|
+
end
|
54
|
+
puts tip["title"].background(:white).foreground("#000000")
|
55
|
+
end
|
56
|
+
|
57
|
+
prev_category = nil
|
58
|
+
puts "\nDETAILS:".color(:yellow)
|
59
|
+
tips.each do |tip|
|
60
|
+
if tip["category"] != prev_category
|
61
|
+
prev_category = tip["category"]
|
62
|
+
puts tip["category"].upcase.background(:red).foreground("#000000")
|
63
|
+
end
|
64
|
+
puts tip["title"].background(:white).foreground("#000000")
|
65
|
+
puts markdown.render(tip["text"])
|
66
|
+
puts "\n\n\n"
|
67
|
+
end
|
metadata
ADDED
@@ -0,0 +1,122 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: basics
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Aditya Bhargava
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-02-01 00:00:00 -08:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: json
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :runtime
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rainbow
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
type: :runtime
|
48
|
+
version_requirements: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: redcarpet
|
51
|
+
prerelease: false
|
52
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
hash: 3
|
58
|
+
segments:
|
59
|
+
- 0
|
60
|
+
version: "0"
|
61
|
+
type: :runtime
|
62
|
+
version_requirements: *id003
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: console_renderer
|
65
|
+
prerelease: false
|
66
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
hash: 3
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
version: "0"
|
75
|
+
type: :runtime
|
76
|
+
version_requirements: *id004
|
77
|
+
description: Cheat sheets for basic programming knowledge.
|
78
|
+
email: batman@scribd.com
|
79
|
+
executables:
|
80
|
+
- basics
|
81
|
+
extensions: []
|
82
|
+
|
83
|
+
extra_rdoc_files: []
|
84
|
+
|
85
|
+
files:
|
86
|
+
- bin/basics
|
87
|
+
has_rdoc: true
|
88
|
+
homepage: https://github.com/egonSchiele/basics
|
89
|
+
licenses: []
|
90
|
+
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
hash: 3
|
102
|
+
segments:
|
103
|
+
- 0
|
104
|
+
version: "0"
|
105
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
hash: 3
|
111
|
+
segments:
|
112
|
+
- 0
|
113
|
+
version: "0"
|
114
|
+
requirements: []
|
115
|
+
|
116
|
+
rubyforge_project:
|
117
|
+
rubygems_version: 1.3.7
|
118
|
+
signing_key:
|
119
|
+
specification_version: 3
|
120
|
+
summary: Cheat sheets for basic programming knowledge.
|
121
|
+
test_files: []
|
122
|
+
|