Skip to content

Instantly share code, notes, and snippets.

View cosmtrek's full-sized avatar
🦄
Build!

Rick Yu cosmtrek

🦄
Build!
View GitHub Profile

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
@cosmtrek
cosmtrek / backup_repo_mirrors.sh
Last active May 20, 2022 11:11
backup github repo
#!/bin/bash
BACKUP_DIR="$HOME/backup/repo-mirrors"
REPOS=(
"cosmtrek/dotfiles"
"cosmtrek/air"
"typefuture/powerbox"
"zdharma-continuum/zinit"
"neovim/neovim"
)
@cosmtrek
cosmtrek / commit.md
Created May 15, 2019 09:58 — forked from abravalheri/commit.md
RFC: Git Commit Message Guidelines

Commit Message Guidelines

In the last few yers, the number of programmers concerned about writting structured commit messages had dramatically grown. As exposed by Tim Pope in article readable commit messages are easy to follow when looking through the project history. Moreover the AngularJS contributing guides introduced conventions that can be used by automation tools to automatically generate useful documentation, or by developpers during debbuging process.

This document borrow some concepts, conventions and even text mainly from these two sources, extending them in order to provide a sensible guideline for writing commit messages.

@cosmtrek
cosmtrek / bijective.rb
Last active August 29, 2015 14:21 — forked from zumbojo/bijective.rb
# Simple bijective function
# Basically encodes any integer into a base(n) string,
# where n is ALPHABET.length.
# Based on pseudocode from http://stackoverflow.com/questions/742013/how-to-code-a-url-shortener/742047#742047
ALPHABET =
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789".split(//)
# make your own alphabet using:
# (('a'..'z').to_a + ('A'..'Z').to_a + (0..9).to_a).shuffle.join
@cosmtrek
cosmtrek / index.md
Last active August 29, 2015 14:17 — forked from rstacruz/index.md

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs