Skip to content

Instantly share code, notes, and snippets.

@mattlewissf
mattlewissf / add-p.md
Last active August 5, 2026 13:51
Lightning Talk: Git add -p

git add -p is your friend

git add -p is basically "git add partial (or patch)"

Patch mode allows you to stage parts of a changed file, instead of the entire file. This allows you to make concise, well-crafted commits that make for an easier to read history. This feature can improve the quality of the commits. It also makes it easy to remove parts of the changes in a file that were only there for debugging purposes - prior to the commit without having to go back to the editor.

It allows you to see the changes (delta) to the code that you are trying to add, and lets you add them (or not) separately from each other using an interactive prompt. Here's how to use it:

from the command line, either use

  • git add -p
---
title: "Hey, what a weird way to set titles"
date: 2017-05-24 15:00:00
categories:
tags:
---
I'm gonna try some stuff!
<div id="chart"></div>
<style>
html {
font-size: 62.5% !important; }
body {
font-size: 1.8em !important; /* currently ems cause chrome bug misinterpreting rems on body element */
line-height: 1.6 !important;
font-weight: 200 !important;
color: #222 !important; }
@mattlewissf
mattlewissf / jupyter.css
Last active May 2, 2017 20:36
Jupyter Notebook CSS
<style>
html {
font-size: 62.5% !important; }
body {
font-size: 1.5em !important; /* currently ems cause chrome bug misinterpreting rems on body element */
line-height: 1.6 !important;
font-weight: 400 !important;
font-family: "Raleway", "HelveticaNeue", "Helvetica Neue", Helvetica, Arial, sans-serif !important;
color: #222 !important; }
@mattlewissf
mattlewissf / class_def.py
Created September 7, 2016 14:18
Dynamic class creation example
# written and discarded in favor of sqlalchemy methods - still a good example of how to dynamically create classes in Python
import glob
import sys
from sqlalchemy import Column, ForeignKey, Integer, String
from sqlalchemy.dialects.mysql import TIMESTAMP
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
from sqlalchemy import create_engine
import pandas as pd
@mattlewissf
mattlewissf / digit_recognizer_1.py
Created August 23, 2016 21:26
Kaggle | Digit Recognizer
""" First attempt at Kaggle Digit Recognizer | https://www.kaggle.com/c/digit-recognizer/
Basic approach w/ random trees results in 0.96486 accuracy
"""
import pandas as pd
import numpy as np
from numpy import savetxt
from sklearn.ensemble import RandomForestClassifier
@mattlewissf
mattlewissf / prime_gaps.py
Created August 6, 2016 20:42
prime_gaps.py
import unittest
def gap(g,m,n):
primes = []
# finds primes in range
for num in xrange(m,n+1,1): # n to be included in range
x_half = num / 2
is_prime = all(num % x != 0 for x in xrange(2,x_half+1,1))
if is_prime == True:
lambda x: -683.923549636
lambda x: -116.783533207 * (-(x[6] - -5.1676818541) if x[6] <= -5.41238626298 else 0 if x[6] >= -4.67412019866 else (-0.007619371398 * (x[6] - -4.67412019866) ** 2 + -0.61845994042 * (x[6] - -4.67412019866) ** 3))
lambda x: -29.1588158614 * (0 if x[6] <= -0.137738977403 else (x[6] - 0.751892264604) if x[6] >= 1.25162817331 else (0.0569021591939 * (x[6] - -0.137738977403) ** 2 + 0.145377420148 * (x[6] - -0.137738977403) ** 3)) * (0 if x[6] <= -5.41238626298 else (x[6] - -5.1676818541) if x[6] >= -4.67412019866 else (1.36214458707 * (x[6] - -5.41238626298) ** 2 + -0.61845994042 * (x[6] - -5.41238626298) ** 3))
lambda x: 28.2353765603 * (-(x[6] - 0.751892264604) if x[6] <= -0.137738977403 else 0 if x[6] >= 1.25162817331 else (0.662849995222 * (x[6] - 1.25162817331) ** 2 + 0.145377420148 * (x[6] - 1.25162817331) ** 3)) * (0 if x[6] <= -5.41238626298 else (x[6] - -5.1676818541) if x[6] >= -4.67412019866 else (1.36214458707 * (x[6] - -5.41238626298) ** 2 + -0.61845994042 * (x[6] - -5.412386
@mattlewissf
mattlewissf / 0.2.1-boggle_class_from_methods.rb
Last active January 3, 2016 00:49 — forked from dbc-challenges/0.2.1-boggle_class_from_methods.rb
phase 0 unit 2 week 1 boggle class challenge
class BoggleBoard
def initialize(board)
@board = board
end
def create_word(*coords)
coords.map { |coord| @board[coord.first][coord.last]}.join("")
end
@mattlewissf
mattlewissf / gist:15e074c45e6809fffd11
Created June 12, 2014 00:38
Awesome Sublime Text 2 configuration
{
"auto_complete_commit_on_tab": true,
"auto_complete_delay": 0,
"bold_folder_labels": true,
"caret_style": "wide",