November 26, 2015

python3 twitter downloader with mongodb

mongodb credit goes to Liam Bowen (original post: http://hut8.io/posts/mongodb-3-on-debian-jessie/) 1. install mongodb 3.0
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 7F0CEB10
echo 'deb http://repo.mongodb.org/apt/debian wheezy/mongodb-org/3.0 main' | sudo tee '/etc/apt/sources.list.d/mongodb-org-3.0.list'
sudo apt-get update
sudo apt-get install -y mongodb-org
2. tweak the settings
sudo mkdir /mongodb
sudo chown -R admin:admin /mongodb    # "admin" because of using AWS debian AMI
sudo nano /etc/mongod.conf            # change [storage.dbPath] and [systemLog.path], "wiredTiger" part is more optional
3. start mongodb in background
mongod --config /etc/mongod.conf --fork
# to report mongodb stats every 60 seconds
# mongostat 60
# to shutdown 
# mongo --eval "db.getSiblingDB('admin').shutdownServer()"
python and twitter 1. get the packages
sudo apt-get install python3-pip
sudo pip3 install twitter pymongo
2. tweaks
sudo nano /etc/hostname 
echo $HOSTNAME

September 21, 2015

Disable date/time sync between VirtualBox client and host

by msa.operation @ forum.virtualbox.org
original post: https://forums.virtualbox.org/viewtopic.php?t=8535

vboxmanage setextradata [VMname] "VBoxInternal/Devices/VMMDev/0/Config/GetHostTimeDisabled" "1"

Note: replace [VMname] with the name of target virtual machine; replace "1" with "0" to turn the sync back on.

July 28, 2015

connect to local area network through PPTP VPN (Synology DSM)

Credit goes to this forum post by vibrationbaby

In short, assign PPTP managed IPs into the same pool of local private network.
  1. login as root through SSH.
  2. go to /usr/syno/etc/packages/VPNCenter/pptp
  3. edit the two lines for localip and remoteip pptp.conf. (@vibrationbaby provided the setting below. i used .200 and .201-205 while my DHCP managed 100-199. just choose some addresses that is not overlapping with existing DHCP pool.)
    localip 192.168.1.210
    remoteip 192.168.1.211-220
    
  4. then it should work after restart the VPN Server through DSM web interface.

add Dynu.com to DDNS list on Synology NAS

https://www.dynu.com/DynamicDNS/IPUpdateClient/SynologyNAS

(install ipkg to install nano follow the instructions here if necessary)
(Note: on my DSM 5.2, PATH setting in /root/.profile need to be commented out)
add below codes to /etc.defaults/ddns_provider.conf
[Dynu.com] 
        modulepath=DynDNS 
        queryurl=api.dynu.com/nic/update?hostname=__HOSTNAME__&username=__USERNAME__&myip=__MYIP__&password=__PASSWORD__

June 19, 2015

a new Mint 17


  1. Software Manager
  2. ScreenShot, Gpaste 2, Sticky Notes, Screensaver Inhibitor, Timer w Notification
  3. edit fstab
    sudo blkid    # for UUID
    sudo gedit /etc/fstab
    
  4. packages...
    wget https://gist.githubusercontent.com/bcchenbc/cd97144714a89d6dd69e/raw/aaaac1e2f76fcbcf44137f9acece357d7214bb00/install_packages.sh
    chmod +x install_packages.sh
    ./install_packages.sh
    
  5. zsh
    curl -L https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh | sh
    # ZSH_THEME="jreese" in .zshrc
    nano .zshrc
    chsh -s /bin/zsh
    
  6. latex
    # http://www.tug.org/texlive/quickinstall.html
    # http://mirror.ctan.org/systems/texlive/Images/
    sudo furiusisomount
    # mount texlive iso file
    ./install-tl
    # add "/usr/local/texlive/2015/bin/x86_64-linux" to PATH
    
  7. JRE
    # https://sites.google.com/site/easylinuxtipsproject/java#TOC-Install-JRE-64-bit-
    # https://java.com/en/download/linux_manual.jsp
     sudo mkdir -p -v /opt/java/64
     cd Downloads && tar xvzf ~/Downloads/jre-8u45-linux-x64.tar.gz
     sudo mv -v ~/Downloads/jre1.8.0_45 /opt/java/64
     sudo update-alternatives --install "/usr/bin/java" "java" "/opt/java/64/jre1.8.0_45/bin/java" 1
     sudo update-alternatives --set java /opt/java/64/jre1.8.0_45/bin/java
     mkdir -v ~/.mozilla/plugins
     sudo apt-get remove icedtea-6-plugin && sudo apt-get remove icedtea-7-plugin
     rm -v ~/.mozilla/plugins/libnpjp2.so
     ln -s /opt/java/64/jre1.8.0_45/lib/amd64/libnpjp2.so ~/.mozilla/plugins/
    # uncheck "Keep temporary file..." in "General", [Settings...]
     /opt/java/64/jre1.8.0_45/bin/ControlPanel
    

June 17, 2015

Add code blocks to Blogger

Credit goes to: http://shanhua0131.blogspot.com/2014/01/code.html
Reference: https://code.google.com/p/google-code-prettify/wiki/GettingStarted

1. Use [Edit HTML] in "Template" to add following line into the header.
<script src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js"></script> 2. Then, go "Template", [Customize], [Advanced], [Add CSS] to paste following codes, and click [Apply to Blog]
.post .prettyprint { 
  display: block; /* fixes a strange ie margin bug */
  font-family: Courier New; 
  font-size: 10pt; 
  overflow:auto; 
  background: #f0f0f0 url(data:image/gif;base64,iVBORw0KGgoAAAANSUhEUgAAAAsAAASwCAYAAAAt7rCDAAAABHNCSVQICAgIfAhkiAAAAQJJREFUeJzt0kEKhDAMBdA4zFmbM+W0upqFOhXrDILwsimFR5pfMrXW5jhZr7PwRlxVX8//jNHrGhExjXzdu9c5IiIz+7iqVmB7Hwp4OMa2nhhwN/PRGEMBh3Zjt6KfpzPztxW9MSAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzAMwzB8HS+J9kUTvzEDMwAAAABJRU5ErkJggg==) left top repeat-y;
  border: 1px solid #ccc;
  padding: 10px 10px 10px 21px;
  max-height:200px;
  line-height: 1.2em;
}

As the result, codes will be prettified by the script when encapsulated by
<pre class="prettyprint"> def example: codes = here </pre> In some cases: <xmp class="prettyprint"> <some codes="" with=""> <html like="" tags=""> </html></some> <|xmp> (Note the slash need to be changed. It was replaced by vertical bar here for displaying purpose. For more detail, see this)

February 9, 2015

install python pip on linux without root

While trying to run python on Karst, i was (not) surprised that the new server does not come with numpy/pandas, but again amazed by that having no pip available. While i did make the pip works on Quarry (the retired server), I cannot really follow the old process, since I don't really remember how.... The issue seems to be that to install pip, easy_install is necessary... Anyway, thanks Evgeny for the post in askbot.org and authors of setuptools, i finally got the pip:


(touch the .bashrc, for lazy ones)

January 29, 2015

testing2

新手上路

測試一