This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
func faviconHandler(w http.ResponseWriter, r *http.Request) { | |
http.ServeFile(w, r, "relative/path/to/favicon.ico") | |
} | |
... | |
func main() { | |
http.HandleFunc("/favicon.ico", faviconHandler) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo apt-get install nmap | |
# Scan all hosts in the network (between 192.168.1.0 and 192.168.1.255) by ping | |
$ nmap -sP 192.168.1.0/24 | |
# Scan all open ports on a host | |
$ nmap 192.168.1.123 | |
# Detect OS, services | |
$ nmap -A minhnd.com |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get request parameters | |
## GET paramaters | |
### GET example.com/item?id=1203&name=minhnd | |
### or POST example.com/item (data: id=1203, name=minhnd) | |
id := c.GetInt("id") | |
name := c.GetString("name") | |
### Other methods | |
### c.GetString(key string) string | |
### c.GetStrings(key string) []string | |
### c.GetInt(key string) (int64, error) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Button-like anchor element | |
<a href="/page.html" class="btn btn-primary" role="button">Add item</a> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func get_root() (int) { | |
euid := os.Geteuid() | |
if euid != 0 { | |
fmt.Println("[-] You didn't run as root!") | |
fmt.Println("[-] Exiting...") | |
os.Exit(1) | |
} | |
return euid | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Installation | |
$ wget -qO- https://get.docker.com/ | sh | |
# Some useful commands | |
$ docker pull ubuntu:latest | |
$ docker images | |
$ docker ps | |
$ docker ps -a | |
$ docker run -it ubuntu:latest /bin/bash | |
$ docker run -it --name="my_docker_image" ubuntu:latest /bin/bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Create a new session | |
$ tmux | |
## or | |
$ tmux new | |
## or | |
$ tmux new -s <session-name> | |
# Detaching from a session | |
$ tmux detach |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ignore files from repository in the pull request | |
git update-index --assume-unchanged source/law/*.pyc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# add the following util.py to your application directory | |
# in the models.py | |
from .util import create_thumbnail | |
class Article(models.Model): | |
image = models.ImageField(default="") | |
thumbnail = models.ImageField() | |
def save(self): | |
# create a thumbnail |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Installation | |
$ sudo apt-get install virtualenv | |
# Usage | |
$ virtualenv <yourdir> | |
$ cd <yourdir> | |
$ source bin/activate |