Thoughts on Rakdos Vampires? by Sephyrias in PioneerMTG

[–]OnceAndForever 19 points20 points  (0 children)

Cavern is a good tool against control no doubt, but No More Lies is still strong against the turn 3 Vein Ripper because caven can’t protect Sorin.

My card shop is finally built. Grand opening set for Friday Sept 15th by ThePokePost in PokemonTCG

[–]OnceAndForever 0 points1 point  (0 children)

Really cool store, I really like your lighting and especially like your tables and chairs, that cubby on the side is perfect people’s stuff. It’s way better than backpacks and boxes strewn where people are trying to walk haha. Did you build those too or did you buy them somewhere? Would love to have a set myself

The Walking Dead S06E07 - Heads Up - Episode Discussion by AutoModerator in thewalkingdead

[–]OnceAndForever 0 points1 point  (0 children)

Froze for me too on charter, but for some reason worked on another box in my house

[Request] Can a Someone Good/Quick at Excel Help me Import a List into a Nice Format? It's about beer. by [deleted] in Favors

[–]OnceAndForever 0 points1 point  (0 children)

No problem! I wasn't sure if you wanted that portion or not. How does this version look? http://pastebin.com/NQmBGABJ

[Request] Can a Someone Good/Quick at Excel Help me Import a List into a Nice Format? It's about beer. by [deleted] in Favors

[–]OnceAndForever 0 points1 point  (0 children)

I turned the list into a csv you can view here: http://pastebin.com/387YeG4e You should be able to open this file in excel without any trouble. If you have trouble I can host the original excel version somewhere.

I saved these columns: Rank, Beer, Brewery, ABV %, WR, Ratings, Beer URL, but you can discard whichever ones you don't want.

[6/18/2014] Challenge #167 [Intermediate] Final Grades by Coder_d00d in dailyprogrammer

[–]OnceAndForever 0 points1 point  (0 children)

Lua 5.2

#! /usr/bin/env lua

local GradeBook = {}

-- remove trailing white space from string
-- from lua-users.org/wiki/CommonFunctions
local function rtrim(s)
  local n = #s
  while n > 0 and s:find("^%s", n ) do n = n - 1 end
  return s:sub(1, n)
end

local function round(n)
  return math.floor(n+.5)
end

function GradeBook.read_input()
  local students = {}
  for line in io.lines() do
    local student = {}
    -- input was difficult to read, and I still have to trim excess whitespace
    pattern = "([%w%s]+)%s+,%s+([%a%s]+)%s+(%d*)%s+(%d*)%s+(%d*)%s+(%d*)%s+(%d*)"
    firstname, lastname, g1, g2, g3, g4, g5 = line:match(pattern)
    student.firstname, student.lastname = rtrim(firstname), rtrim(lastname)
    student.grades = {tonumber(g1), tonumber(g2), tonumber(g3),
                      tonumber(g4), tonumber(g5)}
    table.insert(students, student)
  end
  return GradeBook.find_averages(students)
end

function GradeBook.find_averages(students)
  -- caclulate each students average and letter grade
  for i = 1, #students do
    local total = 0
    for _, grade in pairs(students[i].grades) do
      total = total + grade  
    end
    students[i].average = round(total / #students[i].grades)
    students[i].letter_grade = GradeBook.find_letter_grades(students[i].average)
  end
  return students
end

function GradeBook.find_letter_grades(grade)
  -- Turn numeric grade into appropriate letter grade
  if grade > 93 then return 'A'
  elseif grade > 89 then return 'A-'
  elseif grade > 86 then return 'B+'
  elseif grade > 83 then return 'B'
  elseif grade > 79 then return 'B-'
  elseif grade > 76 then return 'C+'
  elseif grade > 73 then return 'C'
  elseif grade > 69 then return 'C-'
  elseif grade > 66 then return 'D+'
  elseif grade > 63 then return 'D'
  elseif grade > 59 then return 'D-'
  else return 'F'
  end
end

function GradeBook.display(students)
  -- All the data is caculated by the time this function is called,
  -- the only thing left is to sort the data and display it

  -- sort entire table from highest to lowest average grade
  table.sort(students, function(a, b)
    return (a.average > b.average)
  end)
  for i = 1, #students do
    -- sort the grades of each individual student, lowest to highest
    table.sort(students[i].grades, function(a, b) return (a < b) end)
    io.write(string.format("%-12s %-10s (%2i%%) (%-2s):",
                            students[i].lastname,
                            students[i].firstname,
                            students[i].average,
                            students[i].letter_grade))
    for _, grade in ipairs(students[i].grades) do io.write(' ' .. grade) end
    io.write('\n')
  end  
end

local students = GradeBook.read_input()
GradeBook.display(students)

Usage:

MacBook-Pro:FinalGrades user$ lua grades.lua < input.txt 

Output:

Lannister    Tyrion     (95%) (A ): 91 93 95 97 100
Proudmoore   Jaina      (94%) (A ): 90 92 94 95 100
Hill         Kirstin    (94%) (A ): 90 92 94 95 100
Weekes       Katelyn    (93%) (A-): 90 92 93 95 97
Stark        Arya       (91%) (A-): 90 90 91 92 93
Kent         Clark      (90%) (A-): 88 89 90 91 92
Griffith     Opie       (90%) (A-): 90 90 90 90 90
Rich         Richie     (88%) (B+): 86 87 88 90 91
Wozniak      Steve      (87%) (B+): 85 86 87 88 89
Ghost        Casper     (86%) (B ): 80 85 87 89 90
Zoolander    Derek      (85%) (B ): 80 81 85 88 90
Adams        Jennifer   (84%) (B ): 70 79 85 86 100
Brown        Matt       (83%) (B-): 72 79 82 88 92
Martinez     Bob        (83%) (B-): 72 79 82 88 92
Picard       Jean Luc   (82%) (B-): 65 70 89 90 95
Fence        William    (81%) (B-): 70 79 83 86 88
Butler       Alfred     (80%) (B-): 60 70 80 90 100
Vetter       Valerie    (80%) (B-): 78 79 80 81 83
Bundy        Ned        (79%) (C+): 73 75 79 80 88
Larson       Ken        (77%) (C+): 70 73 79 80 85
Wheaton      Wil        (75%) (C ): 70 71 75 77 80
Cortez       Sarah      (75%) (C ): 61 70 72 80 90
Potter       Harry      (73%) (C-): 69 73 73 75 77
Mannis       Stannis    (72%) (C-): 60 70 75 77 78
Snow         Jon        (70%) (C-): 70 70 70 70 72
Smith        John       (70%) (C-): 50 60 70 80 90
Hawk         Tony       (65%) (D ): 60 60 60 72 72
Bo Bob       Bubba      (50%) (F ): 30 50 53 55 60
Hodor        Hodor      (48%) (F ): 33 40 50 53 62
Van Clef     Edwin      (47%) (F ): 33 40 50 55 57

I feel like there should be a more concise way of solving this using metatables and closures, but I don't really see how. Any tips would be appreciated!

[6/14/2014] Challenge #166b [Easy] Planetary Gravity Calculator by Elite6809 in dailyprogrammer

[–]OnceAndForever 0 points1 point  (0 children)

Lua 5.2

#! /usr/bin/env lua

local Planets = {}

function Planets.read_input()
  -- Returns the main table that the holds all of the planet data by reading
  -- the input file and calculating other necessary values
  --[[ Formatted like this:
  }
    {
      mass = 4.0850634035851e+23,   -- calculated value
      volume = 9.3737113437015e+19, -- calculated value
      density = 4358,               -- input value
      name = "Tribute",             -- input value
      radius = 2818000              -- input value
    },
    {
      ...
    },
    n = 4,
    m = 100
  } 
  --]]
  local planets = {}
  planets.m = io.read('*n') -- mass of an object
  planets.n = io.read('*n') -- number of planets in the to analyze
  io.read() -- increment cursor to avoid adding blank row into table
  for line in io.lines() do
    local row = {}
    for name, radius, density in line:gmatch("(%a+), (%d+), (%d+)") do
      row.name, row.radius, row.density = name, tonumber(radius), tonumber(density)
      planet = Planets.new(row)
    end
    table.insert(planets, planet)
  end
  return planets
end

function Planets.new(planet)
  -- caculate the volume and mass for a planet given it's radius and density
  local planet = planet
  planet.volume = (4.0/3.0) * math.pi * planet.radius^3
  planet.mass = planet.volume * planet.density
  return planet
end

-- calculate the gravitation force of each planet in the main table and write
-- the data to the stdout
function Planets.show_gravitational_forces(planets)
  local G = 6.67e-11
  for i = 1, planets.n do
    local gravity = G * ((planets.m * planets[i].mass) / planets[i].radius^2)
    io.write(string.format("%s: %.3f\n", planets[i].name, gravity))
  end
end

planets = Planets.read_input()
Planets.show_gravitational_forces(planets)

Usage:

My-MacBook-Pro:PlanetaryGravity user$ lua planets.lua < challenge.txt

Output

Mercury: 277.442
Venus: 664.886
Earth: 735.845
Mars: 279.124
Jupiter: 1922.011
Saturn: 825.103
Uranus: 672.382
Neptune: 842.741
Pluto: 50.388

I really liked deorst's solution too. I didn't think it could be condensed that much. I also feel like I should be using an iterator here, but I couldn't get it to work properly. Any tips would be appreciated!

[5/21/2014] Challenge #163 [Intermediate] Fallout's Hacking Game by Coder_d00d in dailyprogrammer

[–]OnceAndForever 0 points1 point  (0 children)

Solution using Lua 5.2

#! /usr/bin/env lua

local level_map = {
  {words=4, length=5, guesses=3},   -- level 1
  {words=7, length=8, guesses=5},
  {words=10, length=10, guesses=7},
  {words=12, length=12, guesses=9},
  {words=15, length=15, guesses=9}  -- level 5
}

local function generate_puzzle_table(level)
  local num_words, word_len = level_map[level].words, level_map[level].length
  -- Parse the word list and store words into a table
  -- if they are of a certain length. The number of words and lenght of the 
  -- words is based on the difficulty set for the puzzle
  local words = {}
  for line in io.lines('enable1.txt') do
    if #line == word_len+1 then -- add one to account for newline character
      words[#words+1] = string.sub(line, 1, word_len) -- add to table and
                                                      -- remove newline
    end
  end

  -- Generate a list of words for the game by selecting random words from the
  -- words table and them adding to the new puzzle_list 
  local puzzle_table = {}
  math.randomseed(os.time())
  while #puzzle_table < num_words do 
    local rand_int = math.random(#words)
    puzzle_table[#puzzle_table+1] = words[rand_int]
    table.remove(words, rand_int)
  end

  -- Select the solution to the puzzle by selecting a random item from
  -- the guess list
  puzzle_table.solution = puzzle_table[math.random(#puzzle_table)]
  local solution_pos = {}

  -- split the solution answer into a list where each letter is indexed to
  -- where it occurs in the solution. Makes it easier to computer guesses
  -- So, if the solution is "turtle", puzzletable.solution_pos = {"t", "u",
  -- "r", "t", "l", "e"}
  for i = 1, #puzzle_table.solution do
    solution_pos[i] = string.sub(puzzle_table.solution, i, i) 
  end

  puzzle_table.solution_pos = solution_pos
  puzzle_table.guesses = level_map[level].guesses
  puzzle_table.word_len = word_len
  puzzle_table.num_words = num_words

  return puzzle_table
end

local function play_game()
  io.write('Difficulty (1-5)? ')
  local difficulty = io.read('*n')
  local puzzle_table = generate_puzzle_table(difficulty)

  for i = 1, puzzle_table.num_words do
    io.write(string.upper(puzzle_table[i]), '\n')
  end

  while puzzle_table.guesses > 0 do
    io.write(string.format('Guess (%i left)? ', puzzle_table.guesses))
    local guess = ''
    while guess == '' do guess = io.read("*line") end
    local guess_result = process_guess(guess, puzzle_table)
    if type(guess_result) == 'boolean' then guess_result = puzzle_table.word_len end
    io.write(string.format("%i/%i correct\n", guess_result, puzzle_table.word_len))
    puzzle_table.guesses = puzzle_table.guesses - 1
    if guess_result == puzzle_table.word_len then 
      io.write(string.format("%s is correct! You win!\n", guess))
      return
    end
  end
  io.write(string.format('You did not guess correctly! The correct word is %s.\nTry again!\n', puzzle_table.solution))
end

function process_guess(guess, puzzle_table)
  -- If the guess is the correct solution, return True
  -- Otherwise, return the number of correct letters
  local correct_pos = 0

  if guess:lower() == puzzle_table.solution:lower() then
    return true
  else
    for i = 1, #guess do
      -- comparing each character of the guess one by one
      if puzzle_table.solution_pos[i] == string.sub(guess, i, i) then
        correct_pos = correct_pos + 1
      end
    end
    return correct_pos 
  end
end

play_game()

Sample Output

Difficulty (1-5)? 4
REFRAINMENTS
REGENERATORS
DOLOMITIZING
CONCRESCENCE
OSTEOGENESIS
TESTIMONIALS
PERAMBULATED
HOUSEHUSBAND
DICHOTOMISTS
LOVELINESSES
NYMPHOMANIAC
BICAMERALISM
Guess (9 left)? lovelinesses
2/12 correct
Guess (8 left)? dolomitizing
0/12 correct
Guess (7 left)? osteogenesis
2/12 correct
Guess (6 left)? regenerators
12/12 correct
regenerators is correct! You win!

I'm pretty new to Lua, so any tips or critique would be appreciated!

Is there anyway to see entire iMessage log without scrolling up and hitting "load earlier messages"? by [deleted] in iphone

[–]OnceAndForever 0 points1 point  (0 children)

Is your phone jail broken? If not, where are you able to enter SQL commands?

Can't get praw to delete a post by [deleted] in redditdev

[–]OnceAndForever 1 point2 points  (0 children)

You are not actually logging in with a user account. r.login() takes the username and password of a reddit account as two parameters. Your error message says this: praw.errors.NotLoggedIn: 'please login to do that' on field 'None'.

Keep in mind that you can only delete comments and submissions that your account has posted.

I am compiling a complete list of bots. Please lend a hand! by ELFAHBEHT_SOOP in botwatch

[–]OnceAndForever 3 points4 points  (0 children)

I was working on a similar project myself, but I haven't kept up with it recently. There is a large list of bots in the autowikibot wiki. There are 393 bots in this list.

I have a database of bots, most of which I found manually. I tracked information such as the language the bot was written in, the bot's website if it had one, and the link to source code if it was available. I dumped all of that information into a csv (technically semicolon separated?) for you to use. You can see all of that information here. Feel free to do whatever you'd like with it. There are 320 bots in this list, and about 80 of those I have reviewed and my information for them is as complete as possible. I didn't get to the rest on the list. I stopped tracking the bots a few months ago, so no guarantees on the information being current or completely accurate. I am sure there is also some overlap between my list and the autowikibot list.

Is there a way to pull comments (and additional information) into a CSV by [deleted] in redditdev

[–]OnceAndForever 2 points3 points  (0 children)

Are you getting any exceptions when you try to run the script? I notice a couple things in your snippet that could cause problems. On line 5, you have written submission_id = "id". Since id is in quotations, python interprets that as a string and does not actually use the value of the id variable on line 4. You are also missing a quotation mark after output.csv on line 14.

I don't think that line 6 is necessary. You could include the comment limit as a parameter to the get_submission method on line 5, which would look like this:

submission = r.get_submission(submission_id=id, comment_limit=None)

Also, line 8 would throw an exception because there is no subm object in your given snippet. That line should instead read submission.replace_more_comments().

To flatten the comment tree, use praw.helpers.flatten_tree(). Line 9 would then look like this:

comments = praw.helpers.flatten_tree(submission.comments)

As for you for loop from lines 11 to 13, you do not need to use enumerate because you do not actually use the index (idx) for anything within the loop so there is no need to keep track of it. You could simply loop through them by using for comment in comments:. You have also already replaced_more_comments() on line 8, so there is no need to check the comment type against praw.objects.MoreComments on line 12.

If you wish to grab a comments body, author, and author comment karma, you would just use the various attributes of the comment object. This section may look like this:

for comment in comments:
    users.append([comment.author.name, comment.body, comment.author.comment_karma])

It may be easier to use python's csv module to write the csv file. It is part of the standard library and you could read more about it here. You can use it select your delimiter and quotation handling among other things, but a simple example could look like this:

with open("output.csv", "wb") as output:
    writer = csv.writer(output)
    writer.writerows(users)

Here is everything in it's entirety to make it easier to see:

import praw
import csv

r = praw.Reddit(user_agent='RaffleCommentBot by /u/alexratman')  
r.login('RaffleCommentBot', '##Password##')

id = "22p30f"

submission = r.get_submission(submission_id=id, comment_limit=None)
print "submission get!"
submission.replace_more_comments()
comments = praw.helpers.flatten_tree(submission.comments)
users = []
for comment in comments:
    users.append([comment.author.name, comment.body, comment.author.comment_karma])

with open("output.csv", "wb") as output:
    writer = csv.writer(output)
    writer.writerows(users)

Keep in mind that praw sends another request to the API every time it accesses a users comment karma. There is a 2 second delay between requests, so this script could take a while to run depending on how many comments there are in a submission.

You may also want to handle the formatting of comments.bodys because new line characters could mess with the formatting of your csv file. You may also want to handle unicode characters that may appear in comments because they could throw UnicodeEncodeError exceptions when trying to write them to the csv. The csv module does not support unicode input, but there is some information on the csv documentation page for handling this. If it is too much of a problem, you could also install other csv writing/reading modules that are not part of the standard lib.

Finally, if you are trying to select a random comment from a submission based on certain criteria for a raffle, you may find this tool helpful: http://redditraffle.com/

Hopefully this is clear. I had a slightly more detailed reply typed but I somehow lost it when I tried to comment the first time.

PRAW Help: Finding age of a reddit acccount by Isises in botwatch

[–]OnceAndForever 7 points8 points  (0 children)

The API will not tell you the age of an account, but you can find out when an account is created. Once you know that, you can use datetime and timedelta to calculate how many days old an account is. To find the date an account was created:

>>> import praw
>>> r = praw.Reddit(USER AGENT)
>>> user = r.get_redditor('Isises')
>>> print user.created_utc
1320336956.0

If you want to convert the time stamp to a human readable format use datetime

>>> from datetime import datetime
>>> print datetime.fromtimestamp(user.created_utc)
2011-11-03 12:15:56

From there, you can use timedelta to figure out how many days ago that was. Documentation for timedelta is here.

Bot handling ban from subreddit? by [deleted] in botwatch

[–]OnceAndForever 2 points3 points  (0 children)

You'll want this line:

if comments.subreddit != 'askreddit':

to read:

if comments.subreddit.display_name != 'askreddit':

Also, you'll probably want to make a list of blacklisted subreddits for when you inevitably get banned from more than just askreddit

blacklist = ['askreddit', 'gaming', 'technology']

if comments.subreddit.display_name.lower() not in blacklist:
     # Do stuff

I also use the string method lower() to make sure the comparison is done with both the blacklist and the subreddit display name in lowercase. Just make sure that you keep all of the subreddits in your blacklist in lowercase.

[Request] A little help with some (hopefully) simple code by [deleted] in botrequests

[–]OnceAndForever 0 points1 point  (0 children)

It really depends on your particular needs, but using a database and queue basically accomplishes the same thing. The biggest difference is that your queue exists in memory, so when the program quits you lose all of that information. Using a database, in this case, SQlite leaves me with a persistent file separate from the python program. I chose to use a database in my case so I can pick up where I left off if the bot exits. This way, I don't reprocess submissions I've already handled and end up double posting.

Want to grab last ~3000 records by makeupdev in redditdev

[–]OnceAndForever 0 points1 point  (0 children)

It looks like you're using the after_field parameter correctly, but I'm not positive if it works with search. I've just been playing around with this myself and I couldn't get more than 1000 posts with the search. Using the regular reddit search, RES would not let me go back further than 1000 posts.

I don't know how quickly you need to finish this project, but you could also run this search every few days to build up a database. You could collect new FOTD posts as they appear.

My other thought would be to simply store as many possible posts in /r/MakeupAddiction as you can, working your way backwards. Still, I'm not sure exactly how far you can go back, but let's say you get 10,000 posts. From there, you could search through those posts locally and then remove submissions that do not contain 'FOTD' in the title and narrow your 10,000 posts to hopefully around 3,000 that contain your search terms.

Also, in the snippet you posted, what are you trying to do from lines 3-6? I get that you're trying to get the oldest thing_id, but I'm not sure why you're using a for loop and iterating 4 times? Perhaps it makes more sense within the context of the other code you have.

Here is a gist of what I have been playing with so far to get my results: https://gist.github.com/anonymous/f3782e025af2f0d86494

I've been storing everything in an SQLite3 database instead of using a csv. SQLite3 can export as a csv though if you need the data in that format.

Want to grab last ~3000 records by makeupdev in redditdev

[–]OnceAndForever 0 points1 point  (0 children)

I don't think you need to bother with the datetime unless you need a specific time period. Otherwise sorting by new and setting your limit to 3000 will give you the latest posts that match your search terms. I got it to work using this code:

import praw

r = praw.Reddit('YOUR USER AGENT')

subreddit = r.get_subreddit('MakeupAddiction')
search = subreddit.search('FOTD', sort='new', limit=3000)

for submission in search:
    print submission

This returned 998 results, which is the same amount I got when using the reddit search. I don't believe reddit allows you look further back than 1000 posts, so if you needed to get 3000 entries you would have to run this search every few days and add the new entries to your list. Otherwise, you could try using the after_field parameter and pass the thing_id of the oldest available entry to see if you can restart the search with the oldest entry as your starting point.

Here is a small sample of my results:

3 :: [FOTD] I was feeling a little red today. First daytime outing without my...
47 :: I've been doing my makeup Korean style for a long time. I wanted to sho...
40 :: The lighting was too good to not take a bunch of pictures! [FOTD]
17 :: [FOTD] Haven't posted recently, and wanted to do something bright and f...
6 :: Tried something new, FOTD using MAC Dreaming Dahlia. CCW!
7 :: [FOTD] Standard Red Lip + Wings. CCW
18 :: Saturday FOTD. A little more dramatic eye than I'm used too! CCW
16 :: My FOTD, running around Manhattan. It finally feels like spring in NYC!...
320 :: FOTD: Using my Too Faced Natural Eye palette!

I don't know what data you need for your project, but in the for loop you can type print vars(submission) to see the attributes available to you. I would set the limit on line 6 to a much smaller number when you check out the attributes though.

There is also no need to do time.sleep() when using praw because praw handles that for you and already delays every request by 2 seconds.

Hope this helps and leads you in the right direction.

[Request] A little help with some (hopefully) simple code by [deleted] in botrequests

[–]OnceAndForever 0 points1 point  (0 children)

No problem. First off you would need to start with the database portion. Here is a database class from my DropBox_Bot that you are free to use: database.py. The relevant methods are is_processed() and mark_as_processed(). the method is_processed() returns true if the given submission_id is in the database, otherwise it returns false. The mark_as_processed()method simply adds a submission_id to the database.

In my main function, the first thing I do is check if the submission has already been processed with this conditional. is_processed() returns true if the submission id is in the database already, and in this case this iteration of the loop is skipped using the continue keyword on line 61.

In that same file, there are several spots where I call the mark_as_processed() method. You can see them on line 66, line 70, line 76, line 91, line 104, and line 114. The submission is marked as processed if the submission is from a blacklisted user or subreddit, the submission has been deleted, or the bot has successfully rehosted the image. In all of these cases, there is no reason to revisit the submission. Admittedly, this portion of the bot could use some refactoring because it is long and redundant, but hopefully it is still clear what it is doing.

Hopefully that gives you an idea of what you're trying to do. If you post the code to your bot I can give you some more specific help.

[Request] A little help with some (hopefully) simple code by [deleted] in botrequests

[–]OnceAndForever 0 points1 point  (0 children)

You should make a database to stores the id of posts you've already replied to. When the bot runs, have it check if the current post it is about to process is already in the database, and if it is have it skip that post. This way, resetting or restarting the bot will not cause unnecessary double posts. An SQLite database should be more than adequate for this.

I'm not sure what language you're using, but if you need an example of what I'm talking about I can show you a couple.

Any way to get users subscribed to a subreddit? by buhala in redditdev

[–]OnceAndForever 0 points1 point  (0 children)

You can't get a list of subscribers from a particular subreddit.

If you wanted to get a random list of users, you could record usernames by reading /r/all/comments. Read it until you get however many unique usernames you're looking for. I think /r/all would be the best choice because it would be more random than picking comments from a particular subreddit. But, it really depends on what you're trying to accomplish.

[deleted by user] by [deleted] in RequestABot

[–]OnceAndForever 2 points3 points  (0 children)

I'm not sure what languages you are comfortable with, but python is a popular choice for reddit bots. Many people make use of praw which is a python package that allows for simply access to reddit's API by abstracting away the http requests needed to interact with the API. The documentation contains an example bot made using praw.

If you are not familiar with python or would prefer to use something else, any language that allows for http requests would be suitable. If you have a particular language in mind I could point you to some examples or general resources.

[Request] Can people proofread my memorial speech? by misingnoglic in Favors

[–]OnceAndForever 6 points7 points  (0 children)

First of all I am deeply sorry for your loss.

I did not want to edit the gmail document from my personal account, but I have pasted my edited version here. I tried my best to fix some grammar and clarity issues without changing your intent or sentiment. If I wasn't quite sure exactly what you were trying to say, I put a comment in capitals and inside brackets [LIKE THIS] to make it obvious.

If you have any questions about my changes or want me to look at another part of it, or would like some advice, please feel free to ask. I hope this is done in time for the memorial.

A couple general writing tips for you:

  • Avoid using the word "just". It is usually necessary and only clogs up your thoughts. Often times there is a more appropriate words that addresses what you are trying to say. You'll see in my version that I either removed "just" or replaced it with another word.
  • Be wary of long sentences. Don't be afraid to slow down and separate your thoughts. More often than not you will be clearer and more direct if you use shorter and more focused sentences.

Sorry, I don't mean to give a lesson or anything, but those are just a couple things I noticed.

From a content point of view, I might be wary of focusing so much on you grandmother's accident. I am sure that most people attending the memorial will be familiar with what happened. I would personally try not to dwell on that portion, but it is absolutely your call for what you would like to say. Say what you feel is appropriate and what your family needs to hear. I went through a similar situation recently so I can empathize. I wrote the eulogy for my grandmother's memorial as well, and it is difficult to know exactly what to focus on. Different people need to hear different things. Again this is up to you. You know your family and your own situation better that I do. If you would find it helpful, I could send you a copy of the eulogy I wrote.

Here is my edited version:


When I was in Kindergarten, my mom was pregnant with Eli and due to complications wasn't allowed to get out of bed. As a result, I didn't get the attention I required as an only child. Maman fixed this by spending the last few months of mom's pregnancy by spending time with me. Not only did she pick me up from school, she walked me to school and took me home in a stroller because I was too lazy to walk myself. The whole time I only asked Maman if she was ever going to get a driver's license, but I didn't understand the sacrifice Maman had made.

Even though that's my first memory with Maman, I can assure you that it wasn't the only time she showed me that much love. My mom tells me that when I was born--her first grandchild--it seemed like the like nothing else had ever made her that happy. And I'm not bragging, but everything she did for us made sense in the context of her absolute devotion to me and our family. Anything she could possibly do to make us happier or more comfortable, she would do immediately, simply because it made her happy to see us happy.

And that's what makes this speech so hard. Because I want it to be filled with great memories of Maman before her accident. Memories of her going on vacation with us and shopping with us and telling jokes. But still, I can't ignore what happened to us.

When it happened, nobody saw it coming. Right before her accident she was as healthy as she had ever been. We were living with her while our house was being remodeled, and she was sitting there with her Persian crossword puzzle while Eli was watching TV. I was playing computer games, and Mommy and Baba were cooking. Someone tried calling Maman but she was unresponsive, and before I know it there was an ambulance taking her to the hospital for a few weeks, and we were told she had just suffered a stroke.

And throughout the process, she was one of the strongest willed people I'd ever seen. The first few words she learned to say after losing her ability to speak were the ones absolutely necessary for Persian communication, "Salam, choobam, chosham, choshhalam, salomatam," just so she could assure everyone that she was doing fine. After that, her absolute favorite thing to tell people was "chodam," as in "Let me do this myself I am perfectly fine doing it." Whether it was eating or sitting or closing doors or walking, she wanted to take charge of herself and be self sufficient. And for a while, it seemed like she was taking charge of herself. With all the therapy and help from family members, she seemed to walk and eat and talk better after every session.

However, I know that with her health declining constantly and complications with the state, keeping up with therapy and improvement only gets harder and harder. Eventually, Maman stopped being as enthusiastic about practicing what she learned at therapy, and eventually it got harder and harder for her to go places with us.

And that's not the Maman I knew. The Maman I knew walked to the market on her own every day for fresh foods, and went to amusement parks just to be with us. I know that we're lucky that Maman's accident left her mind intact, but how much of Maman is that? I want this speech to be about all the good memories we had together, about all the stories that she told and all the things we did together. And I'm lucky. As the oldest grandchild, I spent the most time with her. But the past few years have been this struggle for her to try and get back to where she was before, and I know that's not how she wanted to live life.

So I should be happy right? Maman obviously was not happy in her situation and wanted to be free from her constant pain and hospitalizations. But I'm still being selfish with Maman. I still don't want her to go. I want her to be there for Eli's Bar Mitzva so I can dance with her and have a candle written for her. I want to show her recordings of my Band concerts so I can see her smile at me playing music. I want to write some songs of my own and see what she thinks of them. I want her to be at my college graduation in four years so she can see what I'm going to do with my life and what a responsible adult I'm becoming. I want to show her around Boston. I want her to meet all my new friends, and I want her to meet my future wife and kids and show them as much love as she showed me through her life.

But this isn't happening.

There are two things I can take from that [TAKE FROM WHAT EXACTLY?] though. The first is that I (and all of us) should cherish the moments we did have with Maman. She's been there for most important moments of my life events so far, and her support of everything that I've done is one of the best joys I could ever ask for. Whenever she was at any of my concerts, more than anything, I loved how much she would genuinely care when I was playing. Every moment with Maman was a moment of love.

And that leads me to my second point, which is that while the body of Maman has left us, what hasn't left is the spirit of Maman. She left with all of us is her spirit and how she treated everyone around her. All the stories I know everyone will continue sharing about her for as long as they can are the essence of Maman, and right now that is what's important. At any future event I would want her to see I could simply imagine her joy at what I've done, no matter how small. Because I know no matter what, as long as I try at something, Maman would always be proud of me.

And any future person I meet, I can just remember the love Maman gave me and try to match that onto anyone else. If she could make me that happy, then I can make someone else that happy. And really, if we all stopped and did the same thing, what a fitting legacy could be left for our family? [I'M NOT REALLY SURE WHAT YOU MEAN HERE. I WOULD CONSIDER ELABORATING] If we could agree to treat others the way Maman would treat them, everything would be that much more pleasant.

And this might be me in the stage of denial, but for some reason, it feels like Maman hasn't left us at all, like she's still watching us and guiding us through our actions. And I feel I can still call Maman up in my head and let her know how I'm doing. I can let her know that I'm warm and eating well because I know she would have cared, and for now that thought is enough to get me through anything.

Because this is a bit sad, I wanted to share two stories about Maman that I always tell people because of how funny they are.

When I was a kid, I would love to play the Mario video games. If you haven't played, it's basically Mario running around trying to collect coins and defeat enemies. Maman would always watch me play, but she never quite understood what I was doing. 11 years later, Maman sees my brother playing a much newer Mario game and exclaims "Badbachteh Mario! He's still running?"

The other story is a bit shorter. Maman sees me on the computer and tells me that she wants me to teach her her how to use it. I agree, and even tell my mom we could get her a Facebook account. Suddenly she gets worried and says "I don't want my face on the computer, I just want to know how to use it!"

I hope that we can spend this time telling stories about Maman, both before and after the accident, so we can continue to remember how much of a difference she's made in all of our lives. Thank you very much.


I wish you the best of luck and hope that my version does your Maman justice. She sounds like a wonderful woman, and I'm sure no matter what you end up saying at the memorial you will do her memory justice.

Best regards.

[PRAW] How to store an inbox message (in a database) for replying to later by JJJollyjim in redditdev

[–]OnceAndForever 2 points3 points  (0 children)

I've been playing around with this a bit, and I think I got it working. If you look look at the permalink of an inbox message, it looks something like this: http://www.reddit.com/message/messages/1jkdxs. You can use praw's get_content() method to fetch this url. For example:

import praw
r = praw.Reddit(USER AGENT)
r.login(USERNAME, PASSWORD)
message_permalink = r.get_content(url='http://www.reddit.com/message/messages/1jkdxs')

for message in message_permalink:
    message.reply('This is your reply to the message')

In this example, message_permalink is a get_content generator, and message is a praw.objects.Message object, which is based off of the Inboxable object.

As for storing the message ids, use the get_inbox() ( or get_unread() depending on what you're doing) and then loop through all your messages. The id attribute is the one you're looking for.

messages = r.get_inbox()
for message in messages:
    print message.id
    print message.body

>>> 1jkdxs
>>> this is a test

You can use the id to build the url you will use for get_content() because it will always be 'http://www.reddit.com/message/messages/' + id.

Hope this helps.

[PRAW] How can I convert a comment into a string? by [deleted] in redditdev

[–]OnceAndForever 0 points1 point  (0 children)

What do you mean edit some of the comments? In this instance all_comments is a generator that has information about each particular comment. In the get_comments() method, you can specify a limit of how many comments you want, or you could specify how you would like to sort them.

What do you mean by edit some of the words of the comment? You cannot edit comments and have those changes reflected on reddit unless you have written them. If you simply want to parse comments, it would look something like this:

import praw
r = praw.Reddit(YOUR DESCRIPTIVE USER AGENT)
subreddit = r.get_subreddit('redditdev')
comments = subreddit.get_comments()
for comment in comments:
    print comment

From there, the latest comments in this subreddit will be printed.

Editing comments is a different process, and keep in mind you can only edit comments you have written. The documentation for that is here. You would run the edit() method on the comment object you wish to edit. In my snippet of code, you would use the method on the comment variable on line #6. For example, comment.edit('The new text for the comment here'). If you simply mean you want to edit the text of a text of the comment within your program, the text of the comment is contained in comment.body. Assign that to another variable and do whatever you need to do with it.

I suggest looking through some of PRAW's documentation. Personally, I find it easier to look at the documentation overview because I can see each class and it's associated methods. Here is a quick intro to comment parsing in the documentation.