Skip to content

Instantly share code, notes, and snippets.

@cdbennett
cdbennett / write-unix-eols-on-windows.py
Last active March 20, 2017 16:45
Demonstrate the effects of the newline parameter for Python's open function. See http://stackoverflow.com/a/23434608/994153
#!/usr/bin/env python
import re
import sys
class Mode(object):
def __init__(self, desc, newline):
self.desc = desc
self.newline = newline
@cdbennett
cdbennett / git-switching-branches-with-changed-files.txt
Last active February 18, 2016 16:45
Demonstrate how Git allows switching branches when you have unstaged changes if and only if it can do so without losing data -- for instance if files would need to be merged, or therre are path conflicts.
$ git init myproj && cd myproj
Initialized empty Git repository in C:/tmp/myproj/.git/
$ echo Hello > test.txt
$ git add -A && git commit -m "Initial commit: Hello"
[master (root-commit) dcda84c] Initial commit: Hello
1 file changed, 1 insertion(+)
create mode 100644 test.txt