πŸ‘©πŸΌβ€πŸ’» tech-note

How to update any cells in MySQL?

I forgot about it so, so frequently that I decided to jot down the syntax. For example, to make all the posts unpublished in Ghost: update

I forgot about it so, so frequently that I decided to jot down the syntax.

For example, to make all the posts unpublished in Ghost:

update posts set status = "draft";

Or if you want to add the condition:

update posts set status = "draft" where author_id = "1";

Source: https://stackoverflow.com/a/3024567/2360798

-->
1 min read
πŸ‘©πŸΌβ€πŸ’» tech-note

How to check if an element is in the table in Lua?

This is NOT supported in Lua. So you must write your own function manually. In Python, you can write the following: if i in yourList: In L

This is NOT supported in Lua. So you must write your own function manually.

In Python, you can write the following:

if i in yourList:

In Lua, write the following:

local function has_value(tab, val)
    for index, value in ipairs(tab) do
        if value == val then
            return true
        end
    end

    return false
end

And then, use the function to

-->
1 min read
πŸ‘©πŸΌβ€πŸ’» tech-note

How to change the default browser on Jupyter Notebook?

Open up your Jupyter config file. The default is on ~/.jupyter/ but I put it on Dropbox. Now, edit the config file to reflect the following

Open up your Jupyter config file. The default is on ~/.jupyter/ but I put it on Dropbox.

Now, edit the config file to reflect the following settings (on macOS). If you don't have a config file, you must create it first (jupyter notebook --generate-config).

c.NotebookApp.browser = u'open -a /Applications/Google\ Chrome\ Canary.app %s'

Now, try jupyter notebook and

-->
1 min read
πŸ‘©πŸΌβ€πŸ’» tech-note

How to use a config file in R and Python?

The easiest solution The easiest solution would be just create a config.R (or something like that), and read the file in R. For example her

The easiest solution

The easiest solution would be just create a config.R (or something like that), and read the file in R.

For example here is config.R (replace <- with = in Python):

#file: config.R
user <- "root"
password <- "root"
host <- "localhost"
dbname <- "

-->
1 min read
πŸ‘©πŸΌβ€πŸ’» tech-note

How to access an internal file of a script run by a cron job?

I have failed to access a file that should be accessed in a script run by a cron job. The problem came from the fact that the cron job coul

I have failed to access a file that should be accessed in a script run by a cron job.

The problem came from the fact that the cron job could not access the internal file due to a different path.

So you must make sure to write the file in a program in an absolute path. This is simple in

-->
1 min read
πŸ‘©πŸΌβ€πŸ’» tech-note

How to untrack a directory in Git?

The process is pretty simple: git rm -r --cached directory_to_untrack Note that I was forced to untrack the directory as it had a .git/ wit

The process is pretty simple:

git rm -r --cached directory_to_untrack

Note that I was forced to untrack the directory as it had a .git/ within it and thus was considered a submodule. So in my case I first deleted the .git/ before untracking the directory.


Source: http://stackoverflow.com/a/30360954/2360798

-->
1 min read
πŸ‘©πŸΌβ€πŸ’» tech-note

How to upgrade Ghost?

NOTE: This post is about the prior version of Ghost (0.x). In version 1.0 or later, the Ghost official team supports a tool to upgrade your

NOTE: This post is about the prior version of Ghost (0.x). In version 1.0 or later, the Ghost official team supports a tool to upgrade your app via ghost command line tool.


Take the following steps, which is a short summary of the linked tutorial:

  • Download the latest Ghost and extract it

  • Delete core/, index.js, package.json

-->
1 min read
πŸ‘©πŸΌβ€πŸ’» tech-note

How to create a custom static page in Ghost?

It is simple. Take the following steps: Add a custom page from an admin page, where you enable the "custom page" checklist. Crea

It is simple. Take the following steps:

  • Add a custom page from an admin page, where you enable the "custom page" checklist.

  • Create a page-{customURL}.hbs in the root of your theme directory. The customURL must be the same as the root URL you want. If you show the page at yourblog.com/about, it must be

-->
1 min read
πŸ‘©πŸΌβ€πŸ’» tech-note

How to replace a string in a file using sed?

According to the answer over Stack Overflow, you must create a temporary file and mv it to the original file. For example: sed -e 'script

According to the answer over Stack Overflow, you must create a temporary file and mv it to the original file.

For example:

sed -e 'script script' index.html > index.html.tmp && mv index.html.tmp index.html

This is pretty daunting... I wish there were any alternatives...

-->
1 min read
πŸ‘©πŸΌβ€πŸ’» tech-note

How to add a custom route to your Ghost blog?

First, create a custom route directory to your root. Originally I added my custom route files under core/server/, but since it is going to b

First, create a custom route directory to your root. Originally I added my custom route files under core/server/, but since it is going to be overwritten by updates on Ghost, it might be preferrable to make them agnostic about the core directory altogether.

Then, define your own custom routes in whatever way you want. Add routes, controllers, or middlewares,

-->
1 min read
πŸ‘©πŸΌβ€πŸ’» tech-note

What is `module.exports` in node.js?

According to the answer over Stack Overflow: module.exports is the object that's actually returned as the result of a require call. Also,

According to the answer over Stack Overflow:

module.exports is the object that's actually returned as the result of a require call.

Also, the exports variable is available on which you can add whatever variables you want to export, such as:

var thunderbolt = function() { ... };
exports.thunderbolt = thunderbolt;

, which is accessable from the exported environment:

var pikachu = require("pikachu"

-->
1 min read
πŸ‘©πŸΌβ€πŸ’» tech-note

How to drop all tables in MySQL?

It is simple enough if you don't care about permissions, etc..., which is true of my local test database. mysql -uUSER -p -e "drop dat

It is simple enough if you don't care about permissions, etc..., which is true of my local test database.

mysql -uUSER -p -e "drop database YOUR_DB;"
mysql -uUSER -p -e "create database YOUR_DB;"
mysql -uUSER -p YOUR_DB < SQL_FILE.sql

And now you get a refreshed DB.


If you don't mind getting

-->
1 min read
πŸ‘©πŸΌβ€πŸ’» tech-note

Your cron job is not running? Check out the followings!

Your cron scheduler should be working as long as you put your files to /etc/cron.hourly or something. If not, the problem might be found som

Your cron scheduler should be working as long as you put your files to /etc/cron.hourly or something. If not, the problem might be found somewhere like the following:

  • Is the permission correct? It should be 755 or something like that.

  • Does your filename use only upper and lower cases, hyphens, and underscores? The cron is pretty pedantic about

-->
1 min read
πŸ‘©πŸΌβ€πŸ’» tech-note

How to set up SSL on namecheap?

These kind of things are so boring to learn and implement, yet are required to execute only once. So I would like to share my experience wit

These kind of things are so boring to learn and implement, yet are required to execute only once. So I would like to share my experience with it.

My environment is the following:

  • node.js app
  • Google Compute Engine
  • Nginx
  • Domain purchased on namecheap with PositiveSSL

First, you have to run the following set of commands to generate private key

-->
1 min read
πŸ‘©πŸΌβ€πŸ’» tech-note

Don't append `.sh` extension to your cron script

Having created a .sh script you want to run periodically, and put it in /etc/cron.daily/, you still find it not working😰? The potential pro

Having created a .sh script you want to run periodically, and put it in /etc/cron.daily/, you still find it not working😰? The potential problem might come from the file extension.

You should NOT append the .sh extensionπŸ™…πŸ» So just remove it and test it again with run-parts --test /etc/cron.daily.

Or more correctly, your script name should

-->
1 min read
πŸ‘©πŸΌβ€πŸ’» tech-note

Add Google Analytics and Adsense into your Ghost blog

The answer is simple enough to add your script to theme filesπŸ™Š Google Adsense Create an ad partial like ad-banner.hbs template and copy/pa

The answer is simple enough to add your script to theme filesπŸ™Š

Google Adsense
  1. Create an ad partial like ad-banner.hbs template and copy/paste your ad script to the file.

  2. Edit the relevant files (e.g. index.hbs, post.hbs, etc...) to insert the ad partials.

Google Analytics

To add Google Analytics, not only you can insert the script

-->
1 min read