H: to go back in tabs
L: to go forward in tabs
\zz: to focus cursor in the middle of the screen
\b: select buffer by number
\e: open up a explorer Tree
This file contains hidden or 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
| psql postgres -U simonthompson | |
| create database <db_name>; | |
| grant all privileges on database <db_name> to simon; | |
| grant all privileges on database <db_name> to cdt_user; | |
| \q |
This file contains hidden or 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
| -- extract single part of date | |
| extract(year from date) -- can be month, day, hour etc. | |
| --e.g. | |
| extract(hour from '1979-02-01 12:03:01') | |
| -- returns 12 | |
| -- reduce date to unit of date, but return full date/timestamp | |
| date_trunc('hour', date/timestamp) -- can be month, day hour, year etc. | |
| --e.g. | |
| date_trunc('hour', timestamp '1979-02-01 12:03:01') |
This file contains hidden or 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
| list_jira_issues <- function(jql, u, p, base_url = 'https://jira.extge.co.uk', fields = c('key'), ignore = c('expand', 'self', 'id')){ | |
| # list issues on jira, returns a dataframe of results | |
| # jql - jira query language string (copy from advanced search url) | |
| # u, p - username and password | |
| # base_url - url of service | |
| # fields - vector of fields of interest | |
| # ignore - vector of column names that can be removed from the output | |
| list_jira_issues_pg <- function(jql, u, p, st, npp, base_url, fields){ | |
| # get a single page of search results | |
| require(httr) |
This file contains hidden or 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_jira_issue <- function(d, u, p, base_url = 'https://jira.extge.co.uk'){ | |
| # create a new jira issue | |
| # d - list equating to the json required to create the ticket | |
| # u, p - username and password to use | |
| # base_url - url of the service to create ticket in | |
| require(httr) | |
| require(jsonlite) | |
| r_url = paste0(base_url, '/rest/api/2/issue') | |
| # make the request | |
| r = POST(r_url, authenticate(u, p, type = 'basic'), body = d, encode = 'json') |
This file contains hidden or 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
| #!/usr/bin/env python3 | |
| import requests | |
| import sys | |
| import pandas as pd | |
| import xlrd | |
| import io | |
| import os | |
| import csv | |
| u = <username> |
This file contains hidden or 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
| #-- use the CDT Bot API token see https://cnfl.extge.co.uk/display/CDT/Generic+Login+Credentials+Information#GenericLoginCredentialsInformation-SlackCDTBotUser | |
| #-- function to send df (d) to a specific channel with optional message, will break up if there are too many rows | |
| send_df_to_slack_as_msg <- function(d, channel, api_token, msg = NA){ | |
| require(knitr) | |
| require(slackr) | |
| slackr_setup(channel = channel, | |
| api_token = api_token) | |
| d <- kable(d, format = 'rst') | |
| if(!is.na(msg)){ | |
| slackr_msg(msg) |
This file contains hidden or 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
| # Template objects allows you to add ${FIELD_NAME} tags into the file | |
| # and then values can be substituted with | |
| # template_object.substitute(FIELD_NAME = <field_value>) | |
| def read_template(filename): | |
| """ | |
| Returns a Template object comprising the contents of the | |
| file specified by filename. | |
| """ | |
| import Template | |
| with open(filename, 'r', encoding='utf-8') as template_file: |
This file contains hidden or 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
| # set up the SMTP server | |
| # for qmul: | |
| # host = smtp-mail.outlook.com | |
| # port = 587 | |
| # username, password = full hh..@qmul.ac.uk email address | |
| import smtplib | |
| from os.path import basename | |
| from email.mime.application import MIMEApplication | |
| from email.mime.multipart import MIMEMultipart | |
| from email.mime.text import MIMEText |
This file contains hidden or 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
| # make white transparent | |
| convert <in>.png -transparent white <out>.png | |
| # change image to a4-sized pdf | |
| convert -density 300 -page a4 <in>.png <out>.pdf | |
| # remove large white backgrounds from multiple images | |
| mogrify -trim +repage *.png | |
| # make image grayscale |