Skip to content

Instantly share code, notes, and snippets.

View gengmao's full-sized avatar

Mao Geng gengmao

  • Redwood City, California, US
  • X @gengmao
View GitHub Profile

Keybase proof

I hereby claim:

  • I am gengmao on github.
  • I am gengmao (https://keybase.io/gengmao) on keybase.
  • I have a public key whose fingerprint is 77F4 F9FE 5ECC 6588 5F93 905B 3773 6FFA 5A25 6A7C

To claim this, I am signing this object:

@gengmao
gengmao / gist:7c910b45af7a428c8563
Created October 21, 2015 22:46
Different status codes returned from AWS S3, all are non-existing buckets...
$ wget https://s3-us-west-2.amazonaws.com/bucket_a/file_a
--2015-10-21 15:45:04-- https://s3-us-west-2.amazonaws.com/bucket_a/file_a
Resolving s3-us-west-2.amazonaws.com... 54.231.160.96
Connecting to s3-us-west-2.amazonaws.com|54.231.160.96|:443... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: unspecified
ERROR: Redirection (301) without location.
$ wget https://s3-us-west-2.amazonaws.com/bucket_b/file_b
--2015-10-21 15:45:09-- https://s3-us-west-2.amazonaws.com/bucket_b/file_b
Resolving s3-us-west-2.amazonaws.com... 54.231.160.152
@gengmao
gengmao / gist:75e86c1d9d5427f9632d
Last active February 9, 2021 09:55
Select text from a remote tmux session in mouse mode and copy back to Mac

I like to use mouse mode in tmux to scroll text in windows/panes, however I found there is problem when I wanna select and copy text into local system clipboard.

The problem is described at https://awhan.wordpress.com/2012/04/18/tmux-copy-paste-with-mouse/. The workaround is zoom tmux pane -> turn off mouse mode -> select with Option key and copy, then go back. But it is not ideal.

Fortunately I found http://seancoates.com/blogs/remote-pbcopy and https://gist.github.com/burke/5960455. I tweak them a bit and got what I want - select text in one pane in mouse mode correctly and copy it back to Mac system clipboard.

Here are my configurations:

Local (OS X) Side

~/Library/LaunchAgents/pbcopy.plist

#!/usr/bin/python
import string
def reverse(sentence):
stack = []
word = ''
for char in sentence:
if char in string.punctuation or char == ' ':
if word is not None:
stack.append(word)