forked from gto76/linux-cheatsheet
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
517 additions
and
1,428 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.idea | ||
.Rhistory |
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#!/usr/bin/env python3 | ||
# | ||
# Usage: parse.py | ||
# | ||
|
||
import sys | ||
import re | ||
|
||
BATCH_SEPARATOR = "<tr style='padding:3px'><td></td><td></td></tr>" | ||
|
||
def main(): | ||
lines = [a for a in read_file(sys.argv[1]) if re.search('\S', a)] | ||
lines = [convert_specials(a) for a in lines] | ||
out = [] | ||
line_batches = get_line_batches(lines) | ||
line_batches = [parse_batch(a) for a in line_batches] | ||
out = BATCH_SEPARATOR.join(line_batches) | ||
out = f'<table width=700><tbody>\n{out}\n</tbody></table>' | ||
print(out) | ||
|
||
|
||
def convert_specials(line): | ||
line = line.replace('<', '<') | ||
line = line.replace('>', '>') | ||
return line | ||
|
||
|
||
def get_line_batches(lines): | ||
out, batch = [], [] | ||
for line in lines: | ||
no_whitespace = re.match('\S', line) | ||
if no_whitespace and batch: | ||
out.append(batch) | ||
batch = [] | ||
batch.append(line) | ||
if batch: | ||
out.append(batch) | ||
return out | ||
|
||
|
||
def parse_batch(lines): | ||
out = parse_description(lines[0].strip()) | ||
if len(lines) > 1: | ||
out += parse_options(lines[1:]) | ||
return out | ||
|
||
|
||
def parse_description(line): | ||
command, description = line.split(' - ', 1) | ||
description = format_desc(description) | ||
return f'<tr><td valign="top"><strong><code>{command}</code></strong>' \ | ||
f'</td><td>{description}</td></tr>\n' | ||
|
||
|
||
def parse_options(lines): | ||
options = [parse_option(a.strip()) for a in lines] | ||
options = '\n'.join(options) | ||
return f'<tr> <td></td> <td><table>\n{options}\n</table> </td> </tr>\n' | ||
|
||
|
||
def parse_option(line): | ||
tokens = line.split(' - ', 1) | ||
if len(tokens) == 2: | ||
option, description = tokens | ||
description = format_desc(description) | ||
return f'<tr> <td><strong><code>{option}</code></strong></td> <td>{description}</td> </tr>\n' | ||
return f'<tr> <td></td> <td>{tokens[0]}</td> </tr>\n' | ||
|
||
|
||
### | ||
## UTIL | ||
# | ||
|
||
def format_desc(line): | ||
return line[0].upper() + line[1:] + '.' | ||
|
||
|
||
def read_file(filename): | ||
with open(filename, encoding='utf-8') as file: | ||
return file.readlines() | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
|
||
<!DOCTYPE html> | ||
<html class="ocks-org do-not-copy"> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<title>Comprehensive Linux Cheatsheet</title> | ||
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script> | ||
<script src="https://d3js.org/d3.v3.min.js" charset="utf-8"></script> | ||
<script src="web/showdown.min.js"></script> | ||
<link rel="stylesheet" href="web/default.min.css"> | ||
<script src="web/highlight.min.js"></script> | ||
<script src="web/script.js"></script> | ||
</head> | ||
|
||
<style> | ||
@import url(web/style.css); | ||
|
||
.join, | ||
.link, | ||
.node rect { | ||
fill: none; | ||
stroke: #636363; | ||
stroke-width: 1.5px; | ||
} | ||
|
||
.link { | ||
stroke: #969696; | ||
} | ||
|
||
.node rect { | ||
fill: white; | ||
} | ||
|
||
.link path, | ||
.node rect, | ||
.node text, | ||
.join { | ||
-webkit-transition: stroke-opacity 500ms linear, fill-opacity 500ms linear; | ||
-moz-transition: stroke-opacity 500ms linear, fill-opacity 500ms linear; | ||
-ms-transition: stroke-opacity 500ms linear, fill-opacity 500ms linear; | ||
-o-transition: stroke-opacity 500ms linear, fill-opacity 500ms linear; | ||
transition: stroke-opacity 500ms linear, fill-opacity 500ms linear; | ||
} | ||
|
||
.node .element rect { | ||
fill: #bdbdbd; | ||
stroke: none; | ||
} | ||
|
||
.node .null rect { | ||
fill: none; | ||
stroke: none; | ||
} | ||
|
||
.node .null text { | ||
fill: #636363; | ||
} | ||
|
||
.node .selection rect { | ||
stroke: #e6550d; | ||
} | ||
|
||
.node .data rect { | ||
stroke: #3182bd; | ||
} | ||
|
||
.node .datum rect { | ||
fill: #d9d9d9; | ||
stroke: none; | ||
} | ||
|
||
.node .code text { | ||
font-family: monospace; | ||
} | ||
|
||
.node .key rect { | ||
fill: #a1d99b; | ||
stroke: none; | ||
} | ||
|
||
.link .to-key, | ||
.join { | ||
stroke: #a1d99b; | ||
} | ||
|
||
.join { | ||
stroke-dasharray: 2,2; | ||
} | ||
|
||
.link .to-null { | ||
stroke-dasharray: .5,3.5; | ||
stroke-linecap: round; | ||
} | ||
|
||
.link .from-data { | ||
stroke: #3182bd; | ||
} | ||
|
||
.play circle { | ||
fill: #fff; | ||
stroke: #000; | ||
stroke-width: 3px; | ||
} | ||
|
||
.play:hover path { | ||
fill: #f00; | ||
} | ||
|
||
.play.mousedown circle { | ||
fill: #f00; | ||
} | ||
|
||
.play.mousedown path { | ||
fill: #fff; | ||
} | ||
|
||
.play rect { | ||
fill: none; | ||
pointer-events: all; | ||
cursor: pointer; | ||
} | ||
|
||
code span { | ||
-webkit-transition: background 250ms linear; | ||
-moz-transition: background 250ms linear; | ||
-ms-transition: background 250ms linear; | ||
-o-transition: background 250ms linear; | ||
transition: background 250ms linear; | ||
} | ||
|
||
pre.prettyprint, code.prettyprint { | ||
background-color: #222; | ||
border-radius: 8px; | ||
font-size: 15px; | ||
} | ||
|
||
pre.prettyprint { | ||
width: 90%; | ||
margin: 0.5em; | ||
padding: 1em; | ||
white-space: pre-wrap; | ||
} | ||
|
||
|
||
</style> | ||
<!-- td { | ||
padding: 3px; | ||
} --> | ||
<body> | ||
<header> | ||
<aside>March 14, 2018</aside> | ||
<a href="../" rel="author">Jure Šorn</a> | ||
</header> | ||
|
||
<!-- INSERT_HERE --> | ||
<!-- <div id=bla></div> --> | ||
|
||
<footer> | ||
<aside>March 14, 2018</aside> | ||
<a href="../" rel="author">Jure Šorn</a> | ||
</footer> | ||
|
||
<br> | ||
<br> | ||
<br> | ||
|
||
<!-- <script src="web/showdown.min.js"></script> | ||
<link rel="stylesheet" href="web/default.min.css"> | ||
<script src="web/highlight.min.js"></script> | ||
<script src="web/script.js"></script> --> | ||
<!-- <script async="" src="highlight.min.js"></script> --> | ||
</body> | ||
</html> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
$(document).ready(function() { | ||
// parseMd() | ||
}); | ||
|
||
function parseMd() { | ||
var GITHUB = 'https://raw.githubusercontent.com/gto76/my-linux-setup/gh-pages/text-files/WTF-MAN' | ||
jQuery.get(GITHUB, function(text) { | ||
// var converter = new showdown.Converter() | ||
// html = converter.makeHtml(text) | ||
|
||
aDiv = $('#bla') | ||
nodes = $.parseHTML(html) | ||
aDiv.after(nodes); | ||
// insertLinks() | ||
d3.selectAll("code").each(function() { hljs.highlightBlock(this); }); | ||
}); | ||
} | ||
|
||
|
||
function convert(md) { | ||
|
||
} | ||
|
||
function insertLinks() { | ||
$('h2').each(function() { | ||
aId = $(this).attr('id') | ||
$(this).append('<a href="#'+aId+'" name="'+aId+'">#</a>') | ||
}) | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.