Skip to content

Commit 21168ed

Browse files
committed
minor clean up
1 parent ba825d9 commit 21168ed

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
dailyprogrammer
22
===============
33

4-
Get the programming challenges from http://www.reddit.com/r/dailyprogrammer
4+
Get the programming challenges from http://www.reddit.com/r/dailyprogrammer.
5+
6+
The script doesn't print all links, just these with _easy_, _intermediate_, _difficult_ or _hard_ in its name.
7+
Some of the other links are announcements.
8+
Have a look at dailyprogrammer.txt to see them all.

dailyprogrammer.lua

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
local FILE_NAME = 'dailyprogrammer.txt'
2-
local T_MODES = {"easy","intermediate","difficult","hard"}
2+
local T_MODES = {'easy','intermediate','difficult','hard'}
33
local t_links = {}
44

55
function download()
66
io.write('download ... ')
77
io.flush()
88
local http = require('socket.http')
9-
local ltn12 = require('ltn12')
109

1110
local pat_entry = '<a class="title " href="([^"]+)"'
1211
local pat_next = '<a href="([^"]+)"[^>]+>next'
@@ -17,10 +16,7 @@ function download()
1716
assert(code==200)
1817

1918
for x in html:gmatch(pat_entry) do
20-
--if x:match("_challenge_") then
2119
table.insert(t_links, x)
22-
--end
23-
--print(x)
2420
end
2521

2622
next_link = html:match(pat_next)
@@ -43,7 +39,6 @@ local update = (arg[1] == 'update')
4339
local file = io.open(FILE_NAME,'r')
4440
if not file or update then download()
4541
else
46-
print('using local copy.')
4742
for link in file:lines() do
4843
table.insert(t_links, link)
4944
end
@@ -52,7 +47,7 @@ end
5247

5348
local t_mode = {}
5449
for _,x in pairs(t_links) do
55-
local mode = x:match("(difficult)") or x:match("(intermediate)") or x:match("(easy)") or x:match("(hard)")
50+
local mode = x:match('(difficult)') or x:match('(intermediate)') or x:match('(easy)') or x:match('(hard)')
5651

5752
if mode then
5853
if not t_mode[mode] then t_mode[mode] = {} end

0 commit comments

Comments
 (0)