Skip to content

Instantly share code, notes, and snippets.

Avatar

Jamie Ivanov MuffintopBikini

View GitHub Profile
@MuffintopBikini
MuffintopBikini / README.md
Created May 15, 2019 — forked from steve-jansen/README.md
Stop and start Symantec Endpoint Protection on OS X
View README.md

This script enables you stop and start Symantec Endpoint Protection on OS X

Installation

sudo curl https://gist.githubusercontent.com/steve-jansen/61a189b6ab961a517f68/raw/sep -o /usr/local/bin/sep
sudo chmod 755 /usr/local/bin/sep
sudo chown root:staff /usr/local/bin/sep
@MuffintopBikini
MuffintopBikini / gist:d5e2f00125cd68d99b3b3533c80378f2
Created Jan 26, 2019 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup
View gist:d5e2f00125cd68d99b3b3533c80378f2

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@MuffintopBikini
MuffintopBikini / python.mimetypes.py
Last active May 8, 2018
Fun with Python and mimetypes! Works in Python 2.7.x.
View python.mimetypes.py
import mimetypes
import os
def find_files(root, accepted_types=None):
"""Walk a path and find files that are a specific type, regardless of extension.
:param root: Path to start walking for files.
:type root: str
:param accepted_types: (optional) List of acceptable mimetypes to match.
@MuffintopBikini
MuffintopBikini / python.subprocess.py
Last active May 8, 2018
Fun with Python subprocess! Works on Python 2.7.x.
View python.subprocess.py
import json
import logging
import os
import subprocess
logger = logging.getLogger(os.path.splitext(os.path.basename(__file__))[0])
# If you have ever used jq and tried to use it in Python but ran into
@MuffintopBikini
MuffintopBikini / python.list.fun.py
Last active May 8, 2018
Fun with Python lists! Works on Python 2.7.x.
View python.list.fun.py
def list_chunker(list_obj, chunk_size):
"""Break apart a list into smaller lists as a generator.
:param list_obj: Array of single values in which to be chunkersized.
:type list_obj: list or set
:param chunk_size: Size of the resulting generated lists.
:type chunk_size: int
:return: List of the specified size or last remaining items.
:rtype: list
"""
@MuffintopBikini
MuffintopBikini / python.dict.fun.py
Last active May 8, 2018
Fun with Python dictionaries! Works on Python 2.7.x.
View python.dict.fun.py
def flatten(obj, parent_key=None, sep='.'):
"""Flattens multi-level dictionary to a single-level dictionary.
:param obj: Dictionary object to flatten.
:type obj: dict
:param parent_key: (optional) Prefix for the flattened key. (default: None)
:type parent_key: basestring, str, or unicode
:param sep: (optional) Separator for the nested key names. (default: '.')
:type sep: basestring, str, or unicode
:return: Sexy flattened dictionary.
@MuffintopBikini
MuffintopBikini / python.locale.py
Last active May 8, 2018
Fun with Python and locale! Works on Python 2.7.x.
View python.locale.py
import locale
import logging
import os
logger = logging.getLogger(os.path.splitext(os.path.basename(__file__))[0])
def set_locale(desired_locale=('en_US', 'UTF-8')):
"""Set the local for proper formatting.
@MuffintopBikini
MuffintopBikini / python.datetime.fun.py
Last active May 8, 2018
Fun with Python datetime objects! Works on Python 2.7.x.
View python.datetime.fun.py
import datetime
import pytz
def convert_dt_to_milliseconds(dt_obj):
"""Convert datetime object to a Unix epoch timestamp in milliseconds.
:param dt_obj: Datetime object to be converted.
:type dt_obj: instance
:return: Milliseconds since the Unix epoch.
@MuffintopBikini
MuffintopBikini / python.Files.UTF8.py
Last active May 8, 2018
Fun with Python and UTF-8 files! Works on Python 2.7.x.
View python.Files.UTF8.py
import codecs
import logging
import os
logger = logging.getLogger(os.path.splitext(os.path.basename(__file__))[0])
# NOTE: Python 3.x doesn't have a `unicode()` built-in function.
@MuffintopBikini
MuffintopBikini / python.Files.Gzip.py
Last active May 8, 2018
Fun with Python and Gzipped files! Works on Python 2.7.x.
View python.Files.Gzip.py
import json
import gzip
import logging
import os
logger = logging.getLogger(os.path.splitext(os.path.basename(__file__))[0])
def write_gzip_file(path, data, overwrite_existing=False, compression_level=9):