This blog is no longer maintenance. I moved my blog to peternguyen24.com

Struggling with the lack of motivation.

What?

There are tons of time that I’m zero-motivated in my life.
Recent few weeks are strugling for me, since I feel like nothing is important for me to put effort into. Then, I decided to make a little research on the reason of less-motivated and find out the solution (for me).

Basically, motivation and enthusiasm is instance of desire and interest, and can be express by the driving force that push you to take action and pursue the target.
Most of people have their own desire and interest. Unluckily, they can get into the status of lacking motivation. The reason can be vary.

Let see the situation that one have a quite strong desire, strong interest, but still can’t put many effort to archive any goals in the field. That is not an comfortable feeling for one who experience this situation, and I guess not only me is in this squad, huh?

Why?

The reasons can be vary, but I choose 3 to think about

- Desire/interest/driving-force is not strong enough.
- Laziness
- Lack of faith, lack of self-believe

HowToFix?

1. Desire/interest/drive-force is not strong enough.

This would be the most general reason.
Motivation are normally short burst. I start acting enthusiastically at that strong desire point, but quickly drop it at middle way. Difficulty, no time, no money, distraction,… too many things can pull our driving-force away. Day by day, I forget what make me start.

My thought is finding things that can tell me over and over about my dream. Keep dream the big dream is important, no dream, no party!

Drawing a diagram, progress picture (cute bar with rainbow unicorn, or whatever you like) might be a way to regain the interest that we drop. I bought instant stickers to draw and put them in the front of my desk. It helps me remind myself about what I’m looking for in life.

Generally, it works, but in certain points, I myself reject to look at those booster sticker. It was me too lasy to even care about it.

2. Laziness

No need to explain about this. It’s laziness, obviously. Everyone know it.

This is also the most annoying problem of me. It cause over-deadline submission, class skipping, very low-performance (mostly) on what I dont like (some subjects in Univ, for instance), etc.

I was thinking that boosting motivation can be solution for this. Now look at what I dont like, but essential/necessary?

Till now, I still havent found a super-effective solution for myseft. I believe I will be something around increasing self-comitment with minor task and chores.

3. Lack of faith, lack of self-believe

In contrast of the first one, lack of faith, of self-confident is the obstacle that sits between me and me starting what I want.

Thinking is good, thinking too much about the difficulties isn’t. In other words, don’t fear.
Innocent is good. Taking off my mind problems and difficulties and going with my guts on achieving the goals usually result a higher performance. I find myself doing my job with the fool and hunger better. Steve was right! (hehe)

Then

All over the above, the best in my opinions is keep fighting.

  • Dont avoid small things.
  • Face the difficulties
  • Challenge myself
  • Take enough exercises.

Hash Table with Chain Implementation

Using chain is one solution for collision. Each element in array of hash table is a linked list, which store all the key_value pair that share the same hash. Initially, all slots of array will be NULL. For push in a pair of key-value, hash value is calculated, then the pair will be added at the end of the linked list of corresponding hash value.

Illustration:

Source: www.necessaryandsufficient.net

Complexity

Assume that the distribution of value in hash code is urniform, basic operations (such as get, set, remove) will be TABLE_SIZE time faster than storing all key-value linearly.

Implementation

  • In the implementation below, key-value pairs are assumed to be int-int.
  • TABLE_SIZE (size of hash array) = 128
[HashTable] [++]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;

class LinkedHashEntry{
private:
int key;
int value;
LinkedHashEntry* next;
public:
LinkedHashEntry( int key, int value ){
this->key = key;
this->value = value;
this->next = NULL;
}
int getKey(){
return this->key;
}
int getValue(){
return this->value;
}
void setValue(int value){
this->value = value;
}
LinkedHashEntry* getNext(){
return this->next;
}
void setNext(LinkedHashEntry* next){
this->next = next;
}
};




const int TABLE_SIZE = 128;
class HashTable{
private:
LinkedHashEntry ** table;
public:
HashTable(){
table = new LinkedHashEntry * [TABLE_SIZE];
for (int i=0; i<TABLE_SIZE; i++) {
table[i]= NULL;
}
}
int get(int key) {
int hash = (key %TABLE_SIZE);
LinkedHashEntry* entry = table[hash];
while (entry != NULL && entry->getKey()!=key) {
entry = entry -> getNext();
}
if (entry == NULL)
return -1;
else
return entry->getValue();
}
void set(int key, int value) {
int hash = (key % TABLE_SIZE);
LinkedHashEntry* entry = table[hash];
LinkedHashEntry* last_entry = NULL;;

while (entry != NULL && entry->getKey()!=key) {
if (entry -> getNext() == NULL ) {
last_entry = entry;
}
entry = entry -> getNext();
}
if (entry != NULL) {
entry -> setValue(value);
} else {
if (last_entry ==NULL) {
table[hash]= new LinkedHashEntry(key,value);
} else {
last_entry->setNext(new LinkedHashEntry(key,value) );
}
}
}
void remove(int key) {
int hash = (key % TABLE_SIZE);
LinkedHashEntry* entry = table[hash];
LinkedHashEntry* pre_entry = NULL;

while (entry != NULL && entry->getKey()!=key) {
pre_entry = entry;
entry = entry -> getNext();
}
if (entry !=NULL) {
if (pre_entry == NULL) {
table[hash] = entry->getNext();
delete entry;
} else {
pre_entry->setNext(entry->getNext() );
delete entry;
}
}
}
~HashTable(){
LinkedHashEntry * entry;
LinkedHashEntry * pre_entry;
for (int i=0 ; i<TABLE_SIZE; i++){
entry = table[i];
while (entry !=NULL) {
pre_entry = entry;
entry = entry ->getNext();
delete pre_entry;
}
}
delete[] table;
}
};

Creating hexo blog and deploy on Github

Setting hexo blog and deploy it on Github page is a good idea. To make your life easier in the case that you dont know how to combine 2 things, this is for you.

General Setup

You will need Git, Nodejs and npm on your computer before doing the rest of tutorial.

You also need hexo:

1
$ npm install -g hexo

Hexo Setup

Install Hexo:

1
$ npm install hexo-cli -g

Create and init Hexo project:

1
2
3
$ hexo init blog
$ cd blog
$ npm install

Add a packet that supports deploying hexo blog to Github page:

1
$ npm install hexo-deployer-git --save

Edit setting

Modify _config.yml file:

1
2
3
4
deploy:
type: git
repo: http://github.com/<yourusername>/<username>.github.io.git
branch: [branch]

Deploy:

Create github project yourusername.github.io.
Be aware, if you spell it wrong, things will not work.

To Github

1
$ hexo deploy

For testing in local host:

1
$ hexo server

Finally, dont forget to modify the “Hello World” post.

Hello World

1
echo "Hello World as my very first post, good enough?"

First of all, why am I here?

To improve my programming skills, writting ability, and also perspective.

And what will this blog be about?

The contents will be my experiences as a programmer, a learner. They can be tutorials, technical problems, or sometimes even my feelings and some stories that I’ve heard. Anyway, let’s figure it out!