Skip to content

Instantly share code, notes, and snippets.

View mapix's full-sized avatar

mapix mapix

View GitHub Profile
@mapix
mapix / reset_title.bashrc.sh
Created March 21, 2013 05:58
Reset gnome-terminal title when ssh exit
update_title() {
xtitle --title "$USER@$HOSTNAME ${PWD/#$HOME/~}"
}
PROMPT_COMMAND="update_title"
@mapix
mapix / pr.md
Last active December 16, 2015 05:49 — forked from piscisaureus/pr.md

Locate the section for your github remote in the .git/config file. It looks like this:

[remote "origin"]
	fetch = +refs/heads/*:refs/remotes/origin/*
	url = git@github.com:joyent/node.git

Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:

@mapix
mapix / gist:5402393
Created April 17, 2013 07:22
git tip
git branch -u origin/my_branch
or
git branch --set-upstream my_branch origin/my_branch
<link rel="stylesheet" href="http://cdn.oesmith.co.uk/morris-0.4.2.min.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
<script src="http://cdn.oesmith.co.uk/morris-0.4.2.min.js"></script>
<div id="myfirstchart" style="height: 250px; width:600px;"></div>
<script>
var yMax = 1213;
var yMin = 234;
@mapix
mapix / gist:5589885
Created May 16, 2013 06:56
kill port
#!/bin/bash
port_prefix=`echo $1 | head -c -2`
for pid in `lsof -i | grep \:$port_prefix | awk '{print $2}'| uniq`; do
echo 'killing '${pid}
kill $pid || echo 'killing '${pid}' failed'
done
@mapix
mapix / autocomplete.sh
Last active December 17, 2015 18:39
svn&git repo autocomplete file in vim
function is_git_repository {
git branch > /dev/null 2>&1
}
function is_svn_repository {
test -d .svn
}
if is_git_repository ; then
git ls-files | dmenu -i -l 20 -p $1
$(document).ready(function(){
$(".navbar.navbar-inverse.navbar-fixed-top").fadeTo("slow", 0.05);
$(".navbar.navbar-inverse.navbar-fixed-top").hover(function(){
$(this).fadeTo("fast", 1.0);
},function(){
$(this).fadeTo("slow", 0.05);
});
});
#!/usr/bin/env bash
# gsettings list-recursively org.gnome.system.proxy
# Change de ip address and port number accordingly.
function myProxyOn() {
gsettings set org.gnome.system.proxy mode 'manual' # ' manual / nome / automatic '
gsettings set org.gnome.system.proxy.http host '10.0.0.1'
gsettings set org.gnome.system.proxy.http port 8080
gsettings set org.gnome.system.proxy.https host '10.0.0.1'
@mapix
mapix / lxml_css_selector.py
Created September 18, 2013 05:19
fing element use lxml.cssselector
import urllib
import lxml.html
from lxml.cssselect import CSSSelector
connection = urllib.urlopen('http://dongxi.douban.com/article/1001347/')
dom = lxml.html.fromstring(connection.read())
selAnchor = CSSSelector('a')
foundElements = selAnchor(dom)
print [e.get('href') for e in foundElements]