Monday, August 8, 2016

I'm reviewing data structures and come graph algorithms using Stanford's CS106X

A few weeks ago, I wanted to be able to solve some problems on UVA Online Judge that requires some knowledge of graph algorithms. So I thought of trying to do again the assignments for Stanford's CS106B that I did last 2011.

The problem was that the assignment files that I have requires Visual Studio 2005. I tried to find ways to make it work on VS 2015 but I failed.

So I went to the latest CS106B website to download their latest assignment files (maybe they are using Visual Studio 2015 now?).

... Toinks! I needed to login to download the files. But I'm not a Stanford student! So I was not able to download the files.

Luckily, I found the latest website of CS106X and the files are downloadable. I thought to myself that the problems for CS106X might be more difficult than CS106B's but I think I can be able to do this now because I already experienced solving problems similar to these before.

The handout on the Course Information says that uploading my code to GitHub is a violation to the Honor Code...

The following four activities are among the many considered to be Honor Code violations in this course:
1. Looking at another student's code.
2. Showing another student your code, or making your code public so that it's searchable and easily discovered online or elsewhere.
3. Discussing assignments in such detail that you duplicate a portion of someone else's code in your own program.
4. Uploading your code to a public repository (e.g. github.com or bitbucket.com) so that others can easily discover it via word of mouth or search engines. If you'd like to upload your code to a private repository, you can do so on bitbucket or some other hosting service that provides free-of-charge private hosting.

... so I'm not going to put my code on GitHub or anywhere where anyone can download it. (I placed my solutions online last 2011 when I did CS106B but I already removed them.)

What I'm going to do instead is to put screenshots and the finished executable files of my solutions online just to give proof that I solved the exercises.

You can see the screenshots and executable files of my solutions on my GitHub.

Here is the screenshot of the first problem that I did:



Thursday, August 4, 2016

An easy to read Discrete Math book, I hope :)

I found a book which I believe can help me begin to study Discrete Mathematics and other parts of theoretical computer science: the Building Blocks of Theoretical Computer Science by Margaret M. Fleck.

I found the book from a list of books on Github.

I became interested with the book because the preface says "Everyone can do proofs".

And then says this:
"Some of you are brilliant young theoreticians and you’ll think this stuff is fun because it’s what you naturally like to do. However, many of you are future software and hardware engineers. Some of you may never think of formal mathematics as “fun.” That’s ok. We understand. We’re hoping to give you a sense of why it’s pretty and useful, and enough fluency with it to communicate with the theoretical side of the field."
I'm happy that there are math people out there who are considerate to programmers like me who do not have a very rich math background... and they are doing something to make it easier for us to understand that things that they understand!!! Wow!

I actually do think that formal mathematics is fun. I just don't understand them now.

I hope this book will help get me started in studying the more complex parts of computer science.


Another thing is that, a few days ago, I actually found another interesting book that I believe is similar to the one above: "Mathematical Foundations of Computing" by Keith Schwarz. It is a course reader of Stanford's CS 103 last Winter 2016.

What made me become interested to this one is the statement in the Course Information about prerequisites:
"CS103 is a theory course, but doesn't have any math prerequisites. You should feel comfortable with high-school algebra (i.e. factoring and multiplying polynomials), but you do not need to have taken precalculus or calculus prior to taking CS103. We'll build up all the mathematical machinery we need as we go."
I thought I need calculus when studying discrete math. Well, maybe it is needed in more advanced discrete math? I don't know.

But I will first use "Building Blocks of Theoretical Computer Science" then the second book, "Mathematical Foundations of Computing".

Happy coding!! I mean, mathematicking :D :D


Here's an inspiring video that I got from the webpage of Stanford's CS 103 last Winter 2016:



She says, "Math is hard. But you can do it."

Thanks!

The Angular 2 "Tour of Heroes" tutorial has a missing part

I think there is something missing in the "Routing" part of the "Tour of Heroes" tutorial -- after the "Make the router available" section and before the "Router Links" section.

The <router-outlet> needs "directives: [ROUTER_DIRECTIVES]". But the code for that is given way below of the tutorial.

I got confused. But I was able to see the error and found a fix for it.

Maybe you got confused also.

Here is the link to what I think should be placed in that missing part. I'm not a native English speaker so my English might not be 100% correct but I believe you can be able to understand it.

Happy coding!


Tuesday, August 2, 2016

Is it ok to write "selfish" blog posts?

Selfish?

By "sefish" I don't really mean this:
Concerned chiefly or only with yourself and your advantage to the exclusion of others - from Wordweb
I used that word just to get your attention. :)

What I really mean to say is this: "Is it okay to write blog posts which might seem selfish?" or "Is it okay to write blog posts about yourself and what you are currently doing, and the problems you encountered in, for example, programming?"

Well, Vaughn Vernon has this to say to the question "Do you have any recommendations for newbie blog writers?" in the comments section of one of his articles:
"Write about what you are doing. When you face a tough problem in your work then you find a breakthrough, it’s probably something others will face. Blog about it." - Vaughn Vernon
I think I also encountered statements like that from John Sonmez's blog SimpleProgrammer.com.

I will try to update this post with similar statements from other people in the future.




(Actually I have this kind of thought many years ago that these "selfish" blog post might be useful in the future if people will study something related to past events and predicting future events. But maybe it's just an imagination that will never happen :D )

Sunday, July 31, 2016

What is the purpose of "imports" in project.json of .NET Core apps?

I was doing the tutorial "Building Your First Web API with ASP.NET Core MVC and Visual Studio" and after I finished it, I thought of trying to see if Moq will work with .NET Core.


Then I changed the content project.json file with the JSON below whose significant parts came from the "Testing your Console App" section of the tutorial "Getting started with .NET Core on Windows/Linux/macOS using the command line":

Then I tried to remove the "imports" part of the project.json file because I do not know what it was for. But this error pops up in Visual Studio:



... and errors like this in the Output window:
Package xunit.assert 2.1.0 is not compatible with netcoreapp1.0 (.NETCoreApp,Version=v1.0). Package xunit.assert 2.1.0 supports:
- dotnet (.NETPlatform,Version=v5.0)
- portable-net45+win8+wp8+wpa81 (.NETPortable,Version=v0.0,Profile=Profile259)

So I tried to look for the purpose of this "imports".

I found the docs for project.json but I do not understand what it is trying to say.

Will cause other packages targeting portable-net45+win8 to be usable when targeting netcoreapp1.0 with the current project.
What does that mean?

Then I tried to google for using this:
more explanation of "imports": "portable-net45+win8"
Google shows only one result which came from StackOverflow which led me to an article from the EF docs. It says this regarding EF:
Some of EF Core’s dependencies do not support .NET Standard yet. EF Core in .NET Standard and .NET Core projects may require adding “imports” to project.json as a temporary workaround.

The workaround is to manually import the portable profile “portable-net451+win8”. This forces NuGet to treat this binaries that match this profile as a compatible framework with .NET Standard, even though they are not. Although “portable-net451+win8” is not 100% compatible with .NET Standard, it is compatible enough for the transition from PCL to .NET Standard. Imports can be removed when EF’s dependencies eventually upgrade to .NET Standard.
That is a much better explanation! Even though I do not know what PCL is :) .

Happy coding!

Saturday, July 30, 2016

Why I Started Blogging (Reprise)

I recently started thinking about possible consequences of the things I said about the schools/colleges I attended in my previous blog posts: here and here.

I was thinking that these blog posts might drive away prospective employers or clients in the future because they might think I am a ranter.

Then I remembered that I have written something that sounds like those "rants" in my first blog post.

So I looked for that first blog post and read it again.

...

WOW! I was calm when I wrote that one. I was not ranting!!

And it made me remember the persons (I thought it was only one person) who said that "Programming is easy" and that "Programming Well is hard". They were David Malan and his co-professor on his video lecture for CS50 many years ago.

It also made me remember the first reason why I started blogging: it was to put my programming outputs online.

And then this one (this is really good):
I'm not saying that I have never learned anything from the schools I attended. In fact, there are things that I believe I could have not known had I not attended these schools (tama ba akong grammar?[Is my grammar correct]). So I have learned many important things from my schools.

But it is the "well" part of programming that I need to know now. And I have to find it somewhere else.
And this one also:
I am also planning to pursue a degree in mathematics in the near future if I have time and enough money.
I thought that this mathematics degree thing only came to my mind a few months ago. But it was already there five years ago.

... So if you are a potential employer or client, please don't be afraid of hiring me.

Those two blog posts I linked to above are just part of my journey as a programmer.

... and I have never complained online about my previous employers and clients. They were good employers. They were not perfect (and I don't really know what a perfect employer is.. and I am not perfect) but they were good.


PS:
I worked for Jairosolutions and Mynd Dynamic (with Common Census as our client) in the past. I resigned from Mynd Dynamic last May because I wanted to finish my bachelor's degree in CS because I want to get a degree in mathematics.
But because of some personal problems, I think I'm going to stop my schooling again and concentrate on honing my programming skills in .NET Core and Angular2 and maybe Xamarin and look for a job that needs these kinds of skills.

Sunday, July 10, 2016

My first graph problem solved: "10928 - My Dear Neighbours"

[UPDATE (July 27, 2016): I remember that this is not really the first graph problem I solved. It is, rather, the first graph problem on UVA Online Judge that I solved. I was already able to solve a graph problem when I took the free Stanford course named CS106B last 2011. But I already forgot how I solved it.]

I am so excited!!!

I solved my first graph related problem: the UVA Online Judge's problem #10928 "My Dear Neighbours".

This might just be a very simple problem but at least I am able to get started with solving graph problems.

Picture taken from http://uhunt.felix-halim.net/

Here is my solution:


My actual solution is actually here.

Happy coding!!!

Friday, July 8, 2016

Kidapawan Programmers Club

I have always wanted to be part of a coding club since first year in college. But there are no coding clubs in the schools (in our city) where I went to study.

So few months ago, when I decided to resign from my job and go back to college to finish by bachelor's degree, I said to myself that I am going to start a coding club and will recruit students that are very interested in programming from all colleges in our city; and I am going to name the club "Kidapawan Programmers Club".

I had two goals for starting this club:
  1. The club members (including me) will help each other solve programming contest problems like those in UVA Online Judge. (At the moment, I am able to solve only those simple ad hoc problems and some simple problems that involve the use of basic data structures like stack and queue. I am hoping that the club will be able to recruit someone who can help us solve more complex problems like problems on graphs and computational geometry.)
  2. The club members will help each other study how to create software systems that are easy to maintain and to write code that are easy to read.
As part of goal number two, I also wanted to instill in the minds of the club members (including me) this idea that Robert Martin said in his blog post titled "A Little Architecture":
"The important decisions that a Software Architect makes are the ones that allow you to NOT make the decisions about the database, and the webserver, and the frameworks."


The original plan was to recruit from all colleges that have IT courses in our city, but I was only able to recruit from the school I am currently studying in because I became lazy in looking for ways to recruit from other schools when these thoughts came to my mind:
(1) it will be hard to find a meeting place if the club members are coming from different schools, and
(2) it will also be hard to find a schedule so that all the club members will be present during the meetings.

But I am hoping that many aspiring programmers from other schools will join the club someday (if the club will continue to exist many years from now).



We already started meeting yesterday, July 7, 2016.

The things we discussed and will be discussing during our meetings might seem very simple to many sophisticated programmers out there but please be patient with us. We are hoping that this club will help improve the programming abilities of the club members and will help "increase the lower bound" (as Steven and Felix Halim says regarding Competitive Programming) of IT and computer science education in our city.

Here are some links if you want to know more about the club:
The club's Facebook group - https://www.facebook.com/groups/KidapawanProgrammersClub
The club's GitHub - https://github.com/KidapawanProgrammersClub

Here is the link for the list of club members: https://goo.gl/mKxlk8.
By the time this article is written, the club has only 5 members:
  • Jeremiah (Jboy) M. Flaga (ako!)
  • Dinah Joy Sarino BolaƱos
  • Ian Keir G. Abes
  • Charlemagne Bulaybulay Ociones
  • Rollie Jan Suerte Relampagos
I hope we, the club members, will become successful programmers someday.

Happy coding!!! and please pardon my English :D



[UPDATE (July 29, 2016): I think I failed in leading the club. After our first two meetings, the club members do not seem to be interested anymore. So I asked them to give me just two meetings to discuss to them an introduction to Unit Testing and TDD, and Layered Architecture. Then after that we can end the club. I think one of the reasons why they became uninterested with the club is because we failed to recruit more students to join the club. Maybe another thing is that my lectures are boring?? :) (One member slept in the middle of our discussion during our second meeting. The reason might be because I was just kind of reviewing our previous lesson and failed to give new knowledge to them. I think I can understand because I myself tend to become bored if the lesson is "balik-balik")

...but I do not understand why other IT and Computer Science students in our school would not want to join a programming club. Maybe they do not know that many IT/CS degrees in the Philippines are substandard. Maybe they do not know that in our school, our graduating students know only a fraction of what freshmen students of other schools know. tsk tsk.

(or maybe I'm comparing apples to oranges on that one?? I'm sorry for that. Okay I'm going to change it to a safer statment: "Maybe they do not know that our graduating students only know a small fraction of what graduating students of other schools know")

...Or maybe they are not really interested in programming even though they have the potential of becoming good programmers. (Take note that we were trying to recruit only those students who excel or are trying to excel in their programming classes.)

I think I am going to suggest to the current members of the club that we will create another club that is open to everyone in our school (no entrance test) as suggested by one faculty in our school. I do not have any idea yet what we are going to do in that kind of club. Maybe we will just try to answer programming related questions of anyone who joins?]



[ANOTHER UPDATE (still July 29, 2016):

Regarding my criticisms on the colleges/schools where I went to study...

I am not trying to criticize all the teachers/instructors in the schools I went to. I can say that half of them are good teachers. The other half are not good.

I'm not sure if I can blame the 'not so good' teachers for being not good because they might just be products of teachers who are also not good.

I'm also not sure also if I can blame the administration of the schools I went to because they might not know that they will be offering substandard IT/CS education when they decided to offer them.

But if they knew that they will be offering a substandard IT/CS education and decided to offer it anyway, I will not be afraid to accuse them of being liars -- they are lying to those students who want to study IT/CS badly. These students will be able to find a school in other places if they can't find a school that offer these courses nearby.

But I will still be happy and thankful if they will find a way to solve this problem of offering substandard IT/CS education. I hope that my words above will serve as constructive criticism.

If you are reading this and you are part of the problem, maybe you will be angry with me now. But please be angry only for a very short time, then after that, do your best to become part of the solution to the problem.

In the previous years -- 2008, 2009, 2011 -- and today, 2016, our IT/CS education might be substandard but if you will tell yourself to be part of the solution from now on, then maybe by the year 2030 we will be one of the best IT/CS educators in our country.]

Sunday, May 1, 2016

What does SST Laptop mean by "replacement" battery?

(I believe na may kulang sa info na ibinibigay ng SST Laptop about sa ibinibenta nilang battery. Wala akong balak na siraan ang SST Laptop. Parang constructive criticism lang ito. Gusto ko lang sanang next time ay i-explain nila nang mabuti kung ano ang ibig sabihin ng "replacement" -- na yung "replacement" battery ay hindi talaga galing sa manufacturer ng laptop, para ma-weight ng customer kung bibili ba siya o hindi :) )


Last April 1, 2016, pumunta ako sa SM City (Ecoland, Davao) branch ng SST Laptop para mag-tanong kung dumating na ba yung inorder kong Toshiba laptop battery.

Sabi nung nagbabantay doon ay dumating na daw. Dalhin ko na lang daw yung laptop ko para ma-test yung battery.

So umalis ako at kinuha ko yung laptop ko.

Pagbalik ko sa shop nila, kinuha na niya yung battery. Nang nakita ko ang battery na-disappoint ako dahil hindi pala galing sa Toshiba yung battery.

Nagreklamo ako kung bakit hindi galing sa Toshiba yung battery. Sabi nung nagbabantay ay "replacement" lang daw itong battery so hindi talaga katulad ng original.

Ito yung picture ng original (nasa itaas) at nung "replacement" (nasa ibaba):



At ito yung picture ng resibo para naman hindi sasabihin ng mga nagbabasa na nagsisinungaling ako:



Gusto ko sanang hindi na lang itutuloy yung pag-purchase. Pero dahil may 6 months warranty naman daw e sabi ko na lang sa sarili ko na titingnan ko na lang kung ok ba ang performance ng battery.

So dinala ko na lang yung battery.

Sa first 3 days, palaging 100% yung battery status na nirereport sa screen ko kahit sobra ng 30 minutes nang hindi naka-charge.



Plano ko sana na ito yung gagamitin kong dahilan para ibalik ang battery at makuha ko yung ibinayad ko.

Pero dahil nawala naman after 3 days e binalewala ko na.

Pero hindi umaabot ng 4 hours or 3 hours yung battery ay nade-drain na. Parang 1.5 hours lang yata drained na.

Yun lang :)

I just hope hindi makakasira nga laptop itong battery na nabili ko. hehe


Ang nirereklamo ko lang ay yung pag-gamit ng term na "replacement. "Replacement" din yung ginamit na term noong time na nag-order ako about a month before dumating yung order ko. Akala ko naman yung meaning ng "replacement" ay "tulad ng original".

Gusto ko lang sanang magrequest sa SST Laptop na i-explain na hindi talaga galing sa manufacturer ng laptop ang "replacement" battery na ipinagbibili nila para makapag-decide nang maayos ang customer. :)

Thank you!
I hope hindi kayo magagalit :)


Isinulat ko lang ito para kung sakaling itong battery ang magiging dahilan ng pagkasira ng laptop ko tulad ng nasa mga picture sa article na "Danger: Why You Shouldn’t Buy Cheap Third-Party Batteries For Laptops or Smartphones" ay may masisisi ako hahahaha.


Sunday, April 17, 2016

My first TDD Kata - String Calculator in C#

I heard about TDD a few years ago but I only appreciated its value after reading some of Robert Martin's blog posts in the past few weeks (and also after having experienced writing post-development unit tests at work).

So today I decided to start doing katas for TDD...


This is my first TDD Kata: https://github.com/jboyflaga2/ProgrammingExercises-CSharp/tree/master/TDDKatas/StringCalculator

There are some things in the specs that I did not include in the implementation. I will just do them next time (really?!).

I found the "specs" for this kata in "Learning Test Driven Development with TDD Katas" by Gaurav Kumar Arora. (But the original author of this kata is Roy Osherove)

This is written in C#.

I used Visual Studio 2015 Community Edition to create a .NET Core project for this kata.

I first planned to use just the Visual Studio Code text editor for this but I was having an error with restoring xUnit. The error was "The dependency xunit.abstractions 2.0.0 does not support framework dnxcore".

I hope this error will be fixed soon.


Let's all learn TDD!!! Happy coding!

Saturday, April 2, 2016

Godlike programming should be our goal!

My blog description has a very bold statement: "Godlike programming should be our goal!"

Does that mean that I already know what godlike programming is?

No! Not really. :)

Does that mean the I know someone who already know what godlike programming is?

Still No. :)


Because God did not give us a book on godlike programming (just like he did not give us a book on understanding cat behavior) we will never know what godlike programming is until God himself returns to show us what it is.

But for now, while waiting for God to show us what godlike programming is (if knowing godlike programming is even significant in our future state), we should try to follow those who seek godlike programming in the present -- like Robert Martin (Uncle Bob), Kent Beck ...and those giants before them, those after them, and those who are simultaneously living with them :) .

We might not agree with everything they teach and believe in but we must at least try to read what they have written and follow their steps and make improvements to their ideas when we have a better idea (I might never have one but you might) and constructively criticize bad ideas.

...And by "seeking godlike programming" I mean "seeking perfection when creating software" -- maximizing the benefits to people while minimizing the bad effects to people (which includes us programmers of course).


...But how do we (ultimately) know which things are beneficial to people/us and the ones that are bad for the people/us? ... That will be your assignment :) ...and remember that we must have a reason for what we believe.

Happy coding!!!


UPDATE (July 31, 2016):
I now remember, through my first blog post, the persons who said "Programming is easy" and "Programming Well is hard": they were David Malan and his co-lecturer (or maybe a TA?) in his lectures for either CS50 or Computer Science E-1 (I can't remember anymore which of the two).

I tried to locate the exact video but I can't locate it. My guess is that it is in a video from Computer Science E-1 Spring 2010 (maybe in Lecture 9: Programming) or CS50 Fall 2010.

Thursday, March 31, 2016

Functional Programming for the Object-Oriented Programmer: My solution to the exercises of the sample chapter I found

I read about the book "Functional Programming for the Object-Oriented Programmer" and Clojure on Uncle Bob Martin's blog.

I am interested in learning about functional programming now because Uncle Bob says in his blog that a functional programming language will be the solution of creating software for a processor with many cores.

I am so excited about learning FP and Clojure so I'm going to post my solutions to the exercises of the sample chapter of the book mentioned above.

(I omitted some parts of the questions. Please download the sample chapter if you want to see the whole questions)


Exercise 1: Given what you know now, can you define a function second that returns the second
element of a list?

(def second (fn [list] (nth list 1)))


Exercise 2: Give two implementations of third, which returns the third element of a list.

(def third (fn [list] (nth list 2)))

(def third (fn [list] (first (rest (rest list)))))


Exercise 3: Implement add-squares.

(def square (fn [n] (* n n)))
(def add-squares (fn [& list] (apply +  (map square list))))


Exercise 4: The range function produces a sequence of numbers:
Using it and apply, implement a bizarre version of factorial that uses neither iteration nor recursion.

(def factorial (fn [n] (apply * (range 1 (+ n 1)))))


I did not do Excercise 5 :)


Exercise 6: Implement this function:
(prefix-of? candidate sequence): Both arguments are sequences. Returns true if the elements
in the candidate are the first elements in the sequence:

(def prefix-of? 
   (fn [candidate sequence] 
      (= candidate 
 (first (partition (count candidate) sequence)))))


Exercise 7: Implement this function:
(tails sequence): Returns a sequence of successively smaller subsequences of the argument.

(def tails 
   (fn [sequence]
      (map 
  drop
  (range 0 (+ 1 (count sequence)))
  (repeat (+ 1 (count sequence)) sequence))))


Exercise 8: In the first exercise in the chapter, I asked you to complete this function:

Mag-create siya ug list with one element inside which is also a list.

(after executing it on the command line)


Ahh I was wrong... "list" is a keyword (or a name of a function)

I googled the error -- I was wrong again -- the reason is because the the literal list is being used as a function. We cannot cast a literal list (I'm not sure if that is how we call it) into a function.