Sunday, May 1, 2016

What does laptop repair shops mean by "replacement" battery?

Last April 1, 2016, pumunta ako sa isang laptop repair shop sa SM City, Ecoland, Davao (name of shop removed to kind of protect the business) 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:


Tapos nung nilagay na yung battery sa laptop, hindi fit, medyo maluwang. Parang nagba-bounce-bounce.

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 mga laptop repair shops 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.


Update:

Well, mabilis umiinit yung battery. After a few months, bigla na lang namamatay yung fan ng laptop ko, at of course bigla din namamatay yung laptop.. tapos napansin ko may bukol yung battery. Pina-tingnan namin sa technician. Sabi ng technician, sira yung board. :(


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!

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.



Sunday, October 11, 2015

Frustration during college: solving programming contest problems

During first year in college, I was picked to be part of a team to join a programming competition.

During the competition our team was able to solve only one problem because the problems were hard. They were very much harder that what we were used to solving at school. The judges (or maybe one of the judges) accepted our answer as correct even though our solution did not pass all their test cases. It only passed the sample test case given on the problem. The formatting of our output was even wrong.

Of course the judges did not tell us that our solution did not pass all the test cases but I'm sure it did not. Maybe they accepted our solution so we will not be frustrated and will still join the programming competition the next year.

That experience made me very interested in finding out how to solve those kinds of programming problems.

During my search, I found out that I need knowledge on data structures, algorithms and discrete mathematics, among others, to be able to solve those problems.

Algorithms was hard

So I started reading a book on algorithms in the library. I was able to finish only a few pages.

It was hard, especially when no one is guiding you. And I don’t have a strong background in mathematics.

My algorithms and discrete math classes in college were also of no help because we were still solving simple problems in those classes. (If you want to have an idea on why these classes didn't help, you can read this.) But I am still thankful for the experiences of joining a programming contest because it exposed me to the hard kind of problems that computer science attempts to solve (it's okay with me for now even if I do not know how to solve them).

I was able to join two more programming contests after the first one, but still the problems that our team was able to solve are the simple ones -- the kind of problems called "ad hoc" like the "3n + 1 problem".

Focused on Business Applications

During my later years in college, I decided that I will concentrate on studying how to create business applications rather than solving algorithmic problems because I was thinking that I will not be solving algorithmic problems with the kind of job that I am expecting to have in the future.

Now that I already have a job, I have come to enjoy John Sonmez's blog. In one of his blog posts I read that solving programming contest problems can help enhance problem solving skills.

John Sonmez's blog rekindled my desire to solve algorithmic problems

So I started solving some algorithmic problems again using the UVA Online judge. I was able to solve some "ad hoc" problems and problems that require knowledge on some basic data structures like the stack and queue. (See my User Statistics here)

Recently, reading John Sonmez's blog lead me to the article "Solving Problems, Breaking it down" where I discovered Codility.com.

I am able to solve the first 3 problems in Codility Lessons.

Codility: FrogJmp problem

I followed his advice on solving the problem manually and creating a set of test cases.

This is the screenshot of my manual solution and test cases for the problem "FrogJmp".



My solution to "FrogJmp" can be viewed in https://codility.com/demo/results/trainingTRB9A9-Z7Z/

Codility: TapeEquilibrium problem

"TapeEquilibrium" is actually the first problem I solved on Codility. ("FrogJmp" is the second and "PermMissingElem" the last)

  • Score: 50%
  • some incorrect answers and time complexity is O(n^2)

  • Score: 66%
  • correct answers but time complexity is still O(n^2)

  • Score: 100%
  • time complexity is now O(2n) or O(n); we don't have to compute sum over and over again

Here is the screenshot of my manual solution. Notice that I did not create test cases. That is the reason why on my first attempt I got some incorrect answers.
  

Codility: PermMissingElem problem

  • Used C

  • Used C# instead of C because I thought that the cause of the error is the small size of int in C… but I still get the same results -- wrong answer

  • I gave up with my previous method. Here, I created another array with the size of (A.Length + 2).


Some lessons learned

1. Be sure to create test cases when solving programming problems
2. Write your solution on paper first

I hope my knowledge on data structures, algorithms, and discrete mathematics will increase so that I can be able to solve the harder algorithmic problems.

Happy coding!

PS: Please pardon my English.