Skip to content

Instantly share code, notes, and snippets.

@alexisrobert
alexisrobert / webserver.go
Created May 20, 2011 10:13
Tiny web server in Go for sharing a folder
/* Tiny web server in Golang for sharing a folder
Copyright (c) 2010-2014 Alexis ROBERT <[email protected]>
Contains some code from Golang's http.ServeFile method, and
uses lighttpd's directory listing HTML template. */
package main
import "net/http"
import "net/url"
@juanpabloaj
juanpabloaj / ToggleNumber.vim
Created September 24, 2011 20:15
Toggle {number,relativenumber,off}
nn <silent> <leader>vn :call ToggleNumber()<CR>
fun! ToggleNumber() "{{{
if exists('+relativenumber')
:exec &nu==&rnu? "setl nu!" : "setl rnu!"
else
setl nu!
endif
endf "}}}
@tsabat
tsabat / zsh.md
Last active October 16, 2024 14:43
Getting oh-my-zsh to work in Ubuntu
@bemasher
bemasher / error.go
Created March 9, 2012 07:30
An error handling package for Golang.
package error
import (
"os"
"fmt"
"runtime"
"path/filepath"
)
// Handle an error for the calling function
@zolrath
zolrath / gist:2305333
Created April 4, 2012 20:27
tmux status line from wemux example.

For a tmux status line as seen in the example image for the wemux project: wemux

The session on the left in the example screen shot uses a patched font from the vim-powerline project. Inconsolata-dz, you beautiful creature.

To duplicate the left status line add the following lines to your ~/tmux.conf

set -g status-left-length 32
set -g status-right-length 150
@andsens
andsens / bootstrap_homeshick.sh
Last active December 27, 2023 12:47
Script that can set up an entire user account with homeshick automatically
#!/bin/bash -ex
# Paste this into ssh
# curl -sL https://gist.github.com/andsens/2913223/raw/bootstrap_homeshick.sh | tar -xzO | /bin/bash -ex
# When forking, you can get the URL from the raw (<>) button.
### Set some command variables depending on whether we are root or not ###
# This assumes you use a debian derivate, replace with yum, pacman etc.
aptget='sudo apt-get'
chsh='sudo chsh'
@jedy
jedy / go_scp.go
Last active May 31, 2022 07:20
an example of scp in golang
// https://blogs.oracle.com/janp/entry/how_the_scp_protocol_works
package main
import (
"fmt"
"golang.org/x/crypto/ssh"
)
const privateKey = `content of id_rsa`
@wilbowma
wilbowma / jail.pl
Last active August 1, 2022 11:16
A perl script to create nginx chroot in arch linux.
#a/usr/bin/perl
# This script was hastily cobbled together for my own use. It can
# probably break your system. Use at your own risk.
$JAIL = "/srv/http";
$USER = "http";
$GROUP = "http";
$WWW_DIR = "www";
sub run{
@kvnsmth
kvnsmth / example-subtree-usage.md
Last active March 5, 2023 21:58
A real world usage for git subtrees.

Let's say you have an iOS project, and you want to use some external library, like AFNetworking. How do you integrate it?

With submodules

Add the project to your repo:

git submodule add [email protected]:AFNetworking/AFNetworking.git Vendor/AFNetworking

or something to that effect.

@dgryski
dgryski / godef.vim
Last active December 14, 2015 22:09
vim plugin for godef
" needs https://code.google.com/p/rog-go/source/browse/exp/cmd/godef/godef.go
if !exists("g:godef_command")
let g:godef_command = "godef"
endif
function! GodefUnderCursor()
let offs=line2byte(line('.'))+col('.')-1
call Godef("-o=" . offs)
endfunction