Tweet imitator by Python

Currently I am reaching the end of my summer internship, and the company is in the social media marketing area. Basically it has dozens of social media accounts that can be used to reply to real users’ tweets about a specific topic, let’s say, a sports event, and in the replies would the robots attach links that are connected to some websites with promotional offers. Therefore, it is a good way to enhance the website traffic and do advertisements because it is not as annoying as sending you spam emails or phone calls, but to do that, we need really really authentic and sound robot accounts.
Screen-Shot-2016-07-21-at-4.48.28-PM.pngThat’s when difficulties kicked in. For example on Twitter, during the summer, my teammate and I have tried manually operating several accounts, by tweeting out posts, retweeting and all the stuff that normal users would do. However, it soon became a nightmare to operate even just 2 accounts at the same time since I felt like a psycho all the time, splitting up my life into different segments.

That feeling sucked, and I decided to research on the behaviour of robot accounts that mimicked real users. It soon got rewarding because I realized all robots follow a pattern, in which there’s a particular topic, such as fashion, food, sports or politics. They all seem to have at least one very outstanding characteristic.

Alright, since they all follow patterns in what they are tweeting about, why can’t I automate the pattern. The thought is, for example, if I am a foodie, I would often tweet about foods, and I will follow a lot of foodies’ accounts. If that is the case, I can design a program that randomizes the tweeting by using A-Basket-Of-Users method. What the hell is that? Well, it is just like how the currency policy works, by monitoring a bunch of important sources actively, but eventually it will finalize on one specific tweet to send out.

Yeah, I know it also sucks if I don’t know what I am going to send out, because there should be a way to graphically show what’s the outcome of the process, so I made a user-interface-version of it.
IMG_4332.JPGI can type in the account name I want to imitate, and it will send out that tweet using my account. If the tweet is over 140 character limit, it can also automatically truncate out unneeded url links in the latter part. Each time I hit the “upgrade” button, it will generate a new randomized tweet from the queried user, so hopefully nobody finds out who I am imitating if the “basket” is big enough.

For the server version, I also added in the “retweet” function since it is the most-used feature for those robot accounts, as they always retweet what they like. A potential timer module can be added to run this program 24/7 but I was, to be honest, too lazy to do that LOL.

I put my code open-source on my Github, because it is too long to show here in my blog post, and I value readability very much. Also, thanks to sixohsix’s gorgeous twitter API module in python.

P.S. Every experiment comes with punishments.

Tech Gadgets that I enjoyed

It is not easy to justify the desire to buy tech gadgets these days, because you will be easily tagged by “Geek” or “Nerd” or something similar. Nevertheless, I want to share some essential categories of tech gadgets of mine to make my daily life much more joyful.


No need to say anything…right? Everyone deserves to have the best phones on the world in this age, regardless of Android, IOS or others. 1
Continue reading

Efficiency is poisonous at times

Sounds like a horrible statement right? However, I started to feel that aiming for efficiency improvement is sometimes confusing and distracting, especially for IT workers or tech gadgets lovers. Why? Because these people are most likely to accept new “vague” tech concepts and give them a try, therefore resulting in los of waste in money and time.

Still don’t understand what I mean? Let’s make it this way: for instance, have you ever tried any new apps? Have you ever tried out new apps intending to replace the well-functioning but old one? Are you looking for new stimulus every day and you firmly believe with something new your efficiency will improve vastly?

Are they legible statement? Probably not. Actually I was one of those geeks who think in that way, and I suppose it is a very dangerous way of thinking because sometimes it is not going to help you except for wasting money and time. Quite often we can encounter write ups on the Internet, talking about new apps that worth trying out or new service that is unprecedented, and the writers seem to be eager to attract new users for those apps. I was one of their prey some time ago, therefore I’ve spent lots of time invested in unnecessary new things: for example, once upon a time I’d like to use 2do to replace OmniFocus just because my admiration to the MacStories editor Vittici. Fortunately, I did not lose my judgement, and after trying out 2do for a few days, I deleted it because it is no way better than what OmniFocus is contributing to my healthy lifestyle. Let’s focus on apps and take another example to illustrate my point: on IOS devices there’re tons of new apps showing up in App Store every day and some websites are potentially in cooperation with some of those app companies. There are a lot of new email clients apps, for instance, coming on stage every day and it seems like almost every email app is recommended by some long convincing articles that try to sell their points. If you cannot control yourself well on the curiosity, you might end up downloading new email apps and give them trials every day!
Continue reading

How iPad Pro can help in digital life?

When the iPad Pro first launched last November, my first impression of it is like all others’ – Who on earth is this gigantic iPad for? As time went by, after earning enough money on my job and careful considerations, I decided to buy one and find out the reasons myself.(I got the iPad Pro at a discounted price of 799 at Staples)

Well, it is a huge iPad, and I don’t know how to describe my first glance on it on the stand at Staples. It’s like upgrading your Macbook 11 to MacBook Pro 15, seriously, because I have gone through the switchover from MacBook Pro 13 to 15, I can definitely tell that the shock in switching to iPad Pro is even greater. When I got home, I immediately started to transfer my data from my iPad Air 2 to my new iPad Pro. However, I quit this process and made a bold decision: I am not gonna to use those apps that haven’t support the iOS 9 features and iPad Pro resolution any more! Since I bought this device to act as a potential laptop replacement, I believed I am not going to fully blow its potential without using the right apps.

Continue reading

Python and iTunes

After going through the chaos and matters in Feb., finally I have two days off to do something interesting. I have been thinking about to find a lyrics fetcher on OS X for a long time, but I failed to find one.

For IOS users, you can download musicXmatch. For Windows users, you can download MiniLyrics. These two softwares work like a charm on the mentioned platforms, but for OS X, I still could not find a versatile one. Therefore, I  came up with an idea that why not try to make one with Python.

Continue reading

An ugly but simple V2EX RSS client

It’s been a while since I wrote my last article here. During the winter break I went to three national parks in California, Utah and Arizona, the experience of which is astonishing. Obviously, I have put all of my focus into photography and adventure…….

Alright, after I came home, I as usual would check some forums to see if there’s any update about technology and data science. Among those websites, V2EX is one of my favourite because it is an active, user-friendly website that has a lot of interesting piece of news. I know there are already some people who have developed fascinating third party apps in OS X, but I am more than happy to find out the way to do it.

I have known RSS for a long time, which means, I knew it before Google reader closed…… I seldom used it right now, because I indeed don’t need to overload my information flow with RSS and not too many websites are worth checking every day. To make a RSS reader for my needs, I just need two things, one is a simple interface without ads and distractions, the other one is a simple representation of article titles that are clickable. What about the author and description? Not important to me at all. I make it because I need it to be in this way instead of anything else.

Screen Shot 2016-01-28 at 10.19.13 AM
Continue reading

Using package to create dashboard in R

I have taken DSO-510 Business Analytics this semester. In the final phase of presentation, Prof.Selby asked us to create a webpage to show our results made in SAS. Actually this is a very challenging task since everybody knows  SAS is not good at fancy visualization. Without hesitating for long, I decided to use R instead.

However, R is also not good at creating graphs, at least, for basic users. There are tons of settings and configurations you can tweak, but who on earth could get the hang of them right away. I tried to ask some seniors for advice, and I had some suggestions like using Shinyapps, which is a very good javascript-embedded tool made by RStudio. Although I like challenges, I hope I can make things easier this time without focusing too much on how to use the tools and how to reinvent the wheels.

After researching some packages on the Internet, I came across which is an incredibly easy and fancy package to create plots. They are so easy to install that you just need only one line of command in R and all will be set. It contains a lot of presets in color and design, and its official website has guidelines and tutorials and even example codes to keep users on the same page. I believe everyone who has experience in R will find it easy to learn. Most importantly, can save interactive graphs into HTML file, the feature that is perfect for those who want to create dashboards.

When I get enough interactive graphs, I started to think about how to make a dashboard. Fortunately I have seen some amazing dashboards in various presentations during this semester, so I think the primary factors are “overwhelming” and “informative”. To create an “overwhelming” dashboard, I need to arrange the positions and size of the graphs very well to create a feeling that this work is simply fabulous. To create an “informative” graph, the charts and plots need to be interactive, colorful and user friendly, and luckily has done these for me. Well, apparently, now is all about design.

1…2…3…Boom! Here comes the shitty work: R Dashboard

I am not professional in design, but I don’t like to ask real designers any questions, because I believe what interests me will be good design. To achieve that goal, I have taken a look at successful webpages about dashboards, and wrote and edit the code to mimic successful websites. If anyone is interested in how to arrange the plots, please take a look in my source code of the webpage, and I believe that should be the way to learn and get into discussion. Happy learning!

Final Project of Manegerial Statistics




This report is the final project for course GSBA-524 in Fall 2015.

Olympics, the biggest sports event around the world, is held by a select country every four years. There are approximately 200 countries that take part in it each time. Obviously, a lot of talented athletics are fighting so hard to get the entry of Olympics, and, probably to win a medal for his/her country, proudly. However, as a audience I have never thought about the mysteries and secrets of those medalists. What makes them excellent? What are the interesting facts about them?

As the final project of GSBA-524, I am asked to dig deeper in this topic as an audience and as a potential data analyst. All I have is a dirty dataset that consists of details of Olympics medalists from 2000 to 2012, Country GDP, Population, HDI and ISO codes. To be honest, I am a big basketball fans and I loved Kobe so much that I also plan to make this report a tribute to my beloved 2008 USA basketball team.
Continue reading

Scrapy, Finally….

After months of experiencing the American culture and adapting to the course level at USC, I finally got a chance to review my Python skill. Fortunately, I remember the basic operation command quite well and perhaps that’s how interests can drive a normal person to learn something deep enough.

In short, I still want to enhance my skill in grab the content on different kinds of websites. Everybody knows there are tons of packages of Python that could do that, but everybody should be careful about the learning curve of those stuff unless you major in computer science. During this semester, I have heard a lot of my classmates claiming that Python is easy to learn but COME ON, Python after all is a very powerful objected oriented programming language. If you have never touched on programming before, it would make you crazy. To sum up using an analogy, it’s like learning to play the guitar, at first it might be easy but if you want to do a SOLO in BLUES at stage in front of thousands of audience, you’d better invest a decent amount of time in it.

Continue reading

Select other columns when using functions in SQL

Thanks to INF 551, I finally got a chance to practice the SQL skillset that I learned on my own. In this class, the instructor is recommending us students to use MySQL, which is, not bad but it is not as familiar to me as SQLite.

SQL is straightforward in most ways, but I found a tricky problem when I want to select another column while using functions such as sum(), count() in SELECT clauses. In excel or R, I can easily specify which column to show up when specifying some conditions. However, it seems that SQL does not provide such user-friendly methods to do that.

For example, when I want to select the column next to the maximum of the sum of “sales_amount” column, I ended up inserting two “SELECT” clauses into the chunk, and used a where clause to clarify one last condition. Mind that two clauses in brackets are kind of the same except for the letter alias.

I have done some search on the Internet but I could not find a more elegant way to solve this issue. Another method is to create a new table or view in the software to serve as a substitute for clauses in brackets.

Anyone know better solutions?