How to Work with GitHub and Multiple Accounts

Step 1 – Create a New SSH Key

We need to generate a unique SSH key for our second GitHub account.

ssh-keygen -t rsa -C "your-email-address"

Be careful that you don’t over-write your existing key for your personal account. Instead, when prompted, save the file as id_rsa_COMPANY. In my case, I’ve saved the file to ~/.ssh/id_rsa_work.

Step 2 – Attach the New Key

Next, login to your second GitHub account, browse to “Account Overview” and attach the new key, within the “SSH Public Keys” section. To retrieve the value of the key that you just created, return to the Terminal and type: vim ~/.ssh/id_rsa_COMPANY.pub.

Copy the entire string that is displayed, and paste this into the GitHub textarea. Feel free to give it any title you wish.

Next, because we saved our key with a unique name, we need to tell SSH about it. Within the Terminal, type: ssh-add ~/.ssh/id_rsa_COMPANY. If successful, you’ll see a response of Identity Added.

Step 3 – Create a Config File

We’ve done the bulk of the workload; but now we need a way to specify when we wish to push to our personal account, and when we should instead push to our company account. To do so, let’s create a config file.

touch ~/.ssh/config vim config

If you’re not comfortable with Vim, feel free to open it within any editor of your choice. Paste in the following snippet.

Default GitHub


	Host github.com
	  HostName github.com
	  User git
	  IdentityFile ~/.ssh/id_rsa

This is the default setup for pushing to our personal GitHub account. Notice that we’re able to attach an identity file to the host. Let’s add another one for the company account. Directly below the code above, add:

	Host github-COMPANY
	  HostName github.com
	  User git
	  IdentityFile ~/.ssh/id_rsa_COMPANY

This time, rather than setting the host to github.com, we’ve named it as github-COMPANY. The difference is that we’re now attaching the new identity file that we created previously: id_rsa_COMPANY. Save the page and exit!

Step 4 – Try it Out

It’s time to see if our efforts were successful. Create a test directory, initialize git, and create your first commit.

	git init
	git commit -am "first commit'

Login to your company account, create a new repository, give it a name of “Test,” and then return to the Terminal and push your git repo to GitHub.

	git remote add origin git@github-COMPANY:Company/testing.git
	git push origin master

Note that, this time, rather than pushing to git@github.com, we’re using the custom host that we create in the config file: git@github-COMPANY.

Return to GitHub, and you should now see your repository. Remember:

When pushing to your personal account, proceed as you always have. For your company account, make sure that you use git!github-COMPANY as the host.

Interfacing & displaying a custom graphic on an 0.96″ I2C OLED with Arduino

In case you want to display your own custom graphic, you will need to convert it into a suitable format, so that it can be used by the microcontroller. For this purpose i used an open source software called Gimp .

I guess this pretty much sums up all the parts. Now its time to get your hands dirty!

Requirements

  • Arduino UNO R3
  • 0.96″ 128×64 I2C OLED display
  • jumper wires
  • A Computer with a working Internet connection

Steps

  1.  First let us get the hardware connections right, connect our OLED to Arduino. Its pretty simple, and for your reference i have attached all the details below. Just follow the breadcrumbs!
    Pin connectionsArduino pinOLED pin5VVCCGNDGNDSDASDASCLSCLBreadboard LayoutSchematic diagram
  2. Now for programming any Arduino based development board, we need the Arduino IDE, which can be downloaded freely and installed from the Arduino website.
  3. Once the Arduino IDE is up and running  we need to install the U8glib2 library. For this we need to access the Library Manager from Sketch > Include Library > Manage Libraries. Then search for u8g2 in the search entry and click install.
  4. To make sure that the OLED is properly connected and is working, load the “GraphicsTest” sketch from File > Examples > U8g2 > page_buffer > GraphicsTest.Note: To use the U8g2 library, you need to enable one of the constructors for initializing the u8g2 class object, from the commented constructor list as shown in the image below. This constructor initializes the u8g2 object for the particular hardware configuration we are using. In our case since we are using the hardware I2C bus of Arduino Uno and our OLED has a 128×64 resolution and SSD1306 CMOS driver ,so you need to uncomment this specific line as shown in the picture.
    1U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
    A complete reference of all the available constructors can be found  here
  5. Selecting and converting an image in Gimp

    5.1.   Now for loading custom graphics, you need to first select your image and convert it to X BitMap format, which gives the files a .xbm extension. As our resolution is only 128×64 we need to go for an image with very less details. For my purpose and initial tests i choose this Iron Man helmet. Cool Huh!
    5.2.   Next load this image in Gimp and set color map to black and white 1-bit palette, form Image > Mode > Indexed > Use black and white (1-bit)palette > Convert.5.3.  Now we crop the image using Rectangular select tool to tightly fit inside a box, and then Image > Crop to selection.5.4.   Now  go to Image > Scale Image, and in the Scale Image dialog box, first make sure that the aspect ratio is locked and dimension is set in pixels as shown below.
    Now change the height to 64 px and click inside the width input box, it will automatically change to match the aspect ratio, and then click Scale.5.5.   You may need to edit the image further to add/remove features that were lost in scaling.
    5.6.   Now  go to File > Export As > save it as ironman.xbm 
  6.  Writing and uploading the code to Arduino

    6.1.  Now open the Arduino IDE and start a new project and name it as IronMan.6.2.  Copy the following code into your IronMan Sketch.123456789101112131415161718192021222324252627282930313233#include<Arduino.h>#include<U8g2lib.h> #ifdef U8X8_HAVE_HW_SPI#include<SPI.h>#endif#ifdef U8X8_HAVE_HW_I2C#include<Wire.h>#endif U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Copy the contents of your .xbm file below void draw(void) {// graphic commands to redraw the complete screen should be placed hereu8g2.drawXBMP(x,y,width,height,btimap);} void setup(void) {u8g2.begin();} void loop(void) {// picture loopu8g2.firstPage();do {draw();} while( u8g2.nextPage() ); // rebuild the picture after some delaydelay(1000);}6.3.   Now open your ironman.xbm file with a text editor and copy everything in it to your IronMan Sketch under the following line.1// Copy the contents of your .xbm file below6.4.   After copying the code make the following changes in  your IronMan Sketch.1u8g2.drawXBMP(x,y,width,height,btimap);find the above line and replace x with 42, y with 0width with ironman_widthheight with ironman_height and bitmap with ironman_bits as shown below.1u8g2.drawXBMP( 42, 0, ironman_width, ironman_height, ironman_bits)next find and change the line below1static unsigned char ironman_bits[]to1static const unsigned char ironman_bits[] PROGMEMThe complete code will look like this.1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768#include<Arduino.h>#include<U8g2lib.h> #ifdef U8X8_HAVE_HW_SPI#include<SPI.h>#endif#ifdef U8X8_HAVE_HW_I2C#include<Wire.h>#endif U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); // Copy the contents of your .xbm file below#define ironman_width 44#define ironman_height 64static const unsigned char ironman_bits[] PROGMEM = {0x00, 0x00, 0xfc, 0x03, 0x00, 0x00, 0x00, 0xc0, 0xff, 0x3f, 0x00, 0x00,0x00, 0xf8, 0xff, 0xff, 0x01, 0x00, 0x00, 0x86, 0xff, 0x1f, 0x06, 0x00,0x80, 0x81, 0xff, 0x1f, 0x18, 0x00, 0xc0, 0x80, 0xff, 0x1f, 0x30, 0x00,0x20, 0x80, 0xff, 0x1f, 0xc0, 0x00, 0x10, 0x00, 0xff, 0x0f, 0x80, 0x01,0x08, 0x00, 0xff, 0x0f, 0x00, 0x01, 0x08, 0x00, 0xff, 0x0f, 0x00, 0x02,0x08, 0x00, 0xff, 0x0f, 0x00, 0x02, 0x08, 0x00, 0xfe, 0x07, 0x00, 0x02,0x08, 0x00, 0xfe, 0x07, 0x00, 0x02, 0x08, 0x00, 0xfe, 0x07, 0x00, 0x02,0x08, 0x00, 0x00, 0x00, 0x00, 0x06, 0x08, 0x00, 0x00, 0x00, 0x00, 0x06,0x08, 0x00, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x06,0x0c, 0x00, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x06,0x0c, 0x00, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x06,0x0c, 0x00, 0x00, 0x00, 0x00, 0x06, 0x0c, 0x00, 0x00, 0x00, 0x00, 0x06,0x06, 0x00, 0x00, 0x00, 0x00, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x06,0x06, 0x00, 0x00, 0x00, 0x00, 0x0e, 0xc6, 0x07, 0x00, 0x00, 0x7c, 0x0e,0xe6, 0xff, 0xff, 0xff, 0xff, 0x0e, 0xe6, 0xff, 0x03, 0xf8, 0xff, 0x0c,0x02, 0x3f, 0x00, 0x80, 0x1f, 0x0c, 0x02, 0x00, 0x00, 0x00, 0x00, 0x0c,0x03, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x03, 0x00, 0x00, 0x00, 0x00, 0x0c,0x03, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x03, 0x00, 0x00, 0x00, 0x00, 0x0c,0x03, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x07, 0x00, 0x00, 0x00, 0x00, 0x06,0x07, 0x00, 0x00, 0x00, 0x00, 0x06, 0x16, 0x00, 0x00, 0x00, 0x00, 0x06,0x2e, 0x00, 0x00, 0x00, 0x80, 0x07, 0x6e, 0x00, 0x00, 0x00, 0x40, 0x07,0x6e, 0x00, 0x00, 0x00, 0x60, 0x07, 0xde, 0x00, 0x00, 0x00, 0xb0, 0x07,0xde, 0x00, 0x00, 0x00, 0xb0, 0x07, 0x9c, 0x01, 0x00, 0x00, 0xd8, 0x03,0xbc, 0x01, 0x00, 0x00, 0xf8, 0x03, 0x3c, 0x01, 0x00, 0x00, 0xe8, 0x03,0x7c, 0x03, 0x00, 0x00, 0xf4, 0x03, 0xfc, 0x02, 0x00, 0x00, 0xf4, 0x03,0xfc, 0xc2, 0xff, 0x1f, 0xfa, 0x03, 0xf8, 0x25, 0xff, 0x27, 0xfa, 0x01,0xf8, 0x38, 0x00, 0x60, 0xf9, 0x01, 0xf8, 0x10, 0x00, 0xc0, 0xf8, 0x01,0xf0, 0x00, 0x00, 0x00, 0xf8, 0x01, 0xf0, 0x00, 0x00, 0x00, 0xf8, 0x01,0xf0, 0x00, 0xf8, 0x00, 0xf8, 0x00, 0xe0, 0xc1, 0xff, 0x0f, 0xf8, 0x00,0xc0, 0xe3, 0xff, 0x1f, 0x7c, 0x00, 0x80, 0xff, 0xff, 0x7f, 0x3e, 0x00,0x00, 0xff, 0xff, 0x7f, 0x0f, 0x00, 0x00, 0xf6, 0x00, 0xfe, 0x07, 0x00,0x00, 0x3c, 0x00, 0xb0, 0x01, 0x00, 0x00, 0x08, 0x00, 0x40, 0x00, 0x00 }; void draw(void) {// graphic commands to redraw the complete screen should be placed here  u8g2.drawXBMP( 42, 0, ironman_width, ironman_height, ironman_bits);} void setup(void) {u8g2.begin();} void loop(void) {// picture loopu8g2.firstPage();do {draw();} while( u8g2.nextPage() ); // rebuild the picture after some delaydelay(1000);}
  7. Finally select the board as Genuino Uno/Arduino under Tools > Boards and select the appropriate com port under Tools > Port, and click Upload.
    Enjoy !!!
    All the project files can be found here

新航頭等艙 SIN-HKG 飛行紀錄

航線 : SIN-HKG 班機 : SQ2  機型 : B777-300ER(B77W)   飛行時間 : 3h:25m

去年趕著在 2017/03/01 花旗兌換新航哩程由 2 點換一哩調整成 3 點換一哩前,把手中的花旗信用卡點數換成新加坡航空哩程,換新航的主要目的就是要體驗新航的頭等艙以及使用它的頭等艙貴賓室。

(Updated: 自2019/01/27起, SQ 哩程兌換率即將再度變成  5:1,  宣告花旗紅利卡的結束, 還好早就換光了).

Read more

《思我故鄉》秦孝儀 詞 黃友棣 曲

《思我故鄉》秦孝儀 詞 黃友棣 曲

啊~~ 故鄉!啊~~ 故鄉!
那黃埔的潮汐,
江漢的雨霽,
龍門石闕的奔放,
松花江魚吹細浪,
雅魯藏布江輕聲迴蕩;
還有那,我家近旁的小溪新漲。

啊~~ 啊~~
思我故鄉,何時暫忘!
思我故鄉,何時暫忘!

啊~~ 故鄉! 啊~~ 故鄉!
那洞庭的蘭佩,
西子湖的花舫;
二十四橋的月光。
滇池三百里芙蓉,
大明湖處處泉水垂楊;
還有那,我家近旁的荷塘新涼。

啊~~ 啊~~
思我故鄉,白露為霜。思我故鄉,白露為霜。

啊~~ 故鄉! 啊~~ 故鄉!
那陽朔的山水,
廬山的真面目;
峨嵋金頂的佛光。
石頭城龍蟠虎踞,
天山落照裏遍野牛羊;
還有那,我夢寐中的家山晴爽。

啊~~ 啊~~
思我故鄉,水遠山長。思我故鄉,水遠山長。

啊~~ 故鄉, 故鄉,故鄉,故鄉! 啊~~ 故鄉
那小橋流水,
那橫塘老屋,
失落了月色星光;
失落了炊煙笑語,
失落了人倫天性的安詳。
未失落的是 渴望王師底一樣心腸。

啊,故鄉!  啊,故鄉! 思我故鄉,神魂飛揚。
思我故鄉,神魂飛揚~~

天山明月(1970)               何志浩配詞      黃友棣編曲

天山明月(1970)               何志浩配詞      黃友棣編曲

  「天山明月」是用已有的新疆民歌編成的合唱曲。全曲結構是奏鳴曲體,【呈示部】有兩個主題。(採 何志浩 先生的詩為歌詞)

<主題一>天山明月罩南北,兩大盆地皎月色。維吾爾族、哈薩克通宵達旦舞不息,哈密瓜果大又甜,吃了一個還要添,要買就想買一籃,說道價錢十分廉。

  填入活潑的「沙里洪巴」曲調,並每句之後皆加插一句「新疆地方美呀美」。

<主題二>阿爾泰山真正好,天富金鐮是瑰寶。不管男女老和少,有吃有穿用不了。伊黎天馬矯如龍,日行千里快如風,縱橫馳逞英雄,騎兵善戰立大功。

  填入柔和的「喀什噶爾」曲調。

 【開展部】則用了自由幻想曲,選用「青春舞曲」為素材,配上 何志浩 先生的配詞,光陰似金,寸金難買寸光陰,青春可愛,愛苗長在少女的心,萬紫千紅春色滿園林,挽住青春翩翩起舞情意深,月來花弄影。花月結同心,挽住青春翩翩起舞情意深。「青春舞曲」反覆三次,第一次是女高音獨唱,第二次是男聲齊唱,第三次仍是男聲齊唱,但加入女聲以「啦啦」伴唱,伴唱曲調就用「青春舞曲」減時(值)進行,這是「減時卡農曲」。

 【再現部】:兩個主題同時進行結成一體,男聲唱第一主題,女聲唱第二主題,第二主題比原來時值加倍,這是「倍時進行」,利用倍時曲調與減時曲調來替曲調作伴以增加樂曲趣味。

【尾聲】則將「新疆地方美呀美」反覆開展,以明樂曲意旨。

 

New BWG VPS setup & installation

2018/04/25 發現 BandwagonHost 最便宜的入門級 10G VPS 又開始販賣了,一時手癢就再買了一組來玩玩,畢竟這種打折後只要 US$18.79 一年的價錢實在很便宜啊。

購買完,進入設定畫面後,發現原先一鍵安裝的 Shadowsocks 功能表不在了,只剩下 OpenVPN。

看來這個 Shadowsocks 的功能在某種考量下移除了,還好之前已經多次練習 Shadowsocks 的安裝,加上它所支援的 CentOS 6.0 內核是已經支援 bbr 的內核,所以省去了重新更換內核的手續,只要再自行加上 SS 功能即可。剛好拿這個來練練手。

[root@host ~]# uname -r

4.10.4-1.el6.elrepo.i686


檢查內核的確大於 4.09, 不必再重編。

[root@host ~]# lsmod | grep bbr
tcp_bbr                16384  26

tcp_bbr 已經啟動。

[root@host ~]# sysctl net.ipv4.tcp_available_congestion_control
net.ipv4.tcp_available_congestion_control = bbr cubic reno

接著用 Shadowsocks 一鍵安裝腳本安裝 SS

使用root用戶登錄,執行以下命令

wget --no-check-certificate -O shadowsocks-all.sh https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-all.sh
chmod +x shadowsocks-all.sh
./shadowsocks-all.sh 2>&1 | tee shadowsocks-all.log

安裝完成後,脚本提示如下

Congratulations, your_shadowsocks_version install completed!
Your Server IP        :your_server_ip
Your Server Port      :your_server_port
Your Password         :your_password
Your Encryption Method:your_encryption_method

Your QR Code: (For Shadowsocks Windows, OSX, Android and iOS clients)
 ss://your_encryption_method:your_password@your_server_ip:your_server_port
Your QR Code has been saved as a PNG file path:
 your_path.png

Welcome to visit:https://teddysun.com/486.html
Enjoy it!

至此就把一鍵安裝版 Shadowsocks 補完。

CHASE $500 銀行開戶獎勵

今年初看到 CHASE 又開放 $500 開戶獎勵的網路 Coupon,所以就上網路申請了一組,於是趁著今年 228 假期剛好去 CHASE 開戶,同時看看是否可以用到這個 COUPON.

開戶過程很順利,銀行行員很迅速地完成開戶各項設定,同時我也告知要使用開戶 Coupon 拿開戶紅利,行員幫忙輸入完 Coupon Code 並告知要拿到獎勵,必須在 10 天內存入 $15000 到 Savings 帳戶放 90 天可得 $200, 另外至少要完成一筆 $500 Direct Deposit 才能得到 $300 獎勵。

Read more

[科學上網] 在 Google Cloud platform 上架設 ShadowSocks(SS) + BBR

這篇文章是參考很多網路上他人的作法,再依照目前最新現狀 OS (2018/02) 設定後的測試結果整合而成,寫下來主要是讓自已留下記錄,以利日後參考。

準備動作

1. 註冊 Google Cloud Platform free trial

https://cloud.google.com/free/

2.建立 VPS. 在 GCP 的 Compute Engine 建立新的執行個體 instance

名稱:自定義,這是你的機器名稱

區域:請選 us-west-1 可設定美國 VPN, 可依需要決定自己的區域。

機器類型:由於做個人翻牆工具,可以只選「微型」就好,規格選越高錢扣越快

開機磁碟:請選作業系統 Ubuntu 17.10 LTS

防火牆:將「允許 HTTP 流量」和「允許 HTTPS 流量」皆設為開啟

Read more