There are reasons for everything as I always recall in regular discussions with friends, family, and other acquaintances. Paste2Upload is not an exception, that’s for sure. An avid Lifehacker reader, I remind myself consistently that if there is a noted repetition in my daily life that it is necessary it be dealt with.
One thing that I do, without fail, throughout the day is open up a new tab in whichever browser I am feeling favourable to that day (mainly Firefox or Safari), navigate my way to Paste2, and paste a snippet of text; whether it be a funny conversation, an important selection of a website, or some code that I want to share quickly and efficiently. This works quite well, I must admit, but on the last note of the previous sentence there exists one issue with the current workflow: efficiency.
As we all know, especially the engineers of the crowd, there are many solutions to any given problem. Now, when I’m among a circle of my peers, I’ll make a point to insist that my solution is right. It’s all in good fun, just like they’d insist that theirs is right to me—it’s the engineer’s way.
And so, working diligently, I analyzed the situation at hand and came up with a solution (the right solution, I might add, to any of the aforementioned crowd). What I needed was clear:
A swift, efficient way to paste text—sans-browser. I don’t always work with a browser open, but I do often communicate with an instant messenger at hand, so I wanted to untie myself from that single necessity.
As you read through my implementation, please don’t hesitate to chime in with comments here and there. They’re never hushed away and are instead acted quite the opposite to, I welcome them. While around my peers for the effect of playful banter and competition I’ll insist that I’ve devised the end-all, be-all solutions, I welcome open-mindedness and request any suggestions. If they seem reasonable and well-placed and have a relevancy to the topic, I’ll implement them as necessary.
My goals were outlined and the implementation of them became clear. My original vision with this was that I create a command-line based utility in Python that would allow me to execute something along the following lines:
./paste2 --verbose --language python --description “A little taste of some code that I wrote” [text]
An explanation is in line here:
As a testament to my earlier promise, I am never afraid to welcome new ideas or proposed changes. Talking with a good friend of mine, Will Donnelly, I showed him my code at its then-completed state. It functioned according to the specifications above. Being the kind and praising friend that he is, he immediately pointed out everything that he saw wrong with it.
His main complaint was that my mindset did not seem to embrace the “UNIXy” side of things. I asked him to expand and he pointed out that my program forced the user to have their clipboard modified (which would hinder various implementations), had the unnecessary (and unwelcomed) [-v, –verbose] flags, and that it accepted only input from the clipboard or via directly input text.
To me, that last part was not an issue until he expanded further on his complaint. As he put it, I was failing to meet the standard by not accepting input-by-file or input through stdin. This is when everything clicked: a change had to be made.
I overlooked the proposed changes and implemented them with ease. It wasn’t many lines of change, but the payoff was well worth it. The program now accepted input through both stdin and file (which was simple enough, since Python treats the former just as it would the latter).
The verbose flags were removed as the program would now always output the URL to stdout so that, in the UNIXy fashion that was so demanded, it could be piped wherever necessary—whether xsel (Linux) or pbcopy (OS X).
Text input was removed in favour of file-name specification, which could be specified as a single dash (“-”) to let the program know that stdin input was requested.
The end product, distributed freely under the MIT License, can be viewed at its GitHub repository page. The code itself can be viewed directly from the GitHub website as well.
Although I wanted to take an opportunity to share this bit of code with everyone, and I hope others will find it useful to their daily lives in reducing repetition and increasing efficiency, I had a greater meaning to this post.
First, as my preface suggested, I wanted to stress to all programmers (or - if not a programmer, to those who may want to suggest a small project for me to tackle) that if you notice repetition and inefficiency through your daily life, this is ample opportunity to write some productive code and simplify your life.
Second, I want to remind everyone that—no matter the field that you work in—I know that it is easy to get an idea stuck and committed in your head, but don’t let that block you from the bigger picture. Always take a step back, share your idea with friends and family, and don’t shun their input away. Although you may think that your original idea is the end-all solution and will work exactly how you want it, you may find from a little bit of open-mindedness that other possibilities can branch outwards from a little seed. As was with my code above, clipboards were my main concern at the beginning. Toward the end, various implementations are much less limited.
I like learning new things. Previously: Kenchi founder, eng & ops teams at Stripe from 2012-2019. Say hi! 🏳️🌈