Jan 23, 2014
Technology###Backgroud
Because github only allow one user to login(trusted key), the error message is listed as “Error: Key already in use”, I have to try another method for updating the qzone.
First I have created a new user on github, and created the corresponding repositories, now I have to create the user on my own machine, named “qzone” for only updating the repository.
###Create the user
Use following command for create a new user:
useradd -m -g root -G wheel -s /bin/bash qzone
passwd qzone
Then as another oridinary user, run “su qzone” then we can switch to the new user’s shell.
###Configure the user
Configure the git tools:
[qzone@XXXyyy ~]$ git config --global user.name "qzone"
[qzone@XXXyyy ~]$ git config --global user.email "XXXYYY@qq.com"
Add python virtualenv running environment:
mkdir ~/pyv
[qzone@XXXyyy ~]$ cat ~/.virtualenvrc
export WORKON_HOME="/home/qzone/pyv"
export PROJECT_HOME="/home/qzone/pyv"
source /usr/bin/virtualenvwrapper.sh
Add following lines for automatically run virtualenv setup
$ tail ~/.bashrc
source /home/qzone/.virtualenvrc
Now we can create the virtualenv for running python.
[qzone@XXXyyy ~]$ mkvirtualenv --python=/usr/bin/python2.7 v27
$ cdvirtualenv
Now we are in the python 2.7 environment. But notice you have to set http_proxy/https_proxy, etc for you are working under the proxy.
Install the pelican:
$ pip install pelican
Add configuration for git proxy:
export GIT_PROXY_COMMAND=/bin/myproxy
Add workon directory in .bashrc:
export WORKON_HOME=~/pyv
Next time, workon v27 then we can switch to python2.7 shell.
Make the directory of code, which will store all of the code.
$ mkdir -p ~/code/XXXYYY
Now clone the existing repository into the local directory:
git clone https://github.com/XXXYYY/XXXYYY.github.io
Install ghp-import for swiftly deploy your website
pip install ghp-import
Now setting:
pelican content -o output -s pelicanconf.py
ghp-import output
git push git@github.com:XXXYYY/XXXYYY.github.io.git gh-pages:master
Now you will failed, because you don’t have the correct access rights. So we need to set the ssh access right:
ssh-keygen -t rsa
cat ~/.ssh/id_rsa.pub
Then in github’s accounting management page, add this content.
Push all of the modifications to the remote repository:
git push -f git@github.com:XXXYYY/XXXYYY.github.io.git gh-pages:master
Install markdown for analyse the markdown based blog:
pip install markdown
Now you can do the following:
make html
make github
git push -f git@github.com:XXXYYY/XXXYYY.github.io.git gh-pages:master
Now install new themes:
cat pelicanconf.py
# Use theme for our own
THEME = "./pelican-themes/waterspill-en"
OK, now you can enjoy the blog finally.
Jan 20, 2014
TechnologyGetting Start
Install pelican via pip:
pip install pelican
Getting started Manual: http://docs.getpelican.com/en/3.1.1/getting_started.html, and the command is listed as following:
# Make sure your pelican is the newest
$ pip install --upgrade pelican
$ mkdir ~/code/yoursitename
$ cd ~/code/yoursitename
$ pelican-quickstart
The “pelican-quickstart” will ask you some questions, after answer all of the questions, you will have a start-up point for the website.
If your content is OK, run
$ make html && make serve
will generate the html files and preview it on the server.
Change the Theme
Copy the offical themes into your own directory:
$ git clone --recursive https://github.com/getpelican/pelican-themes ~/pelican-themes
Set the default theme in your pelicanconf.py:
# Use theme for our own
# THEME = "/home/Trusty/pelican-themes/mnmlist"
# THEME = "/home/Trusty/pelican-themes/storm"
THEME = "/home/Trusty/pelican-themes/html5-dopetrope"
Regenerate the site:
$ make html && make serve
Notice the pelican is pretty slow for rendering all of the content. For some themes, it may take up to several minutes for generating the whole site!
Jan 13, 2014
TechnologySince I’ve wrote blog for more than 7 year, I decide to use my own website to hold all of the articles. So I will start a task for transferring all of the written articles to a new website. Following will be the steps for transferring.
###Which blog system I will use
I decide to use static webiste, since the speed is much more faster than the database-based website, and it doesn’t have complicated configuration. Also It’s easy to backup and deploy.
I don’t want to use Octopress, because Octopress is good for recording for technical issues. And Octopress is based on ruby, while I decide to try python based static website generator.
I will choose Hyde. The website for Hyde is located at “http://ringce.com/hyde”, you can get the brief introduction on this website.
###Installation
Install hyde directly from yaourt:
$ yaourt hyde
Or you can directly download the package from the website, and unzip it to a suitable directory, install it.
The most simplest way is via:
$ pip install hyde
Because my machine runs python3, while hyde currently works under python2, everytime I use hyde, just:
$ workon venv2
$ which hyde
/home/Trusty/.virtualenvs/venv2/bin/hyde
It is recommended that use virtualenv to seperate the hyde environment from other python projects. Refer to “http://hyde.github.io/install”
###Get Demo Site run
Create the website:
$ hyde create
Compile all of the hyde source in the “deploy” directory:
$ hyde gen
Run a light-weight server enable you to preview the current website
$ hyde serve
Browser “http://localhost:8080” will see the current website.
After careful consideration, I think maybe I will try hyde later, because a better tool named pelican may fit me better.
“http://blog.getpelican.com/"
Jan 12, 2014
TechnologyFirst , clone th repository to your home computer via:
git clone git@github.com/your_name/Your_Repository
Second , configure everything:
sudo gem install bundler
rbenv rehash
bundle install
rake setup_github_pages
Here you will be asked to provide your accounts, enter it and continue.
Third, do changing the content and deploy .
rake generate
git add .
git commit -am "From Home computer"
git push origin master
rake deploy
In Company computer, run:
git pull origin master
cd ./_deploy
git pull origin master
Jan 9, 2014
TechnologyHere are some explanation on the code in “HMC5883L on RaspberryPI”.
The i2clibraries calls the “quick2wire” library.
root@rasp:~/code/i2c/pythoncode# grep "quick2wire" ./ -r
./i2clibraries/i2c.py:from quick2wire.i2c import I2CMaster, writing_bytes, reading
Binary file ./i2clibraries/__pycache__/i2c.cpython-32.pyc matches
Binary file ./i2clibraries/i2c.pyc matches
So we have to include QUICK2WIRE_API_HOME into the PYTHONPATH:
export QUICK2WIRE_API_HOME=~/code/i2c/quick2wire-python-api/
export PYTHONPATH=$PYTHONPATH:$QUICK2WIRE_API_HOME
So notice you have to specify the correct directory which contains the corresponding code.
root@rasp:~/code/i2c# tree -d
.
├── pythoncode
│ └── i2clibraries
│ └── __pycache__
└── quick2wire-python-api
├── doc
├── examples
├── quick2wire
│ ├── helpers
│ ├── parts
│ └── __pycache__
└── tools
11 directories