Skip to content

Instantly share code, notes, and snippets.

Use Proxy for Git/GitHub

Generally, the Git proxy configuration depends on the Git Server Protocol you use. And there're two common protocols: SSH and HTTP/HTTPS. Both require a proxy setup already. In the following, I assume a SOCKS5 proxy set up on localhost:1080. But it can also be a HTTP proxy. I'll talk about how to set up a SOCKS5 proxy later.

SSH Protocol

When you do git clone ssh://[user@]server/project.git or git clone [user@]server:project.git, you're using the SSH protocol. You need to configurate your SSH client to use a proxy. Add the following to your SSH config file, say ~/.ssh/config:

ProxyCommand nc -x localhost:1080 %h %p
@win5do
win5do / README.md
Created February 17, 2020 08:31 — forked from chuyik/README.md
macOS 给 Git(Github) 设置代理(HTTP/SSH)
@win5do
win5do / previewImg.js
Created October 11, 2017 09:27
file-input选择图片上传前预览
var $ = require('jquery');
$('#file-input').on('change', function () {
var file = $(this).get(0).files[0];
var formData = new FormData();
formData.append('file', file);
var reader = new FileReader();
reader.readAsBinaryString(file);
reader.onload = function () {
var src = 'data:' + file.type + ';base64,' + window.btoa(this.result);
@win5do
win5do / CompressImg.js
Last active April 8, 2021 02:29
利用cavans实现前端图片压缩
export default class CompressImg {
options = {
files: [], // 文件列表
maxSize: 500 * 1024, // 压缩限度
quality: 0.6, // 质量
}
constructor(options) {
this.options = options;
}
@win5do
win5do / judgeNavigator.js
Created September 21, 2017 11:31
根据navigator判断是否为移动端
if (/mobile|android|iphone|ipad|phone/i.test(navigator.userAgent)) {
window.location.href = "//xxoo.com";
}
@win5do
win5do / rem.js
Created September 21, 2017 11:28
移动端rem为单位根据屏幕自动调整font-size
(function (doc, win) {
var docEle = doc.documentElement,
// evt = 'onorientationchange' in window ? 'orientationchange' : 'resize',
evt = 'orientationchange',
fn = function () {
let width = window.screen.availWidth;
if (width > 750) {
width && (docEle.style.fontSize = 75 + 'px');
} else {