A Place For Me To Leave My Thoughts

Don't Hold Me To Anything Here

Reddit Repost Blocker

A large issue with Reddit is that content is regularly submitted again and again (otherwise known as reposting).

A vocal minority always posts comments about how the image has been posted many times before, sometimes the same day, week, or month.

So I started to think about how I can make a Reddit Enhancement Suite extension that would hide reposts.

I started to think about how this would work and there are a few ways I could see this working.

But first, why?

Pros

  • Reposts suck. An argument that the content on Reddit should be fresh and seeing the same submission over and over would decrease the quality of the website.

Cons

  • Reposts are a real part of Reddit, just because something is reposted doesn’t mean that there won’t be an interesting addition to the discussion a user has never seen before.
  • I remember when I used to block the imgur domain using Reddit Enhancement Suite, the extension use to just hide the submissions. So what would happen is that whenever I went to the front page I would only see two actual posts because almost everything was imgur links. For this extension, it would be counter-productive to block most of the submissions from the front page because they are reposts.

One Possible Implementation

  • Keep track of all front page posts for a long time (month or so, to start) into a data store (take your pick, mongo or sql)
  • The extension checks the url of the post against the database and if it already exists hide the submission post.

Issues:

  • Getting the data can take a while, but I found other people who have been archiving Reddit data.
  • Checking against the data store for a certain URL can take a while, of course hashing can make it easier but eventually collisions can happen.
    • One way to make things faster is to use some sort of hashing strategy that can check different hashtables for a URL. I remember that some data stores reverse a URL to make this easier. For example, the strategy is to store a domain in the format com.vvohra.subdomain so the com’s, net’s, etc can be stored on different servers to speed up checking of data.

Existing Solutions

Karma Decay shows which images have been reposted. I think it’s similar to TinEye, so it should be able to handle images from different domains and changed sizes. It seems Karma Decay has an extension which allows a user to notice a submission has duplicates.

Another extension I found was Repost Blocker, which seems to be exactly what I brainstormed. Looking through the documentation, it seems like this extension uses Karma Decay to check for reposts.

Just a short brainstorming activity, gotta think some more!

OSX Shortcuts

I started to really use keyboard shortcuts when I started to use VIM. But what I dislike is that I can’t HJKL in another applications, which is tough to get over because I spent so much time learning I couldn’t use them in other applications!

There are ways to use VIM keybindings in other applications, such as Vimperator, Vimium, Eclim, etc. But the hardest is that getting VIM keybindings to function means that there needs to be support for the insert, normal modes (More here) to work correctly. And this is difficult to do in an effective manner!

So that’s why the Emacs keybindings make sense! Instead of having to try to mess around with modes, I can just use Control + Key to complete an operation. The bad part about using Control is that it is on the bottom left part of a Macbook keyboard, but I do remember that people always mentioned to me that they would remap the Caps Lock key to Control.

I am sad that I can’t switch into ALL CAPS mode (which is good to have when I’m trying to write proper SQL), but being able to control the cursor without having to move my hands to the arrow keys is something I am willing to give up. The one bad part is that these keyboards shortcuts are not always available in all programs, but it works in terminal, Chrome toolbar, and text editors! Which is really covers most of the stuff I do anyway!

The following is a summary of the keyboard shortcuts I find most important to know. Cursor is the small box or vertical line that shows where you are currently typing.

Movement

Keyboard Shortcut Command
Control + A Start of Line
Control + E End of Line
Control + P Previous Line
Control + N Next Line
Control + F Move Cursor Forward
Control + B Move Cursor Backward
Control + V Scroll Down

Editing

Keyboard Shortcut Command
Control + K Cut From Cursor to End of Line (Cut)
Control + Y Paste The Text Removed By Control + K
Control + H Backspace
Control + D Forward Backspace
Control + T Transpose letters *
Control + O Insert Line Break


* If the cursor is:

  • between two letters, the two letters will be switched.
  • is in a white space between two words, the two words will be switched.

Google around more to find out OSX keyboard shortcuts.

My OSX Setup

My brother has just started college and I recommended that he should get a Macbook Pro because I have had a blast using one for the past one year. Also, he is interested in Computer Science and said he would like tips to know what to install for a good workstation setup.

Before an internship I primarily used a Linux box and was comfortable using the command line, but always had trouble with various things such as sound, turning on after a sleep, and performance issues on my previous Linux laptop. This might have been due to the fact that the machine wasn’t the highest quality machine and might not have been a good fit for Ubuntu.

As I was making the list I figured it would be good to put up the list online so others can look at my setup and decide whether they want to use any of the tools I do.

General OSX Desktop Tools:

  • Toggl
  • Yoink
  • Bartender
  • Flux
  • gfxCardStatus
  • Alfred
  • TotalFinder
  • Spectacle
  • KeyRemap4Macbook

Development Tools

  • MacVim
  • Oh My Zsh
  • DBeaver
  • Sublime Text
  • Iterm2

I have remapped the Caps Lock to Control and will have a post discussing how I have made my life better with remapping keys.

Efficient SQL (Custom)

During one of my interviews I was asked whether I knew how to make SQL queries more efficient. At that point in time I had barely used SQL and had to ask the interviewer to move on to another subject.

But since I have started to use SQL in the DSSG Program I’ve started to deal with SQL queries that can possibly take a while to run. And I started to wonder how to make SQL queries more efficient and I found this article.

The following is a quick summary of link.

Tips to Speed Up Queries

  • Try to restrict the queries result set by using the WHERE clause.

This one seems obvious.

  • Try to restrict the queries result st by returning only the particular columns from the table, not all the table’s columns.

Another one that seems obvious.

  • If you need to return the total table’s row count, use an alternative instead of SELECT COUNT(*) statement.

This one is interesting because I didn’t know there were alternatives, I usually do run the SELECT COUNT(*) statement! I will update how to get the table count in Postgres soon.

  • Try to avoid the HAVING clause whenever possible.

This is an interesting one, I wouldn’t think the HAVING clause would be that computationally expensive, but a good point is made that if it’s possible to filter out unneeded values with a WHERE clause, that should be used.

  • Use SELECT statements with LIMIT keyword if you need to return only the first n rows.

Makes sense, I do this quite often when I am testing to make sure my query is running as expected. Usually used to run join on a subset before running it on the whole data set.

  • Try to use UNION ALL statement stead of UNION.

UNION ALL does not look for duplicates while UNION does look for duplicates whether they exist or not.


Something I’ve learned about recently is Postgres’ EXPLAIN and ANALYZE. More information is to be added soon.

I will add more SQL efficiency tips as I come across them!

Javascript/Node Build System for Sublime

To be able to build Javascript in Sublime Text, it’s necessary to add a new Build System.

To be able to do that, it’s necessary to first have Node installed, so head over to Node.js homepage to install node.js first.

With the Sublime Text program open, navigate to Tools -> Build System -> New Build System ...

And add the following:

Node.sublime-build
1
2
3
4
{
    "cmd": ["/usr/local/bin/node", "$file"],
    "working_dir": "${project_path:${folder}}"
}

It might be necessary to adjust the path to node for your own setup.

Now save, restart Sublime Text, and you should be able to build Javascript with Sublime Text!

Markdown Reference

What is Markdown good for? Think of it has a way to write HTML without the messy confusing HTML syntax. Markdown is a simple set of rules that is converted into valid HTML. Some examples are GitHub Repository README and how I write these blog posts.

The following is a quick overview of the most common Markdown syntax.

Headers

# Level one header

## Level two header

### Level three header

… Up to six hashes are supported

I would show an example, but it doesn’t work well because I’m already using Markdown for this blog post!

[This is a link](http://www.darkzeroman.github.io)

This is a link

Lists

Unordered Lists

Use any of the following: *, +, -

1
2
3
* Item 1
* Item 2
* Item 3
  • This
  • is
  • a list

Ordered Lists

Ordered lists use number followed by period.

1
2
1. with
2. numbers
  1. with
  2. numbers

Formatting/Emphasis

_italic_ or *italic*

italic

__bold__ or **bold**

bold


More Resources:

Removing All Pip Packages

If you need to remove all pip packages currently installed.

1
pip freeze | xargs pip uninstall -y

This is more useful than you think!

First Post

So I haven’t really ever used GitHub pages before, but I think this is an awesome way to get quick posts out without having to worry about wordpress and such. All I have to do is just edit a few files, run a few commands, and then push the source! How easy is that?