Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
ip2k
committed
Sep 7, 2011
1 parent
a53a851
commit 0e45e6f
Showing
11 changed files
with
193 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
GEM | ||
remote: http://rubygems.org/ | ||
specs: | ||
git (1.2.5) | ||
jeweler (1.6.4) | ||
bundler (~> 1.0) | ||
git (>= 1.2.5) | ||
rake | ||
rake (0.9.2) | ||
sqlite3 (1.3.4) | ||
|
||
PLATFORMS | ||
ruby | ||
|
||
DEPENDENCIES | ||
bundler (~> 1.0.0) | ||
jeweler (~> 1.6.4) | ||
sqlite3 |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.1.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#!/usr/bin/env ruby | ||
require 'sqlite3' | ||
|
||
# set our filename and path names up | ||
DBNAME = 'til.sqlite' # filename for SQLite DB | ||
DBPATH = '~/.til/' # with trailing slash | ||
|
||
# computed paths | ||
FULL_PATH = File.expand_path( DBPATH ) | ||
FULL_NAME = File.expand_path( DBPATH + DBNAME ) | ||
|
||
# sort our our directory | ||
begin | ||
Dir.mkdir( FULL_PATH ) unless File::directory?( FULL_PATH ) | ||
rescue | ||
abort "Can't create directory: #{FULL_PATH}. Maybe it's already a file or exists but isn't writable by you?" | ||
end | ||
|
||
db = SQLite3::Database.new( FULL_NAME ) | ||
|
||
puts 'What did you learn today? Press ^d (ctrl+d) when done.' | ||
til = STDIN.read # let the user type and insert \n or whatever. We only stop on ^d | ||
db.transaction do |db| # wrap it in a nice clean transaction that rolls back upon failure | ||
db.execute( 'CREATE TABLE IF NOT EXISTS til (id INTEGER PRIMARY KEY, time INTEGER, data TEXT)' ) # set up the table if it isn't there | ||
db.execute( 'INSERT INTO til (time,data) VALUES (?,?)', Time.now.to_i, til ) # store the entry | ||
puts "=> Saved!\n" # tell the user that we stored the entry if nothing failed | ||
end | ||
|
||
# show 3 random past entries | ||
3.times do | ||
db.transaction do |db| | ||
max = db.get_first_value( 'SELECT MAX(id) from til' ) # find out how many entries are in the db | ||
max = Random.rand(1..max) # pick a random one between 1 and the highest ID | ||
past = db.execute( 'SELECT time,data FROM til WHERE id=?', max.to_i).flatten # get the entry (as an array, but flatten it) | ||
puts "On #{Time.at(past[0])} you learned #{past[1]}\n" # print out what you learned in the past :) | ||
end | ||
end |
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Generated by jeweler | ||
# DO NOT EDIT THIS FILE DIRECTLY | ||
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec' | ||
# -*- encoding: utf-8 -*- | ||
|
||
Gem::Specification.new do |s| | ||
s.name = %q{todayilearned} | ||
s.version = "0.1.1" | ||
|
||
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= | ||
s.authors = [%q{ip2k}] | ||
s.date = %q{2011-09-07} | ||
s.description = %q{TIL stands for "Today, I learned..." and helps you keep track of things you've learned and stores them in a SQLite file. It'll also reward you for making new entries by showing you things you've learned in the past.} | ||
s.email = %q{github@seanp2k.endjunk.com} | ||
s.executables = [%q{til}] | ||
s.extra_rdoc_files = [ | ||
"LICENSE.txt", | ||
"README.rdoc" | ||
] | ||
s.files = [ | ||
".document", | ||
"Gemfile", | ||
"Gemfile.lock", | ||
"LICENSE.txt", | ||
"README.rdoc", | ||
"Rakefile", | ||
"VERSION", | ||
"bin/til", | ||
"til.gemspec" | ||
] | ||
s.homepage = %q{http://github.com/ip2k/todayilearned} | ||
s.licenses = [%q{Creative Commons by-nc-sa}] | ||
s.require_paths = [%q{lib}] | ||
s.rubygems_version = %q{1.8.5} | ||
s.summary = %q{TIL is a "Today, I learned..." tool to record things you found interesting and show them to you later} | ||
|
||
if s.respond_to? :specification_version then | ||
s.specification_version = 3 | ||
|
||
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then | ||
s.add_runtime_dependency(%q<sqlite3>, [">= 0"]) | ||
s.add_development_dependency(%q<bundler>, ["~> 1.0.0"]) | ||
s.add_development_dependency(%q<jeweler>, ["~> 1.6.4"]) | ||
else | ||
s.add_dependency(%q<sqlite3>, [">= 0"]) | ||
s.add_dependency(%q<bundler>, ["~> 1.0.0"]) | ||
s.add_dependency(%q<jeweler>, ["~> 1.6.4"]) | ||
end | ||
else | ||
s.add_dependency(%q<sqlite3>, [">= 0"]) | ||
s.add_dependency(%q<bundler>, ["~> 1.0.0"]) | ||
s.add_dependency(%q<jeweler>, ["~> 1.6.4"]) | ||
end | ||
end | ||
|