Skip to content

Instantly share code, notes, and snippets.

@dohsimpson
dohsimpson / resume.json
Last active April 6, 2024 20:23
resume.json
{
"basics": {
"name": "Joe Doe",
"label": "",
"image": "",
"email": "john@gmail.com",
"phone": "(912) 555-4321",
"url": "https://johndoe.com",
"summary": "A summary of John Doe…",
"location": {
@dohsimpson
dohsimpson / advanced_search.markdown
Last active March 18, 2024 10:18
Advanced Search Tricks

Google

  • "cocotte bag": exact match
  • "* is thicker than water": * to replace a phrase inside exact match
  • jaguar -car: minus to filter out matches
  • site:time.com google: search on site, you don't need '.', e.g. 'site:gov'
  • define:bae: check definition, even for slang
  • $0..$50: numeric range (ignore $)
  • "inbound marketing" ~professional: synonyms
  • related:nationalgeographic.com: similar sites
**
*
*******
*
*****
*
******
----------
***
@dohsimpson
dohsimpson / wireguard.conf
Created October 3, 2020 15:58 — forked from nealfennimore/wireguard.conf
Wireguard VPN - Forward all traffic to server
# ------------------------------------------------
# Config files are located in /etc/wireguard/wg0
# ------------------------------------------------
# ---------- Server Config ----------
[Interface]
Address = 10.10.0.1/24 # IPV4 CIDR
Address = fd86:ea04:1111::1/64 # IPV6 CIDR
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; ip6tables -A FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE # Add forwarding when VPN is started
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE; ip6tables -D FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -D POSTROUTING -o eth0 -j MASQUERADE # Remove forwarding when VPN is shutdown
@dohsimpson
dohsimpson / gist:62b4bf6b028138990bb5e3fb0c0f4093
Created May 2, 2019 15:39
Install VIM8 from source (Unix)
#!/bin/bash
cd /tmp/
wget https://github.com/vim/vim/archive/v8.1.1244.tar.gz
tar xzf v8.1.1244.tar.gz
cd vim-8.1.1244/
./configure --enable-perlinterp --enable-rubyinterp --enable-python3interp --enable-luainterp
make
make install

Networking Tools

netstat

  • -i interface config info (use ifconfig -a on Linux for verbose interface info)
  • -a all ports(listening and non-listening)
  • -l all listening ports
  • -t listening TCP ports
  • -p display PID and program names
  • -c it's like watch
  • -rn list routes but don't resolve ip
  • -n numeric ports
* `apt` cannot be followed by module name directory, have to use `name` option
* `import_playbook` is not a task, do not put under tasks
* Don't use `copy`, it is slow, use `synchronize` instead
* `shell` doesn't handle symlink chdir correctly, it's gonna chdir you to resolved path.
@dohsimpson
dohsimpson / sa_application_guide.markdown
Last active November 7, 2018 01:04
SA Application Guide

PostgreSQL

Create User

$ sudo -u postgres createuser -P cronly
$ sudo -u postgres psql
psql (10.5 (Ubuntu 10.5-2.pgdg16.04+1))
Type "help" for help.

postgres=# ALTER USER my_username WITH PASSWORD 'my_password';
ALTER ROLE
Django-REST-Framework
Serializers
* Notice that we're using hyperlinked relations in this case, with HyperlinkedModelSerializer. You can also use primary key and various other relationships, but hyperlinking is good RESTful design
* HyperlinkedModelSerializer:
class UserSerializer(serializers.HyperlinkedModelSerializer):
class Meta:
model = User
fields = ('url', 'username', 'email', 'groups')
@dohsimpson
dohsimpson / learn-django.txt
Last active October 26, 2018 15:08
Learn Django
Django
Model:
Class Based Model:
* class MODEL(models.Model):
FIELD1 = models.AFIELD([FIELDNAME], [default=VALUE])
def __str__(self):
...
Fields: