Other articles

  1. LeetCode: 48. Rotate Image

    The problem is Rotate Image. If I can use more space, just copy the number for original matrix to new matrix. And the rule of rotate 90 degrees is simple, using original y coordinate as new x coordinate, lenght minus x as new y. After copying to new matrix, copy ...

    read more
  2. Install MySQLdb in virtualenv on Ubuntu

    I have install the python-mysqldb on my Ubuntu server, but a missing dependency message alerted when I run a program in virtualenv.

    Then I do as this post and solved my problem:

    $ sudo apt-get build-dep python-mysqldb
    $ source venv/bin/activate
    (venv)$ pip install MySQL-python

    then everything works fine.

    read more
  3. Modify timezone and datetime on Ubuntu

    Some configurations commands for Ubuntu server:

    $ tzselect
    # Since I'm in China, I select the Asia -> China -> Beijing Time
    # The TZ='Asia/Shanghai'
    # Update the localtime profile
    $ sudo cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
    # Update datetime by time center
    $ sudo ntpdate asia.pool.ntp.org
    # Update the hardware ...
    read more
  4. Install Jupyter Environment

    In order to start my own work on data analysis into EDM, I need a development environment of Python Notebook. The process is quite simple:

    Install the virtualenv and related packages:

    $ sudo apt-get install python-virtualenv python-pip python-tk

    Create a virtual environment for project:

    $ cd ~/workspace
    $ virtualenv edm
    $ source edm/bin ...
    read more
  5. Simple Jupyter Python Scripts

    Basic imports

    Import these packages:

    import numpy as np
    import matplotlib.pyplot as plt

    Enable the inline display of graphs

    %pylab inline


    Jupyter Notebook has two different keyboard input modes, which are similar to VIM. I prefer this!

    read more
  6. LeetCode: 125. Valid Palindrome

    The problem is 125. Valid Palindrome. It's quite simple to make a simple one.

    class Solution(object):
        def isPalindrome(self, s):
            :type s: str
            :rtype: bool
            if s == '': return True
            cs = 'abcdefghijklmnopqrstuvwxyz0123456789'
            is_char = lambda c: c in cs
            to_sstr = lambda s: ''.join([ c if is_char(c) else '' for c ...
    read more
  7. LeetCode: 412. Fizz Buzz

    The problem is Fizz Buzz. It's quite simple!

    class Solution(object):
        def fizzBuzz(self, n):
            :type n: int
            :rtype: List[str]
            ret = []
            for i in range(1, n+1):
                if i % 3 == 0:
                    if i % 5 == 0:
                elif i % 5 == 0:
                    ret ...
    read more

Page 1 / 3 »