Skip to content

Instantly share code, notes, and snippets.

@thibaut-d
thibaut-d / 1-modify-a-wikipage.py
Last active March 2, 2019 22:47
Cheatsheet for Pywikibot from the doc
import pywikibot
wikidata_site = pywikibot.Site("wikidata", "wikidata")
wikidata_repo = wikidata_site.data_repository()
page = pywikibot.Page(wikidata_site, 'Wikidata:WikiProject_Materials/Test')
print(page.exists())
print(page.text))
@thibaut-d
thibaut-d / 01 - Django commands
Last active March 2, 2019 22:40
Django cheatsheet from the doc
# Install Django
! pip install django
# Create a project
! django-admin startproject mysite .
# Launch devlopment server
! python manage.py runserver
! python manage.py runserver 8080 # Custom port (default to 8000)
! python manage.py runserver 0.0.0.0:8080 # Allow external access
@thibaut-d
thibaut-d / Using the shell
Last active March 2, 2019 23:42
Another basic linux command line cheatsheet
# print the help
command --help
# ssh commands (use --help)
ssh connect using ssh -pxxxx username@xx.xx.xx.xx
scp ssh copy
rsync remote sync
# common shell commands (use --help)
ls list
@thibaut-d
thibaut-d / Basic security measures for a webserver.sh
Last active March 3, 2019 21:58
Basic security measures for a webserver
# Update the system
apt-get update
apt-get upgrade
# Change root password
passwd root
# Add a new user and give sudo rigts
adduser username
apt-get install sudo #probably not needed
@thibaut-d
thibaut-d / 0 - docker-compose cheatsheet.sh
Last active August 7, 2022 21:30
Cheatsheet for Docker
https://docs.docker.com/compose/reference/overview/
docker-compose build # build containers (usefull if changed)
docker-compose up # builds, (re)creates, starts, and attaches to containers for a service.
docker-compose up -d # same in detached mode
docker-compose up --force-recreate # stop all containers and recreate
docker-compose up --build # rebuild custom images
docker-compose stop # stop but dont remove
docker-compose start # restart
docker-compose down # stop & remove containers
@thibaut-d
thibaut-d / github cheatsheet.sh
Last active March 10, 2019 22:19
github cheatsheet
git init projectname
git commit -a
git push origin master
git push remotename branchname
git clone https://github.com/USERNAME/REPOSITORY.git
git fetch remotename
git merge remotename/branchname
git pull remotename branchname
@thibaut-d
thibaut-d / generate-ssh-key.sh
Created October 8, 2019 22:21 — forked from grenade/01-generate-ed25519-ssh-key.sh
Correct file permissions for ssh keys and config.
ssh-keygen -t rsa -b 4096 -N '' -C "me@gmail.com" -f ~/.ssh/id_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "me@gmail.com" -f ~/.ssh/github_rsa
ssh-keygen -t rsa -b 4096 -N '' -C "me@gmail.com" -f ~/.ssh/mozilla_rsa
@thibaut-d
thibaut-d / docker-compose.yml
Created November 30, 2019 23:25
Neo4j tips
version: '3'
services:
neo4j:
image: neo4j:3.5
restart: unless-stopped
ports:
- 7474:7474
- 7687:7687
@thibaut-d
thibaut-d / 01-add_user_with_ssh_access.sh
Last active May 26, 2020 23:47
Linux add user cheatsheet
# Connect through ssh
ssh username@xx.xx.xx.xx
# Create the Linux user
sudo adduser username
# Check it
cat /etc/passwd
# Grant him sudo privileges (if needed)
@thibaut-d
thibaut-d / docker-compose.yml
Last active July 1, 2021 22:59
docker-compose.yml for Traefik
version: "3.3"
networks:
# Allow the use of traefik in other docker-compose.yml files
traefik:
external: true
services:
traefik: