Posts

Showing posts with the label Level 1

[Level 1] Lost and Found in git

Once you get lost in git and you could try to find it by the following commands $ git fsck --lost-found $ git reset HEAD@{1} Wish this helps. regards, Stanley Huang

[Level 1] Reversion of git

Just read an article mentioned about the reversions of git, so take a note here. G H I J \ / \ / D E F \ | / \ \ | / | \|/ | B C \ / \ / A A = = A^0 B = A^ = A^1 = A~1 C = A^2 = A^2 D = A^^ = A^1^1 = A~2 E = B^2 = A^^2 F = B^3 = A^^3 G = A^^^ = A^1^1^1 = A~3 H = D^2 = B^^2 = A^^^2 = A~2^2 I = F^ = B^3^ = A^^3^ J = F^2 = B^3^2 = A^^3^2 reference: http://schacon.github.io/git/git-rev-parse#_specifying_revisions Wish this helps. regards, Stanley Huang

[ Level 1 ] Limit memory usage in Python program

We could limit memory usage in Python program. #!/usr/bin/env python3.5 import resource def show_memory_limit(): soft, hard = resource.getrlimit(resource.RLIMIT_DATA) print 'Soft limit changed to :', soft print 'Hard limit changed to :', hard def set_memory_limit(soft, hard): resource.setrlimit(resource.RLIMIT_DATA, (soft, hard)) #limit to one kilobyte if __name__ == '__main__': show_memory_limit() set_memory_limit(1024, 2048) show_memory_limit() Wish this helps. regards, Stanley Huang

[Level 1] Install RStudio on Ubuntu 16.04

Image
One you have installed R on Ubuntu, there is a great R develop environment called "RStudio". You could install "R Studio" via apt-get command. $ sudo apt-get -y install rstudio $ rstudio Wish this helps. regards, Stanley Huang

[Level 1] Install R in Ubuntu

Here are the steps to install R on Ubuntu 16.04 $ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 $ sudo add-apt-repository 'deb [arch=amd64,i386] https://cran.rstudio.com/bin/linux/ubuntu xenial/' $ sudo apt-get update $ sudo apt-get -y install r-base r-base-core $ sudo -i R ## test R Here are the steps to instal R packages from CRAN $ sudo -i R > install.packages('__package_name__') Wish this helps. regards, Stanley Huang

[Level 1] How to setup Debian for sharing screen on WebEx.

I installed Debian 8 on my laptop but cannot share my screen on WebEx. After I google it and I found I could share my screen by installing the following packages. libgcj14-awt:i386 libpangoft2-1.0-0:i386 libpangox-1.0-0:i386 libxft2:i386 libpangoxft-1.0-0:i386 libgtk2.0-0:i386libxmu6:i386 Wish this helps. regards, Stanley Huang

[ Level 1 ] What could we do in Sprint 0?

There are many different opinions about if team should have Sprint 0 or not. In my opinion, Sprint 0 is a good for team, because it could avoid team to take pressure immediately if no more Sprint 0.1, 0.2, 0.3...etc. What will I do in Sprint 0? Here is a task list of Sprint 0. * Kick-Off * Agile/Scrum training. (SM) => http://scrummethodology.com/ => http://scrumreferencecard.com/scrum-reference-card/ => 2 half day training. * Auto training. (Auto) * Schedule regular meetings. (SM) * Define user stories. (PO) * Define DoD. (Team) * Prepare developing/testing/integration environment. Wish this helps. regards, Stanley Huang

[Level 1] git ignore

If you want git not to commit some temporary files or log files...etc., you could create .gitignore file to ignore them. If you don't have any idea about which file should be ignore, you could also download ignore templates that prepared by github. mkdir ~/git-home cd ~/git-home git init git clone https://github.com/github/gitignore cd ~/my_py_project cp ~/git-home/gitignore/Python.gitignore ./.gitignore Wish this helps. regards, Stanley Huang

[Level 1] HOWTO Installing Packages from Yaourt AUR in Archlinux.

If you want to install packages from Yaourt(Yet AnOther User Repository Tool ) AUR(Archlinux User Repository), you could follow the following steps. a. Install yaourt by downloading source code. 1. Install development environment. $ sudo pacman -S base-devel $ sudo pacman -S yajl 2. Download, build and install package-query $ curl -O https://aur.archlinux.org/packages/pa/package-query/package-query.tar.gz $ tar zxvf ./package-query.tar.gz $ cd ./package-query $ makepkg -si 3. Download, build and install Yaourt $ wget https://aur.archlinux.org/packages/ya/yaourt/yaourt.tar.gz $ tar zxvf ./yaourt.tar.gz $ cd ./yaourt $ makepkg -si b. Install yaourt from repository. 1. setup repository $ sudo su # cat >> /etc/pacman.conf <<EOF [archlinuxfr] SigLevel = Never Server = http://repo.archlinux.fr/$arch EOF 2. update repository and install yaourt # pacman -Syu # pacman -Ss yaourt Wish this helps. regards, Stanley Huang

[Level 1] Create git repository by command.

A script for creating git repository quickly. http://viget.com/extend/create-a-github-repo-from-the-command-line Wish this helps. regards, Stanley Huang

[ Level 1 ] Go installation and "Hello World" sample.

A friend of mine told me, if you could choose the programming language, choose the fashion one. I tried to use Go becuase it's "Go fashion"(Chinglish, means, fashion enough). The following script is the way to install Go in CentOS, you could refer to it if you also used CentOS. #!/bin/bash # install Go, gcc for Go rpm -q golang >/dev/null 2>&1 || sudo yum -y install golang libgo gcc-go # Hello World [ -e ./HelloWorld.go ] || cat > ./HelloWorld.go <<EOF package main import "fmt" func main() { fmt.Println("Hellow World!") } EOF # run as interpreter script go run ./HelloWorld.go # compile script and run it. gccgo -g -o ./HelloWorld.out ./HelloWorld.go && ./HelloWorld.out Wish this helps. regards, Stanley Huang

[ Level 1 ] Tips for sublime text.

Good tips for sublime. http://nipunbatra.wordpress.com/2014/01/30/plugins-for-python-development-in-sublime-text/ Wish this helps. regards, Stanley Huang

[Level 1] Install skype in CentOS 7.

If you want to install skype in CentOS 7. You need to download 32 bit library. Or you could lookup nux-desktop and it already has made for 32 bit libraries that required by skype. sudo rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-1.el7.nux.noarch.rpm; sudo yum localinstall http://download.skype.com/linux/skype-4.3.0.37-fedora.i586.rpm; Wish this helps. regards, Stanley Huang

[Level 1] How to install 32 bit java for Juniper VPN in CentOS.

## ## Precondition: you have to download 32 bit openjdk first! ## compat_32="compat-libstdc++-296" libs_for_vpn="xterm ld-linux.so.2 libstdc++.so.6 libz.so.1 libXext.so.6 libXrender.so.1" java_64_rpms="java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.x86_64 icedtea-web-1.4.1-0.el6.x86_64" libs_for_java_32="giflib.i686 nss.i686 libpng12.so.0 libpulse.so.0 rhino" java_32_rpm_url="ftp://ftp.muug.mb.ca/mirror/centos/6.5/os/i386/Packages/java-1.7.0-openjdk-1.7.0.45-2.4.3.3.el6.i686.rpm" java_32_rpm="`basename $java_32_rpm_url`" download_dir="/tmp" ## download 32bit java cd $download_dir; wget $java_32_rpm_url ## remove native openjdk sudo yum -y remove java-1.7.0-openjdk ## install 32 compatible libraries for app in $compat_32 do sudo yum -y install $app done ## install libraries for vpn for app in $libs_for_vpn do sudo yum -y install $app done ## install 64 bit java for app in $java_64_rpms do sudo yum -y...

[Level 1] How to yum to install specific version in CentOS.

If you want to use yum to install specific version in CentOS. First, you have to use option "--showduplicates" to get duplicate versions # yum --showduplicates list java-1.7.0-openjdk Loaded plugins: fastestmirror, refresh-packagekit, security, versionlock Loading mirror speeds from cached hostfile * base: mirror01.idc.hinet.net * elrepo: ftp.ne.jp * epel: ftp.cuhk.edu.hk * extras: mirror01.idc.hinet.net * remi: remi.kazukioishi.net * rpmforge: ftp.riken.jp * updates: mirror01.idc.hinet.net Available Packages java-1.7.0-openjdk.x86_64 1:1.7.0.45-2.4.3.3.el6 base java-1.7.0-openjdk.x86_64 1:1.7.0.45-2.4.3.4.el6_5 updates java-1.7.0-openjdk.x86_64 1:1.7.0.51-2.4.4.1.el6_5 updates java-1.7.0-openjdk.x86_64 1:1.7.0.55-2.4.7.1.el6_5 updates java-1.7.0-openjdk.x86_64 1:1.7.0.65-2.5.1.2.el6_5 updates After you got the information of versions, then you could instal...

[Level 1] How to trace the source code more efficient.

If you want to trace python call stack, you could get call sequence by using call_seq module. You could download call_seq from pypi website. https://pypi.python.org/pypi/call_seq/0.0.1 After you download it, you could prepare the python script like following. python from call_seq import CallSeq trail = CallSeq() trail.set_trace() # the code you want to trace. trail.unset_trace() trail.dump_to_file('output.json') After you create the output json file, then you could use browser module of call_seq to get visualization of call sequence. $ python -m call_seq.browser ./output.json Wish this helps. regards, Stanley Huang

[Level 1] Create secure web for iPython notebook.

The default protocol for iPython notebook is http and you didn't passphrase to enter notebook. If you want your notebook be secure, you could follow the steps to enable SSL and passphrase for it. 1. create profile: In [1]: ## create profile for secure web !ipython profile create secureweb 2. create passphrase: In [2]: ## create passphrase from IPython.lib import passwd passwd(passphrase='passphrase') Out[2]: 'sha1:24be7c5ab59a:b8b7d3c691b2db67a5ef855b625cb560e125e5e1' 3. Create SSL certificate $ cd /home/stanley/iPython_notebook/certs $ openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem Generating a 1024 bit RSA private key ..............++++++ ..........++++++ writing new private key to 'mycert.pem' ----- You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There ar...

[Level 1] Install slideshow support in iPython notebook.

Just found an iPython notebook extension support slideshow and you could install by the following steps. Precondition: Because this introduction would try to clone a github project, you have install git utility first. $ sudo apt-get -y install git 1. Use the following commands to install slideshow support. ## get porfile directory profile_dir = get_ipython().profile_dir.location ## clone extension from github import os tgt = os.path.join( profile_dir, 'static', 'custom') !git clone https://github.com/ipython-contrib/IPython-notebook-extensions.git $tgt %cd $tgt ## create a javascript for supporting slideshow %%writefile custom.js // we want strict javascript that fails // on ambiguous syntax "using strict"; // do not use notebook loaded event as it is re-triggerd on // revert to checkpoint but this allow extesnsion to be loaded // late enough to work. // $([IPython.events]).on('app_initialized.NotebookApp', function(){ /** Use path to...

[Level 1] How to auto restore when start iPython

iPython have a magic command call "alias". This command just command "alias" in unix shell could help you to create alias command in iPython environment. How could we save the alias that we created before, you could use "store" magic command. The alias would be saved in iPython internal db. ex. In [1]: %alias ipython_alias echo 'hello world' In [2]: %store ipython_alias After you exit iPython and restart it again, you need to restore the aliases from internal db. In [1]: %store -r And how could we make iPython auto-restore when we launch it? You could modify ipython_config.py in profile. ex. If you use default profile $> cat /home/stanley/.config/ipython/profile_default/ipython_config.py ... # StoreMagics configuration c.StoreMagics.autorestore = True # uncomment this line and assign autorestore as 'True' ... You could also create a script to add alias automatically. ## Add often use commands. security_commands = 'chmod ch...

[ Level 1 ] Install libraries for juniper vpn in 13.10

$ sudo apt-get remove sudo apt-get remove openjdk-6-jdk icedtea-6-plugin $ sudo apt-get install openjdk-7-jdk icedtea-7-plugin $ sudo apt-get install openjdk-7-jre:i386 $ sudo apt-get install libstdc++6:i386 lib32z1 lib32ncurses5 lib32bz2-1.0 libxext6:i386 libxrender1:i386 libxtst6:i386 libxi6:i386 Wish this helps. regards, Stanley Huang