Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env bash
# referencing: https://www.moerats.com/archives/507/
set -e
# Usage: pipe to `sh` on the fly, or download and use
# curl -L https://tinyurl.com/mk-inst-py | PYTHON_VERSION=<2.7.15 or 3.6.5> [SILENT_SUDO=1] sh
# wget https://tinyurl.com/mk-inst-py && PYTHON_VERSION=3.6.5 sh ./install_python_from_source.sh
if ! [[ "$PYTHON_VERSION" =~ ^(2.7.15|3.6.5)$ ]]; then # required environ var
echo "Usage: PYTHON_VERSION=<2.7.15 or 3.6.5> [SILENT_SUDO=1] sh $BASH_SOURCE"
@priancho
priancho / pprint_utf8.py
Created April 25, 2017 02:30
python 2.x pprint with UTF-8 text
import pprint
class MyPrettyPrinter(pprint.PrettyPrinter):
"""PrettyPrint with UTF-8 text.
Refer to: http://stackoverflow.com/questions/10883399/unable-to-encode-decode-pprint-output
"""
def format(self, object, context, maxlevels, level):
if isinstance(object, unicode):
return (object.encode('utf8'), True, False)
return pprint.PrettyPrinter.format(self, object, context, maxlevels, level)
@onevcat
onevcat / Jitouch-Restarter
Created February 15, 2016 04:14
This gist kill Jitouch and then restart it. It solves problems when using Jitouch with Magic Trackpad 2
pkill -f "Jitouch"
sleep 5
nohup ~/Library/PreferencePanes/Jitouch.prefPane/Contents/Resources/Jitouch.app/Contents/MacOS/Jitouch > /dev/null 2>&1 &
@vpontis
vpontis / copy.py
Last active January 11, 2024 18:59
Copy to clipboard from iPython on Mac OS X
"""
Add copy to clipboard from IPython!
To install, just copy it to your profile/startup directory, typically:
~/.ipython/profile_default/startup/
Example usage:
%copy hello world
# will store "hello world"
@PurpleBooth
PurpleBooth / README-Template.md
Last active April 27, 2025 06:17
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@seberg
seberg / rolling_window.py
Created October 10, 2012 14:38
Multidimensional rolling_window for numpy
def rolling_window(array, window=(0,), asteps=None, wsteps=None, axes=None, toend=True):
"""Create a view of `array` which for every point gives the n-dimensional
neighbourhood of size window. New dimensions are added at the end of
`array` or after the corresponding original dimension.
Parameters
----------
array : array_like
Array to which the rolling window is applied.
window : int or tuple
@clintel
clintel / gist:1155906
Created August 19, 2011 02:40
Fenced code in bullet lists with GitHub-flavoured MarkDown??

Fenced code blocks inside ordered and unordered lists

  1. This is a numbered list.

  2. I'm going to include a fenced code block as part of this bullet:

    Code
    More Code
    
@pksunkara
pksunkara / config
Last active April 22, 2025 22:10
Sample of git config file (Example .gitconfig) (Place them in $XDG_CONFIG_HOME/git)
[user]
name = Pavan Kumar Sunkara
email = [email protected]
username = pksunkara
[init]
defaultBranch = master
[core]
editor = nvim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
pager = delta