Skip to content

Instantly share code, notes, and snippets.

@suroegin
Last active June 8, 2017 09:20
Show Gist options
  • Save suroegin/b6ce60835a2efc7397fc35f79f5168cd to your computer and use it in GitHub Desktop.
Save suroegin/b6ce60835a2efc7397fc35f79f5168cd to your computer and use it in GitHub Desktop.

Travis CI examples

File .travis.yml must be in the root of project.

Example 1

language: python
python:
    - 2.6
    - 2.7

install: python setup.py install
script: trial cotools

Example 2

language: python
python:
  - 2.6
  - 2.7
  - 3.3
  - 3.4
  - 3.6
  - pypy
install:
  - pip install -r requirements.txt
  - pip install -r requirements-test.txt
  - pip install coveralls
script:
  - coverage run --source=slumber setup.py test
after_success:
  - coveralls

Example 3

language: python
python:
  - "2.6"
  - "2.7"
install:
  # Build/test dependencies
  - pip install -r requirements.txt
  # Get fab to test fab
  - pip install -e .
  # Deal with issue on Travis builders re: multiprocessing.Queue :(
  - "sudo rm -rf /dev/shm && sudo ln -s /run/shm /dev/shm"
  - "pip install jinja2"
before_script:
  # Allow us to SSH passwordless to localhost
  - ssh-keygen -f ~/.ssh/id_rsa -N ""
  - cp ~/.ssh/{id_rsa.pub,authorized_keys}
  # Creation of an SSH agent for testing forwarding
  - eval $(ssh-agent)
  - ssh-add
script:
  # Normal tests
  - fab test
  # Integration tests
  - fab -H localhost test:"--tests\=integration"
  # Build docs; www first without warnings so its intersphinx objects file
  # generates. Then docs (with warnings->errors), then www again (also w/
  # warnings on.) FUN TIMES WITH CIRCULAR DEPENDENCIES.
  - invoke www
  - invoke docs -o -W
  - invoke www -c -o -W
notifications:
  irc:
    channels: "irc.freenode.org#fabric"
    template:
      - "%{repository}@%{branch}: %{message} (%{build_url})"
    on_success: change
    on_failure: change
  email: false

UFW CheatSheet

It's a great simple firewall.

Usage

ufw [--dry-run] enable|disable|reload
ufw [--dry-run] default allow|deny|reject [incoming|outgoing]
ufw [--dry-run] logging on|off|LEVEL
    toggle logging. Logged packets use the LOG_KERN syslog facility. Systems configured for rsyslog
    support may also log to /var/log/ufw.log. Specifying a LEVEL turns logging on for the specified LEVEL.
    The default log level is 'low'.
ufw [--dry-run] reset
ufw [--dry-run] status [verbose|numbered]
ufw [--dry-run] show REPORT
ufw [--dry-run] [delete] [insert NUM] allow|deny|reject|limit [in|out] [log|log-all] PORT[/protocol]
ufw [--dry-run] [delete] [insert NUM] allow|deny|reject|limit [in|out on INTERFACE] [log|log-all]
    [proto protocol] [from ADDRESS [port PORT]] [to ADDRESS [port PORT]]
ufw [--dry-run] delete NUM
ufw [--dry-run] app list|info|default|update

Examples

  • ufw status verbose
  • ufw app list
  • ufw allow in on eth0 log from any to any app SSH-22022
  • ufw [delete] allow in proto udp from 193.204.114.105 to 12.34.56.78 port 123

Загрузка файла по ссылке с возможностью продолжить загрузку, например, при обрыве соединения: wget -c http://link/file

Просмотр записи в текстовый файл в реальном времени: tailf file

Узнать время выполнения команды: time command

Слежение за изменениями в выводе команды: watch command

Сочетание клавиш для закрытия текущей сессии в bash и различных утилитах, например клиент MySQL: Ctrl-D

Быстрое создание резервной копии файла: cp file{,.copy}

Очистка файла:

file

Очистка файла при отсутствии прав на файл: echo -n | sudo tee file

или sudo truncate -s 0 file

Сочетание клавиш для поиска по истории введенных ранее команд: Ctrl-R

Копирование файла с выводом прогресса: pv sourcefile > destfile

Поиск по запущенным процессам без вывода самого процесса поиска: ps aux | grep [p]rocess

Создание директории и всех вложенных директорий, если они отсутствуют: mkdir -p /path/to/directory

Вывод всплывающих сообщений в Gnome и Debian-based системах: notify-send "message!"

Работает аналогично команде cat, с тем отличием, что zcat предназначена для запакованных файлов. zcat file

Рекурсивный поиск файлов, содержащих искомую строку: grep -lr string /directory

Выводит список библиотек, необходимых для работы программы: ldd file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment