Skip to content

Instantly share code, notes, and snippets.

@WilliamQLiu
WilliamQLiu / gist:a7c6fbf201fce273e367
Created October 14, 2015 20:08
Terminal Keys disappear (make typed keys reappear)
$stty echo
@WilliamQLiu
WilliamQLiu / windows_head
Created May 14, 2015 14:41
Windows equivalent of head, pipe, write to file
#In powershell, do this to load a file named "load_me.csv", get first 10000 lines, then output it to "test.csv"
powershell -command "& {Get-Content load_me.csv -TotalCount 10000" | Out-File test.csv
@WilliamQLiu
WilliamQLiu / gist:6494e8ae0b286e4fa7b1
Last active August 29, 2015 14:20
Sublime Text - Multiple Cursors
Highlight your text, do 'Command Shift L' to get multiple cursors
@WilliamQLiu
WilliamQLiu / gist:327d168ebd0626111971
Created February 8, 2015 21:50
Split large file by number of lines
$split -l 1000000 data data.
# Will return files: data.aa, data.ab, data.ac, etc. each with the number of lines specified (one million in this case)
@WilliamQLiu
WilliamQLiu / gist:2ff51a9f560a2ce9c936
Last active August 29, 2015 14:14
Remove first line of a csv file with 'sed'
$sed -i '1d' file.csv # Remove the first line
$sed -i '2d' file.csv # Remove the second line
@WilliamQLiu
WilliamQLiu / gist:506530b03526b0c98e47
Created January 23, 2015 16:51
Python See Docstring
# How to view the docstring of a function quickly
# https://www.python.org/dev/peps/pep-0257/
### View the docstring of a function
$print repr(foo.__doc__) # e.g. print repr(matplotlib.pyplot.plt.__doc__)
### Split the lines
$foo.__doc__.splitlines() # e.g. matplotlib.pyplot.plt.__doc__.splitlines()
### Trim any unnecessary lines - basically do this for best formatting
@WilliamQLiu
WilliamQLiu / csvkit_tutorial
Last active August 29, 2015 14:13
Useful csvkit commands
# From https://csvkit.readthedocs.org
# Shows you stats about the file (e.g. col names, type, nulls, min, max, median, std deviation, unique values, most frequent)
$csvstat myfile.csv
# Peak at excel file to display in terminal
$in2csv myfile.xlsx
$in2csv myfile.xlsx > myfile.csv # can write xlsx file to csv by chaining operations
# Look at data, formats nicely with borders
@WilliamQLiu
WilliamQLiu / countlines
Created January 10, 2015 16:34
Linux - Count number of lines in file
wc -l <myfile> # Example output: 4577465 myfile.csv
@WilliamQLiu
WilliamQLiu / index.html
Created November 18, 2014 21:36
D3 Blank Template
<!DOCTYPE html>
<html>
<head>
<!-- Load D3 from site -->
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<!-- CSS (Styling) -->
<style type="text/css">
</style>
@WilliamQLiu
WilliamQLiu / index.html
Created November 18, 2014 21:35
D3 Basic Template
<!DOCTYPE html>
<!-- D3 Template, can run with: python -m SimpleHTTPServer 8000
Reference: https://github.com/mbostock/d3/wiki/API-Reference
-->
<html>
<head>
<!-- Load D3 from site -->
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>