Author Archives: kevin

About kevin

I write the posts

Escaping from your email

I only download my email once every four hours. Otherwise I check it too much. This works really well and my "need to check" email addiction has totally shut off.

For this to work on your own email, you want to set up a Gmail account with an address that no one knows, as well as access to a cron task scheduler. Cron is an application that runs tasks on a set schedule, so every minute or every year or every Monday at 5pm, etc. If you have Mac or Linux, and you're the type of person that keeps their computer on 24/7, you can run "cron jobs" from your local machine (you want to edit the /etc/crontab file - here are some instructions). I use my web hosting provider's cron service, because it will run even when my laptop is shut down.

Here's the script:

 
import imaplib
from datetime import datetime
import email
import smtplib
import sys
import os
import random
import base64

def main():
    #check user
    if os.isatty(sys.stdin.fileno()):
        #i'm trying to get my email by cheating, not a cron
        print "Are you sure you want to do this?"
        ans = raw_input()
        if ans != "yes":
            return
        no_of_mults = 3
        for i in range(no_of_mults):
            a = random.randint(1000,9999)
            b = random.randint(1000,9999)
            print "What is " + str(a) + " * " + str(b) + "?"
            ans = float(raw_input())
            if ans != a*b:
                print "Sorry, incorrect answer."
                return

    imap_domain = "imap.gmail.com"
    imap_port = 993
    imap_username =  base64.b64decode('my_gmail_username_encoded')
    imap_password = base64.b64decode('my_gmail_pass_encoded')

    #smtp settings
    smtp_domain = "my_smtp_host.com"
    smtp_port = 587
    smtp_username = "my_smtp_user"
    smtp_password = "my_smtp_pass"

    email_recipients = ['kburkeorg@gmail.com']

    imap_server = imaplib.IMAP4_SSL(imap_domain, imap_port)
    imap_server.login(imap_username, imap_password)

    server = smtplib.SMTP(smtp_domain, smtp_port)
    server.ehlo()
    server.starttls()
    server.ehlo()
    server.login(smtp_username, smtp_password)

    imap_server.select('INBOX')

    status, email_ids = imap_server.search(None, '(UNSEEN)')

    recipient = email_recipients

    count = 0
    for e in email_ids[0].split(' '):
        if e is not '':
            try:
                raw_msg = imap_server.fetch(e, '(RFC822)')
                msg = email.message_from_string(raw_msg[1][0][1])

                #modify reply-to so we preserve email address
                if not msg['Reply-To']:
                    msg['Reply-To'] = msg['From']

                result = server.sendmail(msg['From'], recipient, msg.as_string())
                count += 1

            except smtplib.SMTPRecipientsRefused, e:
                print "SMTPRecipientRefused" + str(e)
                continue
            except Exception, err:
                print err
                continue

    # so I can see how many messages were printed
    print "Sent " + str(count) + " messages."
    filename = "/home/kevinburke/webapps/b/sent.txt"
    with open(filename, 'w') as f:
        f.write(str(count))
    print datetime.now()

    server.quit()

if __name__ == "__main__":
    main()

Then in your cron file, you want to add the following line:

0 */4 * * * /usr/bin/python /path/to/email/file.py

where

/path/to/email/file
is the filepath to wherever you saved the script above. The 0 means run the script at the top of the hour, and the */4 means run it once every 4 hours.

Liked what you read? I am available for hire.

links for 2010-11-02

  • The algorithm used by this cron is as follows: On start-up, look for a file named .crontab in the home directories of all account holders. For each crontab file found, determine the next time in the future that each command is to be run. Place those commands on the Franta-Maly event list with their corresponding time and their "five field" time specifier. Enter main loop: Examine the task entry at the head of the queue, compute how far in the future it is to be run. Sleep for that period of time. On awakening and after verifying the correct time, execute the task at the head of the queue (in background) with the privileges of the user who created it. Determine the next time in the future to run this command and place it back on the event list at that time value.
  • (tags: vim)
  • wow: "I wanted to see if I could make myself smarter, by strategically placing notes to myself. Intelligence, as I define it, is getting the right information at the right time at the right place, towards whatever end you are going for." Lion emerged from his experiment a changed man. As a result of spending months thinking and writing down his thoughts with a pen, his brain had started to work in new ways. "You can think about hidden subjects - things that are really important, but that people don't have the time to think about, such as: 'How do we communicate?' 'How is thinking structured?' 'What am I doing?'

Liked what you read? I am available for hire.

links for 2010-11-01

  • "Uncertainty allows mothers to select for their children the father who would be best for them. The point is that paternity was ambiguous and it was effectively up to the mother to name her child’s father, or not… Many men have, of course, ended up raising children who were not genetically their own, but really, does it matter…in making paternity conditional on a test rather than the say-so of the mother, it has removed from women a powerful instrument of choice." - is she serious? the choice to sleep around with whoever you want and foist the child on your unwitting husband?
  • we show that punitive house demolitions (those targeting Palestinian suicide terrorists and terror operatives) cause an immediate, significant decrease in the number of suicide attacks. The effect dissipates over time and by geographic distance.  In contrast, we observe that precautionary house demolitions (demolitions justified by the location of the house but not related to the identity or any action of the house’s owner) cause a significant increase in the number of suicide terror attacks.  The results are consistent with the view that selective violence is an effective tool to combat terrorist groups, whereas indiscriminate violence backfires.
  • lots of common design patterns
  • facebook is unhappy medium between highly private, public conversations: Because Facebook has chosen to emphasize growth over monetization these past few years, they have de-prioritized close, meaningful connections over broadly relevant ones with a larger group of friends.  While this will help them get to a billion users faster, and increase their share of brand spend on advertising (where Facebook is really killing it these days), it may create vulnerability to another social network player who focuses on a more tightly-defined social graph with only a few, specific & meaningful Intimate relationships. Intimate relationships that might just monetize more powerfully with 3 close friends, than they do with 300 acquaintances. Better be careful, Zuck. maybe there's a reason Facebook should care more about Intimacy & Privacy that has absolutely nothing to do with government regulation, and everything to do with simply making more Meaning... not to mention more Money, as well.  
  • breathe out before taking a shot, immediately start chewing a savory hors d'oeuvre, then breathe out

Liked what you read? I am available for hire.

When corporations are more ethical than individuals

We were discussing piracy and plagiarism in class today. It's common knowledge that most young people don't consider downloading or copying music from a friend to be stealing. I was going to raise my hand and talk about how the music industry is actually doing fine - it's shifted more now to live shows, merchandise, and commercial licensing. Commercial licensing made me realize that on some issues corporations act much more ethically than individuals; that is, a corporation's larger liability leads them to act more ethically, because the damages are higher. For example, TV companies and commercial makers pay artists to license music during songs; the costs of them playing the songs without permission is much higher. I would also guess that, all other things equal, employees of a centrally owned, national corporation would act more ethically than a mom-and-pop operation in the same line of work. This analysis only really applies to physical crimes like harassment and theft; I believe that employees of big corporations would act more ethically in these areas than individuals, or small firms. There's no individual equivalent to corporate malfeasance, option backdating or share price manipulation.

Liked what you read? I am available for hire.

links for 2010-10-31

  • not many people have ever seen a trick for testing divisibility by 7. Here’s the trick. Remove the last digit from the number, double it, and subtract it from the first part of the number. Do this repeatedly until you get something you recognize as being divisible by 7 or not.
  • Any word you have to hunt for in a thesaurus is the wrong word. There are no exceptions to this rule. You think you might have misspelled a word? O.K., so here is your choice: either look it up in the dictionary, thereby making sure you have it right - and breaking your train of thought and the writer's trance in the bargain - or just spell it phonetically and correct it later.

Liked what you read? I am available for hire.

Preaching the opposite of what you practice

Half a century ago, nursing books warned against being too cuddly and warm with children. Harry Harlow is an extremely famous psychologist who experimented with monkeys to show the opposite - that children seek affection and warmth, and it helps them grow. He gave monkeys a choice between two 'mothers' - a wire mother that dispensed milk and a cloth mother that had no food - and the monkeys overwhelmingly chose the cloth mother. Furthermore, monkeys that could choose only the wire mother later had psychological problems. This was groundbreaking work at the time. So you would expect that Harlow would apply the same lessons to his personal life, right? Not quite:
Harry Harlow did not discover what children need by watching his own. In fact, Harlow was a hard-drinking, possibly alcoholic, workaholic who ignored his two sons so completely that it led his first wife to divorce him. After his boys were grown, he reacquainted himself with them, but his younger son said that although they got along, "we were never father and son." In fact, Harlow's insights about child rearing were not based on studying children at all but came out of his research with monkeys.
Are the people who preach loudest about X the most likely to have shortcomings in their ability to do X? Maybe there are two reasons for preaching loudly about something: 1) You believe you're better at it than everyone else and want to stress its importance to raise your status. 2) People who lack skills in area X try to cover it up by overachieving in other areas, but remain unwilling or unable to improve their skills in area X.

Liked what you read? I am available for hire.

links for 2010-10-30

Liked what you read? I am available for hire.

links for 2010-10-29

Liked what you read? I am available for hire.

links for 2010-10-27

  • Stop checking shoes, taking out laptops etc
  • In the comments: "A last example: there are a couple dozen movies that accounted for a massive amount of error on the Netflix Prize (~15% of the remaining IIRC). Although it was termed the Napoleon Dynamite problem, the #1 movie for aggregate error in that data set was What Women Want. When the goal is the best customer experience, you could remove those items, stop recommending them to new users or just warn customers."
  • National Public Radio’s flagship news programs, Morning Edition and All Things Considered, featuring news and commentary alongside in-depth reports and stories that can stretch over twenty minutes—are the second- and third-most-popular radio programs in the country, each drawing about 13 million unique listeners in the course of the week. These NPR shows have far larger audiences than the news on cable television; indeed, all four television broadcast networks combined only draw twice as large an audience for their evening newscasts.
  • really cool, also lets you know how incapable your brain is of processing the size of things

Liked what you read? I am available for hire.

links for 2010-10-25

  • Many Japanese chefs, especially in the Kansai region, say they never courted this attention. Even a single Michelin star can be seen as a curse by the Japanese: Their restaurants are for their customers. Why cook for a room full of strangers? Even worse: crass foreigners.
  • The study concludes with the conjecture that people may find it particularly painful to be unhappy in a happy place, so that the decision to commit suicide is influenced by relative comparisons.
  • Providing enough power to every seat on an airplane would require heavy equipment.
  • The big lesson of Digg may be simply this: if someone offers you a ridiculous amount of money for a company that wasn’t that hard to build, don’t think twice. Take the money and run.
  • How to develop a software product using version control, helpful
  • to contact in the future
  • This isn’t Farmville vs Dancing with the Stars.  This is about the best alternative to boredom. If Google , Apple and their competitors can find simple games that are compelling to tens of millions of people and create a unique experience on your HDTV, they have a chance to start pulling people away from watching shows on TV.  You could actually see the number of hours spent watching TV decline materially.
  • Holy shit - GUI app lets you sit on open wireless networks, intercepts cookies, lets you instantly log in as the wireless user to Twitter, Facebook, Flickr Google accounts. Never ever ever ever open anything on an open wireless connection again, until they start using HTTPS and SSL for every connection
  • excellent observation - "My plans rarely work (unless they are boringly simple), but serendipity has been good to me, so over time I've tried to make the most of that. My theory of serendipity is still evolving, but from what I've seen, it's better to think in terms of "allowing" serendipity rather than "seeking" it or "creating" it. Opportunity is all around us, but we have beliefs and habits that block it."
  • But psychologists who study status and power in social settings — and a growing number are — have found that human beings, in surprising ways, actually seem to thrive on a sense of social hierarchy, and rely on it. In certain settings, having a clear hierarchy makes us more comfortable, more productive, and happier, even when our own place in it is an inferior one. In one intriguing finding, NBA basketball teams on which large salary differentials separate the stars from the utility players actually play better and more selflessly than their more egalitarian rivals. “Status is such an important regulating force on people’s behavior, hierarchy solves so many problems of conflict and coordination in groups,” says Adam Galinsky, a psychologist at Northwestern University’s Kellogg School of Management who did the research on social hierarchies on basketball teams. “In order to perform effectively, you often need to have some pattern of deference.”
  • Become a hermit, celebrate your individuality, associate with some higher truth
  • good introduction to fonts - covers helvetica, times new roman, gill sans, psychology behind different fonts, difference between serif & sans serif

Liked what you read? I am available for hire.