Blog
Some ramblings and write-ups about tech, music, travelling and other topics.
So here's a little instruction on how to set up git proxy switching to swtich between accessing your home git repos from work, where you have to go through SOCKS proxy for external access, and git repos on internal network.
Setting the environment variable GIT_PROXY_COMMAND
overrides whatever proxy configuration already exists - this is all we need to get git:// repositories to work. To get Git-over-SSH connections to work, which you probably want for push operations, you’ll also need to set up GIT_SSH
.
~/home/.gitconfig-work
. It might look something like this:
[user]
name = Takeshi Kanemoto
email = [email protected]
[color]
ui = auto
[core]
attributesfile = ~/.gitattributes
[user]
name = Takeshi Kanemoto
email = [email protected]
[color]
ui = auto
[url "ssh://[email protected]:29418/"]
insteadOf = git://tak.atso-net.jp/
pushInsteadOf = git://tak.atso-net.jp/
[core]
attributesfile = ~/.gitattributes
[user]
name = Takeshi Kanemoto
email = [email protected]
[color]
ui = auto
[url "ssh://[email protected]:29418/"]
pushInsteadOf = git://tak.atso-net.jp/
[core]
attributesfile = ~/.gitattributes
#!/bin/sh
# Filename: ~/bin/git-switch
# This script switches between work, home, and local
# It MUST be sourced.
echo "I: setting up for $1..."
[ -e ~/.gitconfig ] && rm -v ~/.gitconfig
case $1 in
home)
export GIT_SSH="${HOME}/bin/socks-ssh"
export GIT_PROXY_COMMAND="${HOME}/bin/socks-gw"
ln -v -s .gitconfig-home ~/.gitconfig
;;
local)
unset GIT_SSH
unset GIT_PROXY_COMMAND
ln -v -s .gitconfig-local ~/.gitconfig
;;
work|*)
unset GIT_SSH
unset GIT_PROXY_COMMAND
ln -v -s .gitconfig-work ~/.gitconfig
esac
echo "I: GIT_SSH=$GIT_SSH"
echo "I: GIT_PROXY_COMMAND=$GIT_PROXY_COMMAND"
echo "I: done!"
#!/bin/sh
# Filename: ~/bin/socks-gw
# This script connects to a SOCKS proxy using connect.c
$HOME/bin/connect -H proxy.bashmygash.net:8080 [email protected]
You will need to have a built binary from connect.c in ~/bin/connect
#!/bin/sh
# Filename: ~/bin/socks-ssh
# This script opens an SSH connection through a SOCKS server
ssh -o ProxyCommand="${HOME}/bin/socks-gw %h %p" [email protected]
. ~/bin/git-switch {work|home|local}
Or even better, you can add the following to ~/.bashrc
:
alias gits='. ${HOME}/bin/git-switch'
and all you have to do is
gits {work|home|local}
Sometimes in Bash, you want to display some text in the console and sometimes you may also want to have the ability to overwrite the line that you have just displayed with a new string. For example, a bash script could display a text “Working..” on the console and then, instead of display “Finished!” to the next line, you want the line that first display “Working…” be cleared and replace with the “Finished!” string. Here is a little piece of code that could do this:
#!/bin/bash
tput sc
echo -n “Working…”
for i in `seq 1 5000`;
do
echo $i > \dev\null
done
tput el1
tput rc
echo “Finished!”
Update
There's actually a simpler way:
for i in `seq 1 5000`; do
echo $i > /dev/null # do some processing
echo -n -e "working $i\x0d"
done
/System/Library/LaunchDaemons/com.ikey.bbot.plist /Bin/poc-bbotReinstall OpenSSH
Jenna is said to 'Burst into tears' when she thinks of her lowest point as a frozen yogurt saleswoman in the Nevada desert, an occupation that we've failed to mention until now....DAAAAYYYAAAMMMNNN!
On July 23, 2010 Apple began allowing iPhone 4 owners to receive a free case or bumper in the hopes of fixing the notorious antenna reception problems caused by holding in a way that attenuates the antenna. Here is how you can get your free case or bumper from your iPhone, from your computer, or as a refund.
I often use this blog for my own reference, and often access it from my iPhone. Though the iPhone renders the blog wonderfully in full, having to zoom in and out to navigate around the blog is a bit of a pain in the backside. While browsing through the sea of wordpress plugins - a lot of good stuff, some of them weren't so helpful - I've stumble upon WPtouch, which seems to be the best plugin for making WordPress blogs render in "mobile" mode. It detects if the client is a mobile device (iPhone/iPod/Android), and automatically applies a very well-polished iPhone-themed style with various JQuery visual effects, all with one simple Install -> Activate.[gallery]