Skip to content

Instantly share code, notes, and snippets.

View mattmc3's full-sized avatar
๐Ÿ
Python!

mattmc3 mattmc3

๐Ÿ
Python!
View GitHub Profile
@mattmc3
mattmc3 / hello.py
Created April 6, 2017 15:08
Python2 hello world
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
DOCSTRING
"""
from __future__ import print_function
from __future__ import unicode_literals
from __future__ import division
@mattmc3
mattmc3 / create_venv.bash
Created April 6, 2017 15:09
Python3 create new virtual environment
python3 -m venv ~/.virtualenvs/my-venv
@mattmc3
mattmc3 / bulk_rename.bash
Created April 6, 2017 15:18
Bash - bulk rename
rename -S .jpeg .jpg *.jpeg
@mattmc3
mattmc3 / Makefile
Created April 6, 2017 15:26
Makefile template
# Makefile to simplify some common development tasks.
# Run 'make help' for a list of commands.
PYTHON=`which python`
default: help
help:
@echo "Available commands:"
@sed -n '/^[a-zA-Z0-9_.]*:/s/:.*//p' <Makefile | sort
@mattmc3
mattmc3 / rand.bash
Created April 6, 2017 15:49
Bash - generate random base64 string
openssl rand -base64 32
@mattmc3
mattmc3 / ssh_passwordless_login.bash
Last active April 14, 2017 13:16
SSH - push public key for passwordless login to ssh server
ssh [[user]]@[[hostname]]
mkdir .ssh
chmod 700 .ssh
exit
cat ~/.ssh/id_rsa.pub | ssh [[user]]@[[hostname]] 'cat >> .ssh/authorized_keys'
@mattmc3
mattmc3 / rotate_jpg.bash
Created April 6, 2017 15:51
Bash - rotate jpg
jhead -autorot *.jpg
@mattmc3
mattmc3 / html_to_markdown.bash
Created April 6, 2017 15:54
HTML to Markdown
find . -name \*.html -type f -exec pandoc -f html -t markdown_strict -o {}.md {} \;
@mattmc3
mattmc3 / csv2tsv.py
Created April 6, 2017 16:39
Python - csv to tsv
#!/usr/bin/env python
"""
CSV to TSV
"""
import csv
import re
def csv2tsv(csvpath, delimiter=',', quotechar='"', newdelimiter='\t'):
@mattmc3
mattmc3 / all_data_types.sql
Last active April 6, 2017 19:05
MSSQL - table with all types
create table all_datatypes (
id int identity(1,1) not null
,bigint_field bigint
,binary_field binary(50)
,bit_field bit
,char_field char(10)
,date_field date
,datetime_field datetime
,datetime2_field datetime2(7)
,datetimeoffset_field datetimeoffset(7)