natnebuer-blog
natnebuer-blog
think. build. oh no. start
13 posts
Just somewhere to store my lesson learnt and thoughts
Don't wanna be here? Send us removal request.
natnebuer-blog · 8 years ago
Text
Book Thoughts - I am Malala
Tumblr media
Just finished reading this book and make me wonder what the hell am I doing when I am sixteen years old. 
This young girl was fighting for her rights to have a education in her country, received death threats, shot in the head and survived, spoke in UN conference and won a nobel peace prize. Whutttt.. 
After reading this book, I come to realise how important is it for a role model in the household. She is who she is now is mainly due to her father who I am sure is a hero in her eyes.
Her father was the one who encouraged her to have an education and provided her the environment and school for her to learn. In fact the father started the all girls school in Swat where education for girls is uncommon. Her father’s vision was to make sure that all children regardless of gender have a right to education.
She is heavily influenced by her father to bring education to those who are oppressed. 
She just make all the problems we faced in our life so small and pathetic, she got shot and still said “ But they can only shoot a body. They cannot shoot my dreams, they cannot kill my beliefs, and they cannot stop my campaign to see every girl and boy in school. Millions of people prayed for me, and God spared me. I am still here for a reason, and it is to use my life to help people”. 
I am like SIMi SAI, at 16 years old she talks like what I see only movies where the main character was giving a speech just before some revolution.  
1 note · View note
natnebuer-blog · 8 years ago
Text
Book Notes : Who said elephant can't dance
Tumblr media
There was a point in time when IBM was very close from bankruptcy and how did a new CEO managed to turn it around. Overall an interesting book to read how did he managed to change the culture of such a massive company. 
Snippets from the book : 
His management philosophy :
1) Managed by principle, not procedure
2) The marketplace dictates everything we should do. ( This is in light of the PC revolution that IBM didn’t managed to get a foothold )
3) Move fast. If we make mistakes, let them be because we are too fast rather than too slow. 
4) Hierarchy means very little to me. Let’s put together in meetings the people who can help solve a problem, regardless of position. Reduce committees and meetings to minimum. No committee decision making. Let’s have lots of candid straightforward communications. 
You can have the most grand vision but if your company is not making money is going to be a problem.  “ Now, the number-one priority is to restore the company to profitability. I mean, if you’re going to have a vision for the company, the first frame of that vision bette be that you’re making money and that the company has got its economics correct. “
Communicating to employee about changes 
“ The sine qua non of any successful corporate transformation is public acknowledgement of the existence of a crisis. If employees do not believe a crisis exists, they will not make the sacrifices that are necessary to change. Nobody likes change. Whether you are a senior executive or an entry-level employee, change represents uncertainty and, potentially, pain. 
So there must be a crisis, and it is the job of the CEO to define and communicate that crisis, magnitide, its severity, and its impact. Just as important, the CEO must also be able to comminicate how to end the crisis - the new strategy, the new company model, the new culture. “ 
The importance of Marketing
“ I have always believed a successful company must have a customer/marketplace orientation and a strong marketing organization. That’s why my second step in creating a global enterprise had to be fix and focus IBM’s marketing efforts. “ 
The context is that IBM has hundreds of business unit around the globe and each of them runs like a separate entity. Each having their own budget, marketing team, PR team which leads to confusing messages and even branding logo. 
Moving forward, all marketing efforts was controlled by a single HQ department and they hired Ogilvy & Mather to lead the charge in changing the brand image. IBM is one of their oldest customer till now.
Ensuring that teamworks matters. 
“ The most unusual part of this plan involved the people who reported directly to me ( CEO )- the highest-level executives, including those who ran all our business units. From then on, their bonuses were to be based entirely on the company’s overall performance. In other words, the person running the Servies Group or the Hardware Group, had his or her bonus determined not by how well the unit performed, but by IBM’s consolidated results. 
Looking at the effects of new industry trend. 
“ Our bet was this : Over the next decade, customers would increasingly value companies that could provide solutions - solutions that integrated technology from various suppliers and, more important, integrated technology into the processes of an enterprise. We bet that the historical preoccupations with chips speeds, software verisions, proprietary systems, and the like would wane that the over time the information technology industry would be services-led, not technology-led. “ 
This is in the context when IBM used to be the only IT company that provides the entire stack from server hardware to OS/2 to applications. It is a one complete solution which was IBM biggest cash cow. 
The revolution of PCs enabled the enterprise to pick and choose what they would like to have in their server and build it at a fraction of what IBM is offering. 
The different options for hardware, OS and applications, companies will find it hard to integrate all these together hence he is betting that integration services  would be the key to the industry rather than who has the best technology. Technology will always change and new tech will replace the old. 
“ The second big bet we placed was that stand-alone computing would give way to networks. 
That may not sound like very big or risky bet today. But, again this was in the context of the 1994 time frame, well before the Internet became mainstream. The first rumblings of change were there. You could find certain industries, particularly telecommunications, that were buzzing about the “ information superhighway , a dazzling future to high-seed broadband connections to workplace, home and school. If this kind of “ wired world “ came about, it would change the way business and society functioned. “
I love how he can see the trends that is coming and predicate what would be the next needed services. Makes me think about what Microsoft CEO said that the next wave would be AI, Mixed Reality and Quantum Computing. What sorts of services of new industry will this spin up ?
The fear of cannibalising  
“ The major breakdown was on the product side, where IBM was consistently reluctant to take new discoveries and new technologies and commercialize them. Why? Because during the 1970s and 1980s that means cannibalizing existing IBM products, especially the mainframe or working with other industry suppliers to commercialise new technology. 
For example, UNIX was the underpinning of most of the relationship database applications in the 1980s. IBM developed relational databases but ours were not made available to the fastest-growing segment of the market. They remained proprietary to IBM systems.  “
Culture Change
“ In comparision, changing the atitide and hebavior of hundreds of thousands of people is very, very hard to accomplish. Business schools don’t teach you how to do it. You can’t lead the revolution from splendid isolation of corporate HQ. You can’t simply give a couple of speeches or write a new credo for the company and declare that the new culture has taken hold. You can’t mandate it, you can’t engineer it. 
Whay you can do is create the conditions for transformation. You can provide incentives. You can define the marketplace realities and goals. But then you have to trust. In fact, the end, management doesn’t change culture. Management invites the workforce itself to change the culture. “
“ People don’t do what you expect but what you inspect, I needed to create a way to measure results “
“ I believe effective execution is built on three atrributes of an institution : world-class processes, strategic clarity, and a high performance culture. “
Leadership 
“ Personal leadership is about visibility - with all members of the institution. Great CEOs roll up their sleeves and tackle problems personally. They don’t hide behind staff. They never simply preside over the work of others. They are visible every with customers, suppliers and business partners “ 
1 note · View note
natnebuer-blog · 8 years ago
Text
Reading a book is like diving into someone's mind. To know the thought process that lead into the decision.
0 notes
natnebuer-blog · 8 years ago
Text
Book Notes : Mindset
Tumblr media
This book describes that everyone of us has a mixture of 2 mindset. Growth and Fixed mindset. 
So what is fixed and growth mindset ? 
Tumblr media
And yes, when we all read this we all think that we have Growth Mindset immediately. Unfortunately we human are not binary where is either 1s or 0s, we are always somewhere in between. 
Fixed mindset can be triggered when we are placed in situation such as failures, criticism, deadlines or disagreements. Everyone of us are unique hence the triggers varies across. The key is to recognise these triggers. 
The book explain these mindset in different context : 
Abilities 
When people think of ability, they often think that people are either born with abilities or not. When you think of Thomas Edison or Darwin, it assumed that they work alone for years and finally their breakthrough. This is far from the truth, each of them had teams working with them for years to help create the work that they are famous for. 
Does it mean that everyone are created equal ? No, some children are prodigies and started with special abilities. Most often people believe that the “ gift “ is the ability itself. Yet what feeds is that constant, endless curiosity and challenge seeking. 
Is it ability or mindset ? Was it Mozart’s musical ability or the fact that he worked till his hands were deformed ? Was it Darwin’s scientific ability or the fact that he collected specimens nonstop from early childhood ? 
Is artistic ability a gift ? 
Most people view drawing as a innate ability but its not, there are learnable components of drawing. Drawing skills are actually seeing skills, the ability to perceive edges, spaces, relationships, light, shadows and the whole. 
Ability Levels, test scores and measure of achievement tell you where a student is, but they don’t tell you where a student could end up. 
Just because some people can do something with little or no training, it doesn’t mean that others can’t do it ( and sometimes do it even better ) with training. 
The Danger of Praise and Positive Labels
They did an experiment on 2 groups of children. They gave them a set of fairly difficult problems and most of them did pretty well. 
The first group, they were told “ Wow, you got eight right. That’s a really good score. You must be smart at this. “. This group were the “ You’re so talanted “ group. 
The other group, they were told “ Wow, you got eight right. That’s really good score. You must have worked really hard. “ They were made not to feel  that they had some special gift; they were praised for doing what it takes to succeed. 
The ability praise ( the first group ) pushed the students into a fixed mindset. When given a choice for a more challenging tasks that they could learn from, they rejected it. They didn’t want to do anything that could expose their flaws and call into question their talent. 
In contrast, when the students were praised for effort, 90 percent of them wanted the challenging new task that they could learn from. 
Business : Mindset and Leadership
Today corporate success requires “ the talent mind-set “. Just as there are naturals in sports, there are naturals in business too. This created the blueprint for the Enron culture and sowed the seeds of its demise. 
Enron created a culture that worshiped talent, thereby forcing its employees to look and act extraordinarily talented. Basically, it forced them into the fixed mindset. People with fixed mindset do not admit and correct their deficiencies. When people live in an environment that esteems them for their innate talent, they will lie and not admit wrong when their image is threatened. 
When Collins reports in his book, Good to Great. there was one absolute key that brought led the company into greatness. It was the leaders, they were self-effacing people who constantly asked questions and ad the ability to confront the most brutal answers--that is to look failure int he face, even their own, while maintaining faith that they would succeed in the end.
In a fixed mindset leader, they do not need great team just little helpers to carry out their brilliant ideas. They want to be the only big fish so that when they compare themselves to those around them, they can feel a cut above the rest. 
In a growth mindset leader, they help employees develop on their job. Seeing them as collaborators, as a team. 
If you are run a company, look at it from a mindset perspective. Think seriously about how to root out elitism and create a culture of self-examination, open communication and teamwork. Read Gerstner’s book Who Says Elephants Can’t Dance? 
Is your workplace promoting groupthink ? If so, the whole decision-making process is in trouble. Create ways to foster alternative views and constructive criticism. Assign people to play the devil’s advocate, take opposing viewpoints so you can see the holes in your position. Get people to wage debates that argue different sides of the issue. Have an anonymous suggestion box that employees must contribute to as part of the decision-making process. Remember, people can be independent thinkers and team players at the same time. Help them fill both roles. 
Its getting late, maybe I will continue writing tomorrow. 
0 notes
natnebuer-blog · 8 years ago
Text
Hit Refresh notes
Tumblr media
Ever since Satya Nadella took over Microsoft as the CEO, he mades some shocking changes. One of these changes was that Microsoft became a Platinum member for Linux Foundation, which his processor said that Linux was cancer. Another was that Satya took to the stage to present Office 365 on an iPhone, which was a direct competitor to Windows Phone. 
With all these shocking changes, it makes me wonder what was he thinking ? Obviously he wanted to shake things up, but what is his goal ? Bought the book last week and decided to read for myself. 
Notes :
In a world of technological innovation, its important to have empathy to use these innovation to improve people’s lives. Its is this unique human attribute that will drive innovation.
Even big companies can be Frenemies, partnering on some business verticals and competitor on others. Example Amazon and Microsoft compete vigorously in the cloud market but Bing powers the search experience on Amazon Fire tablets. 
For an organization to innovate, there needs the 3 Cs. Like the target, the outer rings is Concepts, second ring Capabilities, bullseye is Culture. 
The next 3 big shift in IT industry : Artificial Intelligence, Mixed Reality and Quantum Computing
The progression of AI ( Artificial Intelligence ) :
Bespoke - Only a handful of companies with privileged access to data, computing power and algorithms handcraft an AI product and make it available to the world. Only a few can make AI for the many. This is where most AI is today.
Democratised - Enabling every person and every organization to dream about and create amazing AI solutions that serve their specific needs. 
Learn to Learn - When computers learn to learn. Like humans, computers will go beyond mimicking what people do and will invent new, better solutions to problems. 
As the world becoming more digitalise, policies that govern privacy and freedom of speech becomes more apparent and important. He cited cases like Apple refused to build a master key to unlocked a murderer iPhone, or the govt requesting data that stored in data centers not in the US.
The trust equation : Empathy + Shared values + Safety and Reliability = Trust over time
To stay relevant in the future, our kids and their kids will need :
Empathy - Empathy which is is so difficult to replicate in machines, will be invaluable in the human-AU world.
Education - Develop knowledge and skills needed to implement new technologies on a large scale is a difficult social problem that will take a long time to resolve. The power loom was invented in 1810 but took 35 years to transform the clothing industry cause of shortages of trained mechanics. 
Creativity - Machines will enrich and augment our creativity, but the human drive to create will remain central. 
Judgement and accountability - We may be willing to accept a computer generated diagnosis or legal decision, but we will still expect a human to be ultimately accountable for the outcomes.  
0 notes
natnebuer-blog · 10 years ago
Text
Mistakes made.
Since 2010, I have been freelancing for small projects with workload and deadline that only require one developer to work on it. The reason why I only took up small project is because I usually have a full-time job to complement it hence only lunch time and after work will I be able to code these projects. 
Much of these projects are introduced by my friends whom I have worked with them before hence its easy for ‘client’ and me to understand each other. These projects never stop even when I was travelling and I don’t wish it to stop since I love creating new applications. 
Until recently when my friends and I took a big project which require minimum of 3 developers which make me realized that I been coding ‘selfishly’. 
4 things I realized when working in a team :
1) Build re-useable code.
When I was working on small projects, I usually use someone’s else library or copy and pasting codes since its not going to be used often. While working on this big project, I realized that it will be selfish to copy and paste since the function I am doing is similar to someone else functions. Hence I spent significant amount of time to build a library that caters for different use cases but yet similar. 
2) Write readable codes. 
Obviously I don’t named my variable ‘a’,’b’,’c’. For example in a function for permission checking :
def check_permission( roles )      # check for roles and return result end
Instead of doing this, I created it by using ruby ‘method_missing’ to check for permission. So now we check for permission by doing : 
user.is_admin? or user.is_worker? or user.is_staff?
Doing this makes the code so much more readable and partly I did this is also because on our team, we have one member that is new to ruby. Hence its easier to build a function that he can use easily.
3) Git is can be your enemy when all of us are noobs.
Because I have been working on solo projects, Git is basically a place for me to put my source code in the event my computer stops working. So when we are a team, we had to work things out because codes gone missing. I spent some time reading up on Git and the proper use of it so that I won’t mess up or even worst overwrite someone’s code. 
4) Continuous Integration is your friend. 
For this project, I took the chance to learn a little on chef to deploy a simple ubuntu with passenger to run our staging server. We also use Jenkins to run rspec, code analysis, code coverage and deploy to our staging server automatically. Once that is set up with slack, everyone can focus on coding the application and leave the deployment to Jenkins. It also tells to make sure our application is properly covered with tests.
Finally looking back, I wish I had start my career working under a web development company and more importantly have a mentor that can guide and teach me the ‘ industry standard ‘ of things. 
Everyone tells me you can learn from books, or read someone else source code to understand it. Yes they are right but having a mentor will speed up the process. Again something I strongly believe, “ train with the best to become the best “. 
0 notes
natnebuer-blog · 10 years ago
Text
Flash Message Weird
From what I always understand, Flash message only exist until the next action, meaning it survive one redirect. 
At least that is what I thought until I found out that if you set the flash message and not call it in any view, it will exist until the flash is called. Basically flash message survive 2 calls of flash method. One for setting and another for displaying. It doesn’t matter if has been n times of GET or POST. 
class Request < Rack::Request    # Access the contents of the flash. Use <tt>flash["notice"]</tt> to    # read a notice you put there or <tt>flash["notice"] = "hello"</tt>    # to put a new one.    def flash      @env[Flash::KEY] ||= Flash::FlashHash.from_session_value(session["flash"])    end  end
Only if you called flash method that ENV will get the key, so that the middleware lay can detect the key and display/discard the message accordingly. 
   def call(env)      @app.call(env)    ensure      session    = Request::Session.find(env) || {}      flash_hash = env[KEY]
     if flash_hash && (flash_hash.present? || session.key?('flash'))                session["flash"] = flash_hash.to_session_value        env[KEY] = flash_hash.dup      end
     if (!session.respond_to?(:loaded?) || session.loaded?) && # (reset_session uses {}, which doesn't implement #loaded?)        session.key?('flash') && session['flash'].nil?        session.delete('flash')      end    end
Note that env[KEY] will always be nil if the key is not set and flash_hash.to_session_value will not be called once flash_hash is nil. 
Beware if you get a flash message and not use it, it will appear the next time when you call it. 
0 notes
natnebuer-blog · 10 years ago
Text
Hardware in the future.
So recently HDB launched this new pilot project that uses motion sensors to monitor elderly that lives alone. This project resonate deeply with me because my grandmother fell in our house and no one was around to help her because it was during a workday. I feel useless as a programmer because what’s the point building system when I can’t even help my grandmother or even remotely preventing such thing from happening.
I realised that even with all these knowledge of knowing how to build a system online, it will never help my grandmother in anyway because she doesn’t even know how to use a computer. Think of it this way, at their age knowing how to use a computer is not as important as preventing injuries.
Recently I read this book called “ Zero to One “ and one of the question was “ What important truth do few people agree with you on? “ Most start ups are now are only targeting people age from 5 to 60, people who still can use a computer or knows how to use computer. The world is forgetting about the elderly. The world needs people to focus on how to prevent or help improve the quantity of life of elderly who are bed bound or preventing elderly from getting hurt.
The only way to truly impact someone’s life is through hardware because we can physically interact with it. There is also a rise in hardware trends with tools to quickly prototype although it has’t reached the stage like how we can prototype software that easily.
0 notes
natnebuer-blog · 10 years ago
Text
Zero to Rails Server - Part 2
Bundle install on server
Note when installing “ pg “ gem, you might come across an error saying “ Gem::Ext::BuildError: ERROR: Failed to build gem native extension “. If that is the case, make sure you install the the following libraries 
sudo apt-get install postgresql-client libpq5 libpq-dev
Setting up Capistrano 
Login into your repo and copy a public key from your server’s user into your repo management. 
This enable your user to perform operation on your repo like “ git clone “.
Start with : 
cap production deploy:check
Basically this check the configuration on your deploy.rb file in your application with the structure in your remote server. An error case is when you have a linked file like your “ database.yml “ that is not in your remote server, this check will prompt you an error so that you are reminded to input the file. 
cap --dry-run production deploy
--dry-run means it will run through the process without actually writing into the remote server. 
If this its all green and you should go into 
cap production deploy
Setting up the server file
We need to disable the default Nginx configuration. Open the Nginx config file:
sudo nano /etc/nginx/sites-available/default
Find the lines:
listen 80 default_server;listen [::]:80 default_server ipv6only=on;
Comment them out, like this:
# listen 80 default_server;# listen [::]:80 default_server ipv6only=on;
Save the file.
Now, create an Nginx configuration file for our app:
sudo nano /etc/nginx/sites-available/testapp
Add the following server block. The settings are explained below.
server {  listen 80 default_server;  server_name xxxx.com www.xxxx.com;   passenger_enabled on;   root /home/rails/apps/xxx/current/public;   passenger_ruby /home/rails/.rvm/gems/ruby-2.1.5@xxxx/wrappers/ruby;; }
In this file, we enable listening on port 80, set your domain name, enable Passenger, and set the root to the public directory of our new project. The root line is the one you'll want to edit to match the upload location of your Rails app.
If you don't want to assign your domain to this app, you can skip the server_name line, or use your IP address.
To test our setup, we want to see the Rails Welcome aboard page. However, this works only if the application is started in the development environment. Passenger starts the application in the production environment by default, so we need to change this with the passenger_app_env option. If your app is ready for production you'll want to leave this setting out.
Save the file (CTRL+x, y, ENTER).
Create a symlink for it:
sudo ln -s /etc/nginx/sites-available/testapp /etc/nginx/sites-enabled/testapp
Restart Nginx:
sudo nginx -s reload
0 notes
natnebuer-blog · 10 years ago
Text
Zero to Rails Server - Part 1
Most of all the commands are taken from digital ocean article, basically I just consolidate them together so the next time I would easily reference it. 
The stack for a ubuntu rails server will be : 
Nginx
Passenger 
RVM
GIT
Capistrano 
Postgres
Clean Slate Server with Ubuntu 14.04 x32
Initial Setup of blank server.
Once you are logged in as root, we're prepared to add the new user account that we will use to log in from now on.
This example creates a new user called "demo", but you should replace it with a user name that you like:
adduser demo
You will be asked a few questions, starting with the account password.
Enter a strong password and, optionally, fill in any of the additional information if you would like. This is not required and you can just hit "ENTER" in any field you wish to skip.
Step 1 — Root Privileges
Now, we have a new user account with regular account privileges. However, we may sometimes need to do administrative tasks.
To avoid having to log out of our normal user and log back in as the root account, we can set up what is known as "super user" or root privileges for our normal account. This will allow our normal user to run commands with administrative privileges by putting the word sudo before each command.
To add these privileges to our new user, we need to add the new user to the "sudo" group. By default, on Ubuntu 14.04, users who belong to the "sudo" group are allowed to use the sudo command.
As root, run this command to add your new user to the sudo group (substitute the highlighted word with your new user):
gpasswd -a demo sudo
Now your user can run commands with super user privileges!
Step 2 — Add Public Key Authentication (Recommended)
The next step in securing your server is to set up public key authentication for your new user. Setting this up will increase the security of your server by requiring a private SSH key to log in.
Generate a Key Pair
If you do not already have an SSH key pair, which consists of a public and private key, you need to generate one. If you already have a key that you want to use, skip to the Copy the Public Key step.
To generate a new key pair, enter the following command at the terminal of your local machine (ie. your computer):
ssh-keygen
Assuming your local user is called "localuser", you will see output that looks like the following:
Generating public/private rsa key pair.Enter file in which to save the key (/Users/localuser/.ssh/id_rsa):
Hit return to accept this file name and path (or enter a new name).
Next, you will be prompted for a passphrase to secure the key with. You may either enter a passphrase or leave the passphrase blank.
Note: If you leave the passphrase blank, you will be able to use the private key for authentication without entering a passphrase. If you enter a passphrase, you will need both the private key and the passphrase to log in. Securing your keys with passphrases is more secure, but both methods have their uses and are more secure than basic password authentication.
This generates a private key, id_rsa, and a public key, id_rsa.pub, in the .ssh directory of thelocaluser's home directory. Remember that the private key should not be shared with anyone who should not have access to your servers!
Copy the Public Key
After generating an SSH key pair, you will want to copy your public key to your new server.
Assuming you generated an SSH key pair using the previous step, use the following command at the terminal of your local machine to print your public key (id_rsa.pub):
cat ~/.ssh/id_rsa.pub
This should print your public SSH key, which should look something like the following:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDBGTO0tsVejssuaYR5R3Y/i73SppJAhme1dH7W2c47d4gOqB4izP0+fRLfvbz/tnXFz4iOP/H6eCV05hqUhF+KYRxt9Y8tVMrpDZR2l75o6+xSbUOMu6xN+uVF0T9XzKcxmzTmnV7Na5up3QM3DoSRYX/EP3utr2+zAqpJIfKPLdA74w7g56oYWI9blpnpzxkEd3edVJOivUkpZ4JoenWManvIaSdMTJXMy3MtlQhva+j9CgguyVbUkdzK9KKEuah+pFZvaugtebsU+bllPTB0nlXGIJk98Ie9ZtxuY3nCKneB+KjKiXrAvXUPCI9mWkYS/1rggpFmu3HbXBnWSUdf [email protected]
Select the public key, and copy it to your clipboard.
Add Public Key to New Remote User
To enable the use of SSH key to authenticate as the new remote user, you must add the public key to a special file in the user's home directory.
On the server, as the root user, enter the following command to switch to the new user (substitute your own user name):
su - demo
Now you will be in your new user's home directory.
Create a new directory called .ssh and restrict its permissions with the following commands:
mkdir .ssh chmod 700 .ssh
Now open a file in .ssh called authorized_keys with a text editor. We will use nano to edit the file:
nano .ssh/authorized_keys
Now insert your public key (which should be in your clipboard) by pasting it into the editor.
Hit CTRL-X to exit the file, then Y to save the changes that you made, then ENTER to confirm the file name.
Now restrict the permissions of the authorized_keys file with this command:
chmod 600 .ssh/authorized_keys
Type this command once to return to the root user:
exit
Now you may SSH login as your new user, using the private key as authentication.
To read more about how key authentication works, read this tutorial: How To Configure SSH Key-Based Authentication on a Linux Server.
Step 3 — Configure SSH
Now that we have our new account, we can secure our server a little bit by modifying its SSH configuration (the program that allows us to log in remotely).
Begin by opening the configuration file with your text editor as root:
nano /etc/ssh/sshd_config
Change SSH Port (Optional)
The first option that you may want to change is the port that SSH runs on. Find the line that looks like this:
Port 22
If we change this number to something in between 1025 and 65536, the SSH service on our server will look for connections on a different port. This is sometimes helpful because unauthorized users sometimes try to break into servers by attacking SSH. If you change the location, they will need to complete the extra step of sniffing it out.
If you change this value, you will need to keep in mind that your server is running on the new port. For this guide, I'll change this to 4444 as a demonstration. This means that when I connect, I'll have to tell my SSH client to use this new, non-default port. We'll get to that later. For now, modify that value to your selection:
Port 4444
Restrict Root Login
Next, we need to find the line that looks like this:
PermitRootLogin yes
Here, we have the option to disable root login through SSH. This is generally a more secure setting since we can now access our server through our normal user account and escalate privileges when necessary.
You can modify this line to "no" like this if you want to disable root login:
PermitRootLogin no
Disabling remote root login is highly recommended on every server!
When you are finished making your changes, save and close the file using the method we went over earlier (CTRL-X, then Y, then ENTER).
Step 4 -- Reload SSH
Now that we have made our changes, we need to restart the SSH service so that it will use our new configuration.
Type this to restart SSH:
service ssh restart
Now, before we log out of the server, we should test our new configuration. We do not want to disconnect until we can confirm that new connections can be established successfully.
Open a new terminal window. In the new window, we need to begin a new connection to our server. This time, instead of using the root account, we want to use the new account that we created.
If you changed the port number that SSH is running on, you'll need to tell your client about the new port as well. You can do this by using the -p 4444 syntax, where "4444" is the port you configured.
Install RVM - ( Using RVM to install ruby )
Step One— Install Ruby with RVM
Before we do anything else, we should run a quick update to make sure that all of the packages we download to our VPS are up to date:
sudo apt-get update
Once that's done, we can start installing RVM, Ruby Version Manager. This is a great program that lets you use several versions of Ruby on one server; however, in this case, we will just use it to install the latest version of Ruby on the droplet.
If you do not have curl on your system, you can start by installing it:
sudo apt-get install curl
To install RVM, open terminal and type in this command:
\curl -L https://get.rvm.io | bash -s stable
After it is done installing, load RVM. You may first need to exit out of your shell session and start up a new one.
source ~/.rvm/scripts/rvm
In order to work, RVM has some of its own dependancies that need to be installed. To automatically install them:
rvm requirements
You may need to enter your root password to allow the installation of these dependencies.
On occasion the zlib package may be reported as missing. The RVM page describes the issue and the solution in greater detail here.
Step Two—Install Ruby
Once you are using RVM, installing Ruby is easy.
rvm install ruby
The latest ruby is now installed. However, since we accessed it through a program that has a variety of Ruby versions, we need to tell the system to use the version we just installed by default.
rvm use ruby --default
Install Postgres 
Ubuntu's default repositories contain Postgres packages, so we can install them without a hassle using theapt packaging system.
Since we haven't updated our local apt repository lately, let's do that now. We can then get the Postgres package and a "contrib" package that adds some additional utilities and functionality:
sudo apt-get updatesudo apt-get install postgresql postgresql-contrib
Now that our software is installed, we can go over how it works and how it may be different from similar database management systems you may have used.
Using PostgreSQL Roles and Databases
By default, Postgres uses a concept called "roles" to aid in authentication and authorization. These are, in some ways, similar to regular Unix-style accounts, but Postgres does not distinguish between users and groups and instead prefers the more flexible term "role".
Upon installation Postgres is set up to use "ident" authentication, meaning that it associates Postgres roles with a matching Unix/Linux system account. If a Postgres role exists, it can be signed in by logging into the associated Linux system account.
The installation procedure created a user account called postgres that is associated with the default Postgres role. In order to use Postgres, we'll need to log into that account. You can do that by typing:
sudo -i -u postgres
You will be asked for your normal user password and then will be given a shell prompt for the postgresuser.
You can get a Postgres prompt immediately by typing:
psql
You will be auto-logged in and will be able to interact with the database management system right away.
However, we're going to explain a little bit about how to use other roles and databases so that you have some flexibility as to which user and database you wish to work with.
Exit out of the PostgreSQL prompt by typing:
\q
You should now be back in the postgres Linux command prompt.
Create a New Role
From the postgres Linux account, you have the ability to log into the database system. However, we're also going to demonstrate how to create additional roles. The postgres Linux account, being associated with the Postgres administrative role, has access to some utilities to create users and databases.
We can create a new role of name db_user by typing:
createuser --interactive db_user
This basically is an interactive shell script that calls the correct Postgres commands to create a user to your specifications. It will only ask you two questions: the name of the role and whether it should be a superuser. You can get more control by passing some additional flags. Check out the options by looking at the man page:
man createuser
Change role password 
alter USER db_user WITH PASSWORD 'password'
Install Passenger and Ngnix
The preferred method to install Passenger in the past was using a generic installation via RubyGems (passenger-install-nginx-module).
However, you can now install Passenger on Ubuntu with the Advanced Packaging Tool (APT), which is what we'll be using. In this manner, the installation and — even more importantly — the update process for Passenger with Nginx, is really simple.
First, install a PGP key:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 561F9B9CAC40B2F7
Create an APT source file (you will need sudo privileges):
sudo nano /etc/apt/sources.list.d/passenger.list
And insert the following line in the file:
deb https://oss-binaries.phusionpassenger.com/apt/passenger trusty main
Press CTRL+x to exit, type y to save the file, and then press ENTER to confirm the file location.
Change the owner and permissions for this file:
sudo chown root: /etc/apt/sources.list.d/passenger.list sudo chmod 600 /etc/apt/sources.list.d/passenger.list
Update the APT cache:
sudo apt-get update
Finally, install Passenger with Nginx:
sudo apt-get install nginx-extras passenger
This step will overwrite our Ruby version to an older one. To resolve this, simply remove the incorrect Ruby location and create a new symlink to the correct Ruby binary file:
sudo rm /usr/bin/ruby sudo ln -s /usr/local/bin/ruby /usr/bin/ruby
Step Six — Set Up The Web Server
Open the Nginx configuration file:
sudo nano /etc/nginx/nginx.conf
Find the following lines, in the http block:
# passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini; # passenger_ruby /usr/bin/ruby;
Uncomment both of them. Update the path in the passenger_ruby line. They should look like this:
passenger_root /usr/lib/ruby/vendor_ruby/phusion_passenger/locations.ini; passenger_ruby /usr/local/bin/ruby;
Save and exit the file.
0 notes
natnebuer-blog · 10 years ago
Text
Bootstrap Fonts and Asset Digest
Tumblr media
Sometimes when you push to production, you realized that that the fonts from bootstrap will return a 404 and you wonder why in development, that didn't happen. 
It is because only in Production Environment Rails will compress and rename your assets ( .css, .js and more ) to include a MD5 digest into the filename for caching and cache busting purpose. In layman terms, its like a company has a shitty product and decide to rename their product to something new so that people will see this "rename" product as something new.
Call me old school but I still prefer writing css and not sass, just because sass still compile to css at the end of the day. 
So to solve this problem :
Tumblr media
1. Rename your css file to .css.erb ( so that rails can compile it and set the methods there )
2. Add <%= font_path () %> to all the font in the css file to make sure it produce the asset digest during compilation. 
3. On your machine, type the following : 
rake assets:precompile RAILS_ENV=production
Take notice if the assets .woff2 and all the other font files are compiled in it. It should look like this : 
Tumblr media
Once that is done, a folder in public/assets in Rails.root will have the files and when you run your server : 
rails s -e production 
You should able to see the files being served. 
CSS minify 
Because I don't use sass, I needed to include :
gem "yui-compressor"
into the gemfile. 
One last thing, when you run your own server, make sure you have java installed in the machine otherwise when you do a " cap production deploy ", it will fail when compiling the assets 
To install java in you server machine 
Then, check if Java is not already installed:
java - version
If it returns "The program java can be found in the following packages", Java hasn't been installed yet, so execute the following command:
sudo apt-get install default-jre
This will install the Java Runtime Environment (JRE). If you instead need the Java Development Kit (JDK), which is usually needed to compile Java applications (for example Apache Ant, Apache Maven, Eclipseand IntelliJ IDEA execute the following command:
sudo apt-get install default-jdk
That is everything that is needed to install Java.
0 notes
natnebuer-blog · 10 years ago
Text
initialize active record
Tumblr media
Because ActiveRecord has their own initialize method with their own parameters and overwriting your own is a bad idea. 
I was trying to do a .bulld on a has_many relationship but it kept giving me " ArgumentError: wrong number of arguments (1 for 0) " which doesn't make sense because the documentation stated that it takes in a parameter. After which I realized I am overwriting ActiveRecord initialize which is a bad idea. 
Solution
Rails provide a callback called " after_initialize ", which you can use to add in defaults value when doing a .new on a object. 
Tumblr media
0 notes
natnebuer-blog · 10 years ago
Text
Generalist / Specialist
The age old question of should you navigate your career in a horizontal ( jack of all trade, master of none ) or vertical ( master of something ). 
I have been going for interviews for the past week and it has not been what I expected. I been rejected thrice in one week and all by reputable companies, which make me wonder what am I doing wrong that I didn't make the mark. 
I believe that one can only grow if he is the lousiest employee in the company and that by working with people smarter and more experiences than him, can he grow to be better. The question I have is if you are the lousiest employee in the company, why should the company hire you in the first place ? 
The way I look towards programming is not how craftsmen looks at his work, where he will constantly improve in his craftsmanship. An good example will be like " Kaizen ", a Japanese continuous improvement philosophy. I look at programming as a means to an end. It's like a chair, I can make a chair that fulfil the requirement of someone sitting on it and that is it. As long as the chair doesn't break or uncomfortable to sit, I think my job is complete. 
In the start up mentality, the key is to build fast and iterate. I guess my attitude towards programming is somewhat the same. Used what existing libraries to fulfil the need and test it out, no necessarily for good code or test cases. Build first and see if there is traction. Do not reinvent the wheel. 
Maybe this is time to start looking at the wheel and see if it can be a better wheel. It is time to go back to the basic and spent more time in improving my craftsmanship. 
Time to be a specialist. 
0 notes