Archive

Archive for the ‘IT’ Category

How to move wordpress

June 1st, 2009 Augix 2 comments

Recently I moved my website to a new host, I also upgraded the old version wordpress. Here are what I did for augix.com.

  • export the MySQL database from the old website
  • import the previously exported database to the new website
  • modify my wp_options table, including: (if your domain name is already transfered, you don’t have to do that.)
    • modify the siteurl
    • modify the home
  • upload wordpress folder to the new site. This folder already includes:
    • wordpress/wp-content/uploads, inside there are a lot of photos used in the blog
    • One can test if the installed themes and plugins also work. For my old wordpress, I used the default setting, so there’s no theme and plugin installed.
  • Open web browser, test it. The old version is wordprss 1.5.2, it upgraded to 2.7.1 perfectly.
Categories: IT Tags:

How about this new site?

May 29th, 2009 Augix No comments

Augix.com is back with a new appearance, how about it?

View Results

Loading ... Loading ...
Categories: IT Tags:

Progress bar in Python

May 25th, 2009 Augix 5 comments

I’ve been writting PERL programs for 5 years, recently I started learning Python. Here is a progress bar written in Python.

Usage:

?View Code PYTHON
1
2
3
4
5
from progressBar import progressBar
bar = progressBar(max=200)
for i in range(200):
        bar.update(i)
        time.sleep(0.1)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
 
#!/usr/bin/env python
'''
    NAME: progressBar.py
    AUTHOR: Augix
    DATE: 2009-05-20
 
    FUNCTION: this module prints a progress bar to show how much time you have to wait until the program finish.
    It simply reads a percentage to update the progress bar.
 
    USAGE: from progressBar import progressBar
    bar = progressBar(min=0, max=200, barLength=None, output=sys.stderr)
    for i in range(200):
        bar.update(i)
        time.sleep(0.1)
 
    Reference: http://code.activestate.com/recipes/168639/
'''
 
# === Dependencies ===
import sys, time
 
# === variables ===
 
# === functions ===
 
# === classes ===
class progressBar:
    def __init__(self, min = 0, max = 100, barLength = None, output=sys.stderr):
        self.output = output
        self.progBar = "[]"   # This holds the progress bar string
        self.min = min
        self.max = max - 1
        self.span = self.max - self.min + 1
        self.barLength = self.calBarLength(barLength)
        self.percentDone = 0
        self.timeStart = time.time()
        self.timePrevious = self.timeStart
        self.timePass = 0
        self.finish = False
        self.update(0)  # Build progress bar string
 
    def calBarLength(self, barLength):
        if barLength == None:
            from fcntl import ioctl
            from termios import TIOCGWINSZ
            from array import array
            a = ioctl(self.output,TIOCGWINSZ,''*8)
            h,w=array('h',a)[:2]
            return w
        else: return barLength
 
    def calPercent(self, newAmount):
        diffFromMin = float(newAmount - self.min + 1)
        percentDone = (diffFromMin / float(self.span)) * 100.0
        return percentDone
 
    def calWaitingTime(self):
        self.timePass = time.time() - self.timeStart
        timeWait = self.timePass / float(self.percentDone) * (100.0 - self.percentDone)
        return timeWait
 
    def formatTime(self, seconds):
        seconds = int(round(seconds))
        hour = seconds / 3600
        if hour == 0: hour = ""
        else: hour = " " + str(hour) + " hour"
        minute = seconds % 3600 / 60
        if minute == 0: minute = ""
        else: minute = " " + str(minute) + " min"
        second = seconds % 60
        second = " " + str(second) + " sec"
        s = hour + minute + second
        return s
 
    def formatPercent(self, percent):
        i = str(int(round(percent)))
        s = " "*(3-len(i)) + i + "%"
        return s
 
    def update(self, newAmount = 0):
        timeNow = time.time()
        if timeNow - self.timePrevious < 0.5:
            if newAmount < self.max: return None
        self.timePrevious = timeNow
        # Calculate the percentage finished
        if newAmount < self.min: newAmount = self.min
        if newAmount >= self.max: newAmount = self.max; self.finish = True;
        self.percentDone = self.calPercent(newAmount)
        printPercent = self.formatPercent(self.percentDone)
 
        # Calculate the waiting time
        if self.percentDone == 0: printETA = ""
        elif self.finish == True: printETA = self.formatTime(self.timePass) + " used"
        else:
            timeWait = self.calWaitingTime()
            printETA = self.formatTime(timeWait) + " left"
 
        # Figure out how many '=' and spaces the bar should be
        spaceAndEqual = self.barLength - 11 - len(printETA)
        numEqual = (self.percentDone / 100.0) * spaceAndEqual
        numEqual = int(round(numEqual))
 
        # the rotating thing
        animation = '|/-'
        printAnimation = animation[int(timeNow*2 % 4)]
 
        # build a progress bar with "=" and spaces
        self.progBar = " " + printPercent + " [" + printAnimation + '='*numEqual + ">" + ' '*(spaceAndEqual-numEqual) + "] " + printETA
        if self.finish == True:
            self.output.write(self.progBar + "n")
        else:
            self.output.write(self.progBar + "r")
 
    def __str__(self):
        return str(self.progBar)
 
# === Main ===
if __name__ == '__main__':
    bar = progressBar(max=200)
    for i in range(200):
        bar.update(i)
        time.sleep(0.1)
Categories: IT Tags:

BBS browser on Mac OS X: Welly and Nally

April 26th, 2009 Augix 2 comments

Update May 3, 2009: Welly seems better than Nally.

Welly and Nally are BBS browser, they are both very easy to use. Welly even call himself: Best Term BBS browser on Mac OS X.

BBS _on_Nally

narry_font

http://code.google.com/p/welly/

Categories: IT Tags: ,

爱因斯坦评augix.com

November 17th, 2005 Augix 4 comments

31374

Look, what Uncle Sam said:

Uncle Sam

Categories: Uncategorized, IT Tags: