Skip to content
Permalink
Browse files

Improved the source code styling

  • Loading branch information...
peri4n committed Nov 24, 2018
1 parent 6b74445 commit baa404d13f0342cebec7bab42ca3402ad286c5a5
@@ -1,5 +1,6 @@
---
title: Home
layout: default
---

$partial("templates/post-list.html")$
@@ -15,9 +15,9 @@ The tools we are going to use are [Vagrant][vagrant] (to manage the boxes) and [

If you are on a mac installing both is as easy as:

``` zsh
~~~~ {.zsh .numberLines}
brew install vagrant virtualbox
```
~~~~

Other operating system should be comparably easy.

@@ -26,7 +26,7 @@ Other operating system should be comparably easy.
I'd like to use Ubuntu 16.04 (LTS) for my boxes. Searching the vagrantcloud I found: [bento/ubuntu-16.04][bento].
To use it create a file called `Vagrantfile` with the following content:

``` ruby
~~~~ {.zsh .numberLines}
Vagrant.configure("2") do |config|
config.vm.define :server1 do |server1|
server1.vm.box = "bento/ubuntu-16.04"
@@ -38,25 +38,25 @@ Vagrant.configure("2") do |config|
server2.vm.network :private_network, ip: "10.11.1.101"
end
end
```
~~~~

# Spinning up the boxes

Starting both machines is as easy as:

``` zsh
~~~~ {.zsh .numberLines}
vagrant up
```
~~~~

Both servers are now up and running. You can ssh into server1 with:

``` zsh
~~~~ {.zsh .numberLines}
vagrant ssh server1
```
~~~~

To see if server2 to is also up and running, we can ping it:

``` zsh
~~~~ {.zsh .numberLines}
vagrant ssh server1
vagrant@vagrant:~$ ping 10.11.1.101
PING 10.11.1.101 (10.11.1.101) 56(84) bytes of data.
@@ -65,7 +65,7 @@ PING 10.11.1.101 (10.11.1.101) 56(84) bytes of data.
64 bytes from 10.11.1.101: icmp_seq=3 ttl=64 time=0.537 ms
64 bytes from 10.11.1.101: icmp_seq=4 ttl=64 time=0.535 ms
...
```
~~~~

[hadoop]: http://hadoop.apache.org/
[vagrant]: http://vagrantup.com/
@@ -14,12 +14,12 @@ boot an entire hadoop cluster on my MacBook Pro.
To tell Vagrant that we want to use Ansible to provision the our virtual machines we have to adjust our `Vagrantfile`.
The follwing snippet has to be placed inside the config blog we introduced last time:

``` ruby
~~~~ {.ruby .numberLines}
config.vm.provision :ansible do |ansible|
ansible.playbook = "provision/playbook.yml"
ansible.sudo = true
end
```
~~~~

The first line inside the ansible block tells Vagrant the path to our playbook, which we will create soon. The second
line tells Ansible to execute every command inside the playbook as root user.
@@ -34,23 +34,31 @@ already been done in a previous provisioning.
But let's get back on track. Please copy the content, I'll explain everything afterwards.


``` yaml
~~~~ {.yaml .numberLines}
---
- hosts: all
tasks:
- name: Install java 8 preresequesits
apt: name=python-software-properties
apt:
name: python-software-properties
- name: Add Java 8 repository
apt_repository: repo='ppa:webupd8team/java'
apt_repository:
repo: 'ppa:webupd8team/java'
- name: Agree to oracle license
debconf: name=oracle-java8-installer question=shared/accepted-oracle-license-v1-1 vtype=select value=true
debconf:
name: oracle-java8-installer
question: shared/accepted-oracle-license-v1-1
vtype: select
value: true
- name: Install Java 8
apt: name=oracle-java8-installer force=yes
```
apt:
name: oracle-java8-installer
force: yes
~~~~

The first line is Ansible specific and tells it on which hosts the playbook should be run. When using Vagrant, this line should be
ignore because Vagrant decides on which hosts the playbook is applied.
@@ -14,7 +14,7 @@ As this index contains 500 companies, it would be quite cumbersome to maintain a
The wikipedia page of the [S&P 500][sp500] contains a list of all tickers currently in the index. After having a look at the underlying HTML code, I came up with the following
python script:

``` python
~~~~ {.python .numberLines}
import bs4 as bs
import requests
@@ -24,7 +24,7 @@ table = soup.find('table', { 'class': 'wikitable sortable'})
for row in table.findAll('tr')[1:]:
ticker = row.findAll('td')[0].text
print(ticker)
```
~~~~

Which retrieves the first *table* and prints the text content of the first cell of every row, except the first one (Because is only contains the table header).
If you like to have this information inside python you can append the tickers to a list and do some further analysis.
@@ -33,7 +33,7 @@ If you like to have this information inside python you can append the tickers to

Just in case you have problems adopting this script to other pages, here is a script which scrapes the [DAX 30 index][dax30].

``` python
~~~~ {.python .numberLines}
import bs4 as bs
import requests
@@ -43,7 +43,7 @@ table = soup.find('table', { 'class': 'wikitable sortable'})
for row in table.findAll('tr')[1:]:
ticker = row.findAll('td')[3].text
print(ticker)
```
~~~~

This page has the tickers written on the fourth column.

@@ -1,73 +1,157 @@
/* ==============================================================================
Tango (pandoc built-in style)
==============================================================================
Style based on Pygments' "tango" colors.
This stylesheet was produced using Pandoc v2.0.5.
Pandoc is (c) 2006-2017 John MacFarlane (jgm@berkeley.edu).
Released under the GPL, version 2 or greater.
------------------------------------------------------------------------------
*/
a.sourceLine { display: inline-block; line-height: 1.25; }
a.sourceLine { pointer-events: none; color: inherit; text-decoration: inherit; }
a.sourceLine:empty { height: 1.2em; position: absolute; }
.sourceCode { overflow: visible; }
code.sourceCode { white-space: pre; position: relative; }
div.sourceCode { margin: 1em 0; }
pre.sourceCode { margin: 0; }
@media screen {
div.sourceCode { overflow: auto; }
a.sourceLine {
display: inline-block;
line-height: 1.25;
pointer-events: none;
color: inherit;
text-decoration: inherit;

:empty {
height: 1.2em;
position: absolute;
}
}
@media print {
code.sourceCode { white-space: pre-wrap; }
a.sourceLine { text-indent: -1em; padding-left: 1em; }
.sourceCode {
overflow: visible;
}
pre.numberSource a.sourceLine
{ position: relative; }
pre.numberSource a.sourceLine:empty
{ position: absolute; }
pre.numberSource a.sourceLine::before
{ content: attr(data-line-number);
position: absolute; left: -5em; text-align: right; vertical-align: baseline;
border: none; pointer-events: all;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
color: #aaaaaa;
}
pre.numberSource { margin-left: 3em; border-left: 1px solid #aaaaaa; padding-left: 4px; }
div.sourceCode
{ background-color: #f8f8f8; }
@media screen {
a.sourceLine::before { text-decoration: underline; }

code.sourceCode {
white-space: pre;
position: relative;
}

div.sourceCode {
margin: 1em 0;
padding: 5px 0px;
border: #e6e6e6 1px solid;
border-radius: 5px;
background: #f5f5f0;
}

pre.sourceCode {
margin: 0;
}
pre.numberSource {
margin-left: 3em;
padding-left: 4px;

a.sourceLine {
position: relative;

&:empty {
position: absolute;
}

&:before {
content: attr(data-line-number);
position: absolute; left: -5em; text-align: right; vertical-align: baseline;
border: none; pointer-events: all;
-webkit-touch-callout: none; -webkit-user-select: none;
-khtml-user-select: none; -moz-user-select: none;
-ms-user-select: none; user-select: none;
padding: 0 4px; width: 4em;
color: #aaaaaa;
}
}
}
code span {
&.al { /* Alert */
color: #ef2929;
}
&.an { /* Annotation */
color: #8f5902;
font-weight: bold;
font-style: italic;
}
&.at { /* Attribute */
color: #c4a000;
}
&.bn { /* BaseN */
color: #0000cf;
}
&.ch { /* Char */
color: #96c0d8;
}
&.cf { /* ControlFlow */
color: #ac4142;
font-weight: bold;
}
&.cn { /* Constant */
color: #000000;
}
&.co { /* Comment */
color: #8f5902;
font-style: italic;
}
&.cv { /* CommentVar */
color: #8f5902;
font-weight: bold;
font-style: italic;
}
&.do { /* Documentation */
color: #8f5902;
font-weight: bold;
font-style: italic;
}
&.dt { /* DataType */
font-weight: bold;
color: #ac4142;
}
&.dv { /* DecVal */
color: #ce5c00;
}
&.er { /* Error */
color: #a40000;
font-weight: bold;
}
&.ex { /* Extension */
}
&.fl { /* Float */
color: #0000cf;
}
&.fu { /* Function */
color: #000000;
}
&.im { /* Import */
color: #ac4142;
}
&.in { /* Information */
color: #8f5902;
font-weight: bold;
font-style: italic;
}
&.kw { /* Keyword */
color: #ac4142;
font-weight: bold;
}
&.op { /* Operator */
color: #ce5c00;
font-weight: bold;
}
&.ot { /* Other */
color: #8f5902;
}
&.pp { /* Preprocessor */
color: #8f5902;
font-style: italic;
}
&.sc { /* SpecialChar */
color: #000000;
}
&.ss { /* SpecialString */
color: #96c0d8;
}
&.st { /* String */
color: #a366ff;
}
&.va { /* Variable */
color: #000000;
}
&.vs { /* VerbatimString */
color: #a366ff;
}
&.wa { /* Warning */
color: #8f5902;
font-weight: bold;
font-style: italic;
}
}
code span.al { color: #ef2929; } /* Alert */
code span.an { color: #8f5902; font-weight: bold; font-style: italic; } /* Annotation */
code span.at { color: #c4a000; } /* Attribute */
code span.bn { color: #0000cf; } /* BaseN */
code span.cf { color: #204a87; font-weight: bold; } /* ControlFlow */
code span.ch { color: #4e9a06; } /* Char */
code span.cn { color: #000000; } /* Constant */
code span.co { color: #8f5902; font-style: italic; } /* Comment */
code span.cv { color: #8f5902; font-weight: bold; font-style: italic; } /* CommentVar */
code span.do { color: #8f5902; font-weight: bold; font-style: italic; } /* Documentation */
code span.dt { color: #204a87; } /* DataType */
code span.dv { color: #0000cf; } /* DecVal */
code span.er { color: #a40000; font-weight: bold; } /* Error */
code span.ex { } /* Extension */
code span.fl { color: #0000cf; } /* Float */
code span.fu { color: #000000; } /* Function */
code span.im { } /* Import */
code span.in { color: #8f5902; font-weight: bold; font-style: italic; } /* Information */
code span.kw { color: #204a87; font-weight: bold; } /* Keyword */
code span.op { color: #ce5c00; font-weight: bold; } /* Operator */
code span.ot { color: #8f5902; } /* Other */
code span.pp { color: #8f5902; font-style: italic; } /* Preprocessor */
code span.sc { color: #000000; } /* SpecialChar */
code span.ss { color: #4e9a06; } /* SpecialString */
code span.st { color: #4e9a06; } /* String */
code span.va { color: #000000; } /* Variable */
code span.vs { color: #4e9a06; } /* VerbatimString */
code span.wa { color: #8f5902; font-weight: bold; font-style: italic; } /* Warning */

0 comments on commit baa404d

Please sign in to comment.
You can’t perform that action at this time.