25. August 2018

How to setup html generated site into your hosting

This morning I finally had time to configure my new hosting in a2hosting.com. Did some configs on ssh access, git access, and etc… But what I really wanted to share is, how would you point your projectname/public folder to your public_html. We’re going to do this by linking public folder to public_html

SSH into your server.

ssh -p 22 username@domain.com

Folder structure should be something like this.

public_ftp/
public_html
www

In current directory, clone your project.

git clone https://yourname@bitbucket.org/yourname/blog.git blog
blog
public_ftp/
public_html
www

!Important: If you have something on public_html I would recommend to backing it up. Becase the next step that we will do is make sure that public_html is deleted.

mv ~/public_html ~/public_html_backup
ln -s ~/blog/public ~/public_html

That’s it! check your site www.yourdomain.com and to make sure everything works. If things are not working great, delete public_html and do the last step ln -s ~/blog/public ~/public_html. chow!—

11. August 2018

Mongoose delete/pull ObjectID within an array

Slots

I wanted to delete an ID inside slots array, It took me a while to find the answer, hopefully this small snippet can help you.

// Delete item in users
User.findOneAndUpdate(
  { '_id': userID, 'username': username },
  { $pull: { slots: cardID }}, function(err, data) {
    if (err) res.render('error', { 
      message: 'Sorry failed to delete card id in users',
      error: { status: err, stacks: 'failed to delete card id in users' }
    });
  }
)

I’m using Express 4, Mongoose 5.2.7 and mongodb hosted in mlab.

24. June 2018

React-Static and Firebase

This is what’s keeping me busy since last week. I feel more comfortable with react-static than gatsby. I think I will be using this in my make others that doesn’t require a server side.