Example 1: Delete lines 1, 3 and 5.
sed -e '1d;3d;5d' $filename
Example 2: Delete line 1.
import sublime_plugin, os | |
class RemoteEdit(sublime_plugin.EventListener): | |
def on_post_save(self, view): | |
remote = { "/local/path/to/project": "/usr/bin/scp '$1' username@remote_host:'/remote/path/to/project$2'" } | |
for dirname, target in remote.iteritems(): | |
if view.file_name().startswith( dirname ): | |
target = target.replace( "$1", view.file_name() ) | |
target = target.replace( "$2", view.file_name()[len(dirname):] ) |
""" | |
We used this script to migrate from gitlab.com to our self-hosted gitlab. | |
Author: Mohammad Javad Naderi | |
Before running the script, install `python-gitlab` package. | |
Important Note: | |
In order to keep the authors of merge requests and comments, before running this script make | |
sure all users have enabled "Public Email" in their gitlab.com profile and create account for | |
all users in self-hosted Gitlab (with the same e-mail address as their gitlab.com public email). |
import os | |
import subprocess | |
import requests | |
import logging | |
from logging.handlers import RotatingFileHandler | |
logger = logging.getLogger("gh-mirror.py") | |
logfile = os.path.join(os.path.dirname(__file__), "logs", "gh-mirror.log") | |
logdir = os.path.dirname(logfile) |
# GitLab user project export | |
# | |
# Install gitlab module: python3 -m pip install python-gitlab==3.15.0 | |
# | |
# Set environment variables GITLAB_URL and GITLAB_OAUTH_TOKEN (Personal Access Token): | |
# GITLAB_URL=https://gitlab.com GITLAB_OAUTH_TOKEN=changeme python3 gitlab-export.py | |
import gitlab | |
import time | |
import tarfile |
import requests | |
import os | |
import argparse | |
import logging | |
logging.basicConfig(level=logging.INFO) | |
arg_parser = argparse.ArgumentParser(description='Call GitLab API') | |
arg_parser.add_argument('--gitlab-token', required=True, help='GitLab token') | |
arg_parser.add_argument('--gitlab-url', required=True, help='GitLab URL') | |
arg_parser.add_argument('--org-name', required=True, help='Organization name') |
ASCI art characters for creating diagrams
#!/bin/bash | |
# | |
BACKUPDEST="$1" | |
DOMAIN="$2" | |
MAXBACKUPS="$3" | |
if [ -z "$BACKUPDEST" -o -z "$DOMAIN" ]; then | |
echo "Usage: ./vm-backup <backup-folder> <domain> [max-backups]" | |
exit 1 |