-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.html
246 lines (191 loc) · 12.7 KB
/
test.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Test</title>
<link rel="stylesheet" type="text/css" media="all" href="/css/site.css">
<link rel="stylesheet" type="text/css" href="/css/syntax.css">
<link rel="alternate" type="application/rss+xml" title="Conflating Bits" href="http://blog.coldflake.com/rss.xml">
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon" />
<link href='http://fonts.googleapis.com/css?family=Bitter:400,700,400italic|Ubuntu:400,500,700' rel='stylesheet' type='text/css'>
</head>
<body class="post">
<header class="home">
<h1><a href="../" title="Go back to the homepage"></a></h1>
</header>
<div class="container">
<article>
<header>
<p class="meta"><i class="icon-clock"></i> <time class="timeago" datetime="2014-08-31">2014-08-31</time> <i class="icon-tags"></i> tagged <a href="../tags/programming.html">programming</a>, <a href="../tags/types.html">types</a>, <a href="../tags/C%2B%2B.html">C++</a>, <a href="../tags/lua.html">lua</a>, <a href="../tags/haskell.html">haskell</a>, <a href="../tags/ruby.html">ruby</a>.</p>
<h1>Scripting Git with Ghc Evaluation Mode</h1>
</header>
<section>
<!-- Sample Content to Plugin to Template -->
<h1>CSS Basic Elements</h1>
<p>The purpose of this HTML is to <em>help determine</em> what <strong>default settings</strong> are with CSS and to make sure that all possible HTML Elements are included in this HTML so as to not miss any possible Elements when designing a site.</p>
<hr />
<h1 id="headings">Headings</h1>
<h1>Heading 1</h1> <h1><a href="wrapper">Heading 1</a></h1>
<h2>Heading 2</h2> <h2><a href="wrapper">Heading 2</a></h2>
<h3>Heading 3</h3> <h3><a href="wrapper">Heading 3</a></h3>
<h4>Heading 4</h4> <h4><a href="wrapper">Heading 4</a></h4>
<h5>Heading 5</h5> <h5><a href="wrapper">Heading 5</a></h5>
<h6>Heading 6</h6> <h6><a href="wrapper">Heading 6</a></h6>
<small><a href="#wrapper">[top]</a></small>
<hr />
<h1 id="paragraph">Paragraph</h1>
<img style="width:250px;height:125px;float:right" src="images/snowtrees.jpg" alt="CSS | God's Language" />
<p>Lorem ipsum dolor sit amet, <a href="#" title="test link">test link</a> adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl. Praesent mattis, massa quis luctus fermentum, turpis mi volutpat justo, eu volutpat enim diam eget metus. Maecenas ornare tortor. Donec sed tellus eget sapien fringilla nonummy. Mauris a ante. Suspendisse quam sem, consequat at, commodo vitae, feugiat in, nunc. Morbi imperdiet augue quis tellus.</p>
<p>Lorem ipsum dolor sit amet, <em>emphasis</em> consectetuer adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl. Praesent mattis, massa quis luctus fermentum, turpis mi volutpat justo, eu volutpat enim diam eget metus. Maecenas ornare tortor. Donec sed tellus eget sapien fringilla nonummy. Mauris a ante. Suspendisse quam sem, consequat at, commodo vitae, feugiat in, nunc. Morbi imperdiet augue quis tellus.</p>
<small><a href="#wrapper">[top]</a></small>
<hr />
<h1 id="list_types">List Types</h1>
<h3>Definition List</h3>
<dl>
<dt>Definition List Title</dt>
<dd>This is a definition list division.</dd>
</dl>
<h3>Ordered List</h3>
<ol>
<li>List Item 1</li>
<li>List Item 2</li>
<li>List Item 3</li>
</ol>
<h3>Unordered List</h3>
<ul>
<li>List Item 1</li>
<li>List Item 2</li>
<li>List Item 3</li>
</ul>
<small><a href="#wrapper">[top]</a></small>
<hr />
<h1 id="form_elements">Fieldsets, Legends, and Form Elements</h1>
<fieldset>
<legend>Legend</legend>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl. Praesent mattis, massa quis luctus fermentum, turpis mi volutpat justo, eu volutpat enim diam eget metus.</p>
<form>
<h2>Form Element</h2>
<p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc iaculis suscipit dui.</p>
<p><label for="text_field">Text Field:</label><br />
<input type="text" id="text_field" /></p>
<p><label for="text_area">Text Area:</label><br />
<textarea id="text_area"></textarea></p>
<p><label for="select_element">Select Element:</label><br />
<select name="select_element">
<optgroup label="Option Group 1">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</optgroup>
<optgroup label="Option Group 2">
<option value="1">Option 1</option>
<option value="2">Option 2</option>
<option value="3">Option 3</option>
</optgroup>
</select></p>
<p><label for="radio_buttons">Radio Buttons:</label><br />
<input type="radio" class="radio" name="radio_button" value="radio_1" /> Radio 1<br/>
<input type="radio" class="radio" name="radio_button" value="radio_2" /> Radio 2<br/>
<input type="radio" class="radio" name="radio_button" value="radio_3" /> Radio 3<br/>
</p>
<p><label for="checkboxes">Checkboxes:</label><br />
<input type="checkbox" class="checkbox" name="checkboxes" value="check_1" /> Radio 1<br/>
<input type="checkbox" class="checkbox" name="checkboxes" value="check_2" /> Radio 2<br/>
<input type="checkbox" class="checkbox" name="checkboxes" value="check_3" /> Radio 3<br/>
</p>
<p><label for="password">Password:</label><br />
<input type="password" class="password" name="password" />
</p>
<p><label for="file">File Input:</label><br />
<input type="file" class="file" name="file" />
</p>
<p><input class="button" type="reset" value="Clear" /> <input class="button" type="submit" value="Submit" />
</p>
</form>
</fieldset>
<small><a href="#wrapper">[top]</a></small>
<hr />
<h1 id="tables">Tables</h1>
<table cellspacing="0" cellpadding="0">
<tr>
<th>Table Header 1</th><th>Table Header 2</th><th>Table Header 3</th>
</tr>
<tr>
<td>Division 1</td><td>Division 2</td><td>Division 3</td>
</tr>
<tr class="even">
<td>Division 1</td><td>Division 2</td><td>Division 3</td>
</tr>
<tr>
<td>Division 1</td><td>Division 2</td><td>Division 3</td>
</tr>
</table>
<small><a href="#wrapper">[top]</a></small>
<hr />
<h1 id="misc">Misc Stuff - abbr, acronym, pre, code, sub, sup, etc.</h1>
<p>Lorem <sup>superscript</sup> dolor <sub>subscript</sub> amet, consectetuer adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. <cite>cite</cite>. Nunc iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl. Praesent mattis, massa quis luctus fermentum, turpis mi volutpat justo, eu volutpat enim diam eget metus. Maecenas ornare tortor. Donec sed tellus eget sapien fringilla nonummy. <acronym title="National Basketball Association">NBA</acronym> Mauris a ante. Suspendisse quam sem, consequat at, commodo vitae, feugiat in, nunc. Morbi imperdiet augue quis tellus. <abbr title="Avenue">AVE</abbr></p>
<pre><p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl. Praesent mattis, massa quis luctus fermentum, turpis mi volutpat justo, eu volutpat enim diam eget metus. Maecenas ornare tortor. Donec sed tellus eget sapien fringilla nonummy. <acronym title="National Basketball Association">NBA</acronym> Mauris a ante. Suspendisse quam sem, consequat at, commodo vitae, feugiat in, nunc. Morbi imperdiet augue quis tellus. <abbr title="Avenue">AVE</abbr></p></pre>
<blockquote>
"This stylesheet is going to help so freaking much." <br />-Blockquote
</blockquote>
<small><a href="#wrapper">[top]</a></small>
<!-- End of Sample Content -->
</section>
<section>
<p>Processing bits and pieces on the command line has a very functional feel to it. You feed some input to a function which gives you a result that again can be fed to another function and so on. Each of the individual processing steps resembles a pure function that takes some text as input and outputs some text again.<br />One nice little command I keep in my <code>.bashrc</code> gives a quick overview of the size of all files and folders in the current directory.</p>
<pre class="terminal">
$ du -s ./* | sort -n | cut -f 2- | xargs du -sh
</pre>
<p>This version does actually not work properly…since it also lists files and not only folders. But that’s easy to fix:</p>
<pre class="terminal">
git diff --stat 9e2b68 | ghc -e \
"getContents >>= filterM doesDirectoryExist . L.nub . map(fst.break('/'==).head.words) . lines"
</pre>
<h1 id="some-scripting-examples"><a href="#TOC">Some scripting examples</a></h1>
<p>Having set up the <code>.ghci</code> file here are some more examples of how I now use it, especially together with git.</p>
<h3 id="git-committers-in-a-project"><a href="#TOC">git committers in a project</a></h3>
<p>This is a very simple example of using ghc to process some command output: Combined with a <code>git</code> command, it will list all committers of a project. The haskell part is still pretty modest:</p>
<pre class="sourceCode"><code class="sourceCode haskell">uniq <span class="fu">.</span> <span class="fu">lines</span></code></pre>
Using this little script on Jasper Van der Jeugt’s <a href="http://github.com/jaspervdj/blaze-html.git">blazeHtml</a> repository will result in s.th. like this:
<pre class="terminal">
blazeJasper.git(master) > git log --format='%aN' | ghc -e 'script $ uniq . lines'
["Alex Mason","Chris Done","Frederick Ross","Harald","James Whitehead II",
"Jasper Van der Jeugt","Joeri Samson","Michael Snoyman","Pieter De Baets",
"Sergei Trofimovich","Simon Meier","Tom Harper","Yair Chuchem","oliver","zeuxis"]
</pre>
<p>Not a lot of haskell functionality needed for that one. Let’s look at a more involved example, where we want to find out not only the committers but also rank them according to the number of commits they contributed.</p>
<h3 id="ranking-committers-in-git"><a href="#TOC">ranking committers in git</a></h3>
<p>To do that we can</p>
<ol type="1">
<li>split the commit log into lines</li>
<li>filter out all lines that list an <code>Author</code></li>
<li>sort and group the results so we know how many commits we have per author</li>
<li>count the commits and cut out only the email</li>
<li>sort our items according to the commit count</li>
<li>and print them out in reverse order</li>
</ol>
<h2 id="more-about-ghci-dot-files"><a href="#TOC">More about ghci-dot-files</a></h2>
<p>(<a href="http://neilmitchell.blogspot.com/2010/01/using-ghci-files-to-run-projects.html">This blog post</a> by Neil Mitchell has some nice examples of what you can use .ghci files for as well.)</p>
<p><a href="http://hackage.haskell.org/trac/ghc/ticket/5265">Starting with ghc version 7.4.1</a> it will become possible to specify additional .ghci files. This will allow for a much richer set of imports and definitions for the scripting usecase without polluting the usual ghci setup.</p>
</section>
<section id="comment">
<p>Did you want to comment on this post? Please do so by sending an e-mail
to <a href="mailto: oliver.mueller@gmail.com" title"Send me an email">oliver.mueller@gmail.com</a>
or a tweet to <a href="http://twitter.com/#!/marcontwit" title="Send me a tweet">@marcontwit</a>. Would be honored to meet you.</p>
</section>
</article>
<footer>
<p><a href="../about.html" title="About"><span class="icon-user"></span> About</a> ·
<a href="http://twitter.com/marcontwit" title="My Twitter"><span class="icon-twitter"></span> Twitter</a> ·
<a href="https://github.com/marcmo" title="My Github profile"><span class="icon-github"></span> Github</a> ·
<a href="../rss.xml" title="Feed"><span class="icon-feed2"></span> RSS</a> ·
<a href="mailto:oliver.mueller@gmail.com" title="Send me an email"><span class="icon-envelope-alt"></span> Email</a>
</p>
</footer>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript" src="../js/jquery.timeago.js"></script>
<script type="text/javascript" src="../js/coldflake.ui.js"></script>
</body>
</html>