Skip to content

Instantly share code, notes, and snippets.

@jmclong
jmclong / jupyter_notebook_config.py
Created August 26, 2021 19:03
Save a copy of a Jupyter notebook in a '.history' folder every time the notebook is saved
import os
import shutil
import pathlib
from datetime import datetime
def post_save(model, os_path, contents_manager):
"""post-save hook for saving backups of jupyter files."""
if model['type'] != 'notebook':
return # only do this for notebooks
directory, filename = os.path.split(os_path)
@nimaid
nimaid / install_conda.bat
Last active April 28, 2024 11:57
Batch script to install Miniconda on Windows without user input
@echo off
set ORIGDIR="%CD%"
set MINICONDAPATH=%USERPROFILE%\Miniconda3
set CONDAEXE=%TEMP%\%RANDOM%-%RANDOM%-%RANDOM%-%RANDOM%-condainstall.exe
set "OS="
set "MCLINK="
where conda >nul 2>nul
@1kastner
1kastner / map matching with jupyter.ipynb
Last active January 4, 2019 14:20
map matching with jupyter
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jiewpeng
jiewpeng / add_anaconda_right_click_menu.md
Last active May 9, 2024 12:50
Add Anaconda Prompt to Windows right click context menu

This gist describes how to add Anaconda Prompt to the Windows right click context menu. This is because at some point, Anaconda no longer adds itself to the PATH after installation.

  1. Run regedit.exe
  2. Navigate to HKEY_CLASSES_ROOT > Directory > Background > shell
  3. Add a key named AnacondaPrompt and set its value to "Anaconda Prompt Here" (or anything you'd like it to appear as in the right click context menu)
  4. Add a key under this key, called command, and set its value to cmd.exe /K C:\Anaconda3\Scripts\activate.bat (may have to change the activate.bat file to whereever Anaconda is installed)
@beeman
beeman / remove-all-from-docker.sh
Created November 15, 2016 03:04
Remove all from Docker
# Stop all containers
docker stop `docker ps -qa`
# Remove all containers
docker rm `docker ps -qa`
# Remove all images
docker rmi -f `docker images -qa `
# Remove all volumes
@ishu3101
ishu3101 / reset-wsl.sh
Created July 22, 2016 23:38
Resetting your Windows Subsystem for Linux (WSL) Environment
# Resetting your Windows Subsystem for Linux (WSL) Environment
lxrun.exe /uninstall /full
lxrun.exe /install
/*
* Licensed to Peter Karich under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* Peter Karich licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except
* in compliance with the License. You may obtain a copy of the
* License at
*
@PhiBabin
PhiBabin / simulateur.py
Created February 15, 2014 03:32
Flappy Bird Simulator
import pygame, sys, random
from pygame.locals import *
class sim:
# X origin
#DELTA = 0.1
# Windows size#891
WIN_H = 504.
WIN_W = 308 + 600
@Zulko
Zulko / graph_editor.py
Last active April 27, 2021 19:15
This function enables to manually draw a graph (nodes and edges) that can then be used in Python (with Networkx for instance)It's extremely simple: >>> nodes, edges, nodes_positions = graph_editor()
import matplotlib.pyplot as plt
import numpy as np
def graph_editor(grid=True, grid_N = 12):
"""
This function enables to draw a graph manually using
Matplotlib's interactive plotting capabilites.
In a first phase you are asked to place the nodes
(left-click to place a node, right-click to remove
@rmcgibbo
rmcgibbo / viterbi.py
Created October 19, 2012 02:55
Viterbi algorithm for a simple class of HMMs
"""
Viterbi algorithm for finding the most likely state sequence of a simple
hidden markov model.
# https://en.wikipedia.org/wiki/Viterbi_algorithm
The Model
---------
The HMMs considered in this code are extremely simple. Every hidden state
is uniquely associated with an output symbol, but the link is "fuzzy". That is,