Shurn the Awesomer
My first attempt at Machine Learning

My first attempt at Machine Learning

Written on Tue, 28 June 2016

So I've started doing learning machine learning with tensorflow. Coming from a PHP background, I often forget that python doesn't require semi-colon. I haven't done anything impressive yet. Just some codes to make sure that my tensorflow works.

So here's the code that I've tried so far.

import tensorflow as tf
matrix1 = tf.constant([ [3., 3.] ])
matrix2 = tf.constant([ [2.], [2.] ])
product = tf.matmul(matrix1, matrix2)

sess = tf.Session()
result = sess.run(product)
print(result)

sess.close()

And my output is [ [ 12.] ]

Honestly, I don't know what's matmul, mathematically and programmatically. But I'll figure it out along the way. I just need more practise. At least I know I can get tensorflow to work.

Tutorial: Setting up Tensorflow in Ubuntu 16.04

Tutorial: Setting up Tensorflow in Ubuntu 16.04

Written on Mon, 27 June 2016

So these days I'm just learning up on Machine Learning. Quite a fascinating subject. But I'm no data scientist (yet!) so it's quite daunting what Machine Learning is capable of.

Today's tutorial will just be about setting up TensorFlow on your Ubuntu machine. I won't go in depth about machine learning algorithm or help you build a Terminator T-5000, for obvious reasons.

In my machine build, I do not have a Graphic Card, so I won't be touching on graphic card related configuration. But I sure don't mind you sponsoring me a Quadro M6000. I'm also using 64bit computer. Seriously, why would you have a 32bit computer to run Machine Learning?

Step 1: Installing Python3


There's no reason to use a distribution no longer receiving upgrades. Python2 will still be maintained but why not use the one built for the future? Let's install Python3.

apt-get install python3-pip python3-dev

Step 2: Installing Tensorflow

export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.9.0-cp35-cp35m-linux_x86_64.whl
pip3 install --upgrade $TF_BINARY_URL

This will take some time. Go make yourself some coffee!

Step3: Testing your installation


Let's execute python to make sure your installation works.

python3
>>>import tensorflow as tf
>>>hello = tf.constant('Hello, TensorFlow!')
>>>sess = tf.Session()
>>>print(sess.run(hello))
Hello, TensorFlow!
>>>a = tf.constant(10)
>>>b = tf.constant(32)
>>>print(sess.run(a + b))
42
>>>exit()

Step 4: Run your first Tensorflow Model


Tensor is nothing if you don't run any machine learning. Let's run your first Tensorflow Model.

cd /usr/local/lib/python3.5/dist-packages/tensorflow
python3 -m tensorflow.models.image.mnist.convolutional

Congratulations! You have run your first Machine Learning model. This model will take quite awhile to complete. Took me more than 40 minutes on my slow machine without GPU. If you have a GPU installed, I'm sure it will be a whole load faster.

Setting up Active Directory with Samba on Ubuntu 16.04

Setting up Active Directory with Samba on Ubuntu 16.04

Written on Tue, 21 June 2016

The last time I set up Active Directory as primary controller service was on 14.04. Since then, Ubuntu has been updated to 16.04.

The installation this time round is much easier than I expected. So here goes!

Prerequisites:

  • You have Ubuntu 16.04 installed
  • You have knowledge of linux commands
  • You have some knowledge of how Samba works

We won't be using this server as file server. It's not recommended to put AD and file service in one server. That way, AD can continue to serve while file server is busy. It's not difficult to set up file server along with AD, but that won't be covered today. I'm just going to focus on setting up AD.

Most of the commands are done on root account. If you're not using root, be sure to add sudo before every command.

Setup Box Information


AD DC Hostname: ADSHURN
AD DNS Domain Name: shurn.me
Kerberos Realm: shurn.me
NT4 Domain Name/NetBIOS Name: shurn
IP Address: 10.0.0.2
Server Role: Domain Controller (DC)
Forwarder DNS Server: 10.0.0.1
File System: BTRFS

Your setup will be very different from mine, so you should adapt this tutorial to your own setup. I'll highlight the setup configuration with italics.

Step 1: Making sure Ubuntu is updated and current


It's always best to setup your AD on a well updated Ubuntu. Many bugs are fixed by the time you installed your Ubuntu.

apt-get update
apt-get dist-upgrade

Step 2: Download the required files

apt-get install attr build-essential libacl1-dev libattr1-dev libblkid-dev libgnutls-dev libreadline-dev python-dev libpam0g-dev python-dnspython gdb pkg-config libpopt-dev libldap2-dev dnsutils libbsd-dev attr krb5-user docbook-xsl libcups2-dev acl ntp ntpdate winbind

During Installation, your kerberos will ask you for information.

Realm=shurn.me
Server=shurn.me
Kerberos Login=shurn.me

Step 3: Setting up Static IP address


Active Directory requires static IP address.

nano /etc/network/interfaces

iface eth0 inet static
address 10.0.0.2
netmask 255.0.0.0
gateway 10.0.0.1
dns-nameservers 10.0.0.2 10.0.0.1
dns-search shurn.me


Later we will visit back this file to change the DNS information

Step 4: Setting up hostname

nano /etc/hostname


Put in the hostname of your AD

adshurn

Step 5: Reboot


Let's reboot the computer for all the configurations to take effect.

reboot

Step 6: Setting Host File


We need to make sure adshurn properly resolves to localhost at all times.

nano /etc/hosts

127.0.1.1 adshurn.shurn.me adshurn

Step 7: Setting up NTP


Network Time Protocol is the system that manages what time it is on your system, and it is important that our time is accurate for the proper functioning of Kerberos.

service ntp stop
ntpdate -B 0.ubuntu.pool.ntp.org
service ntp start

Step 8: Setting up Samba (finally)


So here's the main course of the entire tutorial. Let's install Samba.

apt-get install samba smbclient


We need to move the existing smb.conf file away so that we can properly generate a new file.

mv /etc/samba/smb.conf /etc/samba/smb.conf.orig


I usually use the interactive tool to set up Samba. You should too anyway.

samba-tool domain provision --use-rfc2307 --interactive

Realm: SHURN.ME
DOMAIN:''SHURN"
Server Role:dc
DNS backend:SAMBA_INTERNAL
DNS forwarder IP address:10.0.0.1
Administrator password: V3ryS3cur3P@$$w0rd

Step 9: Removing upstream DNS


Now, we remove the upstream DNS that we placed in the network configuration. resolv.conf is generated every time the system boots up so we need to ensure the next reboot, it searches the internal DNS. Samba is now managing all the DNS request.

nano /etc/network/interfaces

dns-nameservers 10.0.0.2

reboot

Step 10: Testing DNS works


Let's check that the DNS is working as expected. Remember to replace the setup information with yours.

host -t SRV _ldap._tcp.shurn.me
_ldap._tcp.shurn.mehas SRV record 0 100 389 adshurn.shurn.me

host -t SRV _kerberos._udp.shurn.me
_kerberos._udp.shurn.me has SRV record 0 100 88 adshurn.shurn.me

host -t A adshurn.shurn.me
adshurn.shurn.me has address 10.0.0.2

Step 11: Setting up Kerberos


As usual, let's move the original kerberos configuration to a safe place. Then we use the kerberos configuration provided by Samba.

mv /etc/krb5.conf /etc/krb5.conf.orig
ln -sf /var/lib/samba/private/krb5.conf /etc/krb5.conf

Step 12: Testing Kerberos and Samba


Let's make sure kerberos is working as expected

kinit administrator@SHURN.ME


Enter the password you used during Samba setup

klist


You should see valid krbtgt ticket.

smbclient -L adshurn.shurn.me -U 'administrator'


You should see netlogon and sysvol listed.

smbclient //localhost/netlogon -U 'administrator'


You should be able to authenticate properly.

Congratulations!


You should now have a properly set up Active Directory working in your environment. Pretty easy and straight forward isn't it?

New Tron Design

New Tron Design

Written on Sun, 19 June 2016

Hey,

How do you guys like my design? It's based on the Tron design. I thought I like the Tron Legacy and it's so futuristic. So I decided on this tron-istic theme.

So far, I hope everything is working fine with this design. I've been facing problems with Foundation's Sticky plugin. I'm considering not to use it anymore. It's so buggy.

But that's it for now. What should I work on next? Perhaps improve on my navigation? Then maybe SEO image for every blogpost? Because I believe these are the 2 things left before I am confident to annouce this site.

My site is now ajaxed

Written on Sun, 12 June 2016

Alright! More progress on my site.

I've finally made the entire site ajaxed. It will also navigate properly when you hit forward and backward.

It's not really my first attempt. I've done this effect with other projects before. This time round, it's mostly copy and paste. So next up, I'm probably going to design the site to look more pleasing. Hmmm.... What kind of design would look nice for this little site?

About Me

Greetings Earthlings , Shurn the Awesomer is here to give you an awesome time.

This little site is a record of my life, opinions, and views. I'm mainly writing about Technology & Gadgets, Busting Creationist Myths, and other philosophical stuff.

This site is done using CakePHP.

Uptime

With this uptime, how much more can I be proud of to showcase to the world? This uptime monitoring is brought to you by StatusCake since 13th May 2017.

Copyright

I will always check for copyright usage before using any materials on my site. Whenever due, credit shall be given.

However, if you notice that I may have infringed on any copyright material. Please do not hesitate to contact me. All works of every artist deserves to be honoured and respected.