Luminoid's Site

OK Computer

Reference commands for common Git situations.

Amend a commit

1
git commit --amend

Git pull till a particular commit

1
2
git fetch remote <branch_name>
git merge <commit_hash>

Your branch and ‘origin/master’ have diverged

Use origin/main if your default branch is main.

1
2
git fetch origin
git reset --hard origin/master # or origin/main

Remove all unreachable objects

Warning

This command will remove all stashed objects.

1
2
git reflog expire --expire-unreachable=now --all
git gc --prune=now
Read more »

Quick reference for Node.js version management and usage.

Usage

Start REPL.

1
node

Check currently supported ES6 features.

1
node --v8-options | grep harmony

Version Management

n

Installation

1
brew install n

Usage

1
2
3
n               # Display downloaded Node.js versions and install selection
sudo n latest # Install the latest Node.js release (downloading if necessary)
sudo n lts # Install the latest LTS Node.js release (downloading if necessary)

Package Manager

npm-check-updates

Shortcuts and commands for daily Mac use.

Upgrading and Checking Packages

1
2
3
4
5
6
7
8
$ bubu          # brew update && brew outdated && brew upgrade && brew cleanup
$ brew doctor

$ ncu -g
$ npm doctor

$ gem update
$ gem cleanup

Keyboard Shortcuts

Mac keyboard shortcuts

Common Shortcuts

Command-,: Open preferences for the front app
Shift-Command-T: Reopen the last closed tab
Shift-Command-[: Switch to previous tab
Shift-Command-]: Switch to next tab

Finder Shortcuts

Shift-Command-.: Toggle show hidden files

System Shortcuts

Option–Volume Up / Option–Volume Down: Open Sound preferences.
Option–Shift–Volume Up / Option–Shift–Volume Down: Adjust the sound volume in smaller steps.
Option–Brightness Up / Option–Brightness Down: Open Displays preferences.
Option–Shift–Brightness Up / Option–Shift–Brightness Down: Adjust the display brightness in smaller steps.
Control-Command-Q: Immediately lock your screen.

Document Shortcuts

Option–Left: Move the insertion point to the beginning of the previous word
Option–Right: Move the insertion point to the end of the next word
Option-Delete: Delete the word to the left of the insertion point
Control-A: Move to the beginning of the line or paragraph
Control-E: Move to the end of the line or paragraph

Implementations of the nth Fibonacci number in various programming languages.

C (1972)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include <stdio.h>
#include <stdlib.h>

int fib(int n) {
if(n <= 1) {
return n;
}

int a = 0;
int b = 1;

for(int i = 2; i <= n; i++) {
int c = a + b;
a = b;
b = c;
}
return b;
}

int main(int argc, char *argv[]) {
int n = atoi(argv[1]);
printf("fib(%d) = %d\n", n, fib(n));
return 0;
}
1
2
3
$ gcc fibonacci.c
$ ./a.out 1
fib(1) = 1
Read more »

Short reference for my Hexo/NexT workflow.

Official Site: https://hexo.io/
Version: 8.1.0

Workflow

With Git deployment

1
2
3
4
5
6
7
$ hexo new "My New Article"
# Edit source/_posts/My-New-Article.md
$ hexo clean
$ hexo generate
$ git add -A
$ git commit -m <msg>
$ git push

Maintenance

Update outdated npm packages. With npm-check-updates, run the following under the blog directory (./):

1
2
$ ncu -u
$ npm install

Configuration

Site config is stored in ./_config.yml

Read more »
0%