This file contains hidden or 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
| -module(count_words). | |
| -export([count_words/2]). | |
| count_words([32 | Tail], NumWords) -> count_words(Tail, NumWords); | |
| count_words([Letter | Tail], NumWords) -> 1 + count_words2(Tail, NumWords); | |
| count_words([], NumWords) -> NumWords. | |
| count_words2([32 | Tail], NumWords) -> count_words(Tail, NumWords); | |
| count_words2([Letter | Tail], NumWords) -> count_words2(Tail, NumWords); | |
| count_words2([], NumWords) -> NumWords. |
This file contains hidden or 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
| -module(max). | |
| -export([max/1, max0/2]). | |
| max([]) -> []; | |
| max([Head | Tail]) -> max0(Tail, Head). | |
| max0([], CurrentMax) -> CurrentMax; | |
| max0([Head | Tail], CurrentMax) -> | |
| if | |
| CurrentMax >= Head -> max0(Tail, CurrentMax); |
This file contains hidden or 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
| 6> c(max). | |
| {ok,max} | |
| 8> max:max([]). | |
| [] | |
| 10> max:max([10]). | |
| 10 | |
| 11> max:max([2, 3, 10]). | |
| 10 | |
| 13> max:max([2, 3, 10, 1]). | |
| 10 |
This file contains hidden or 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
| -module(bin2dec). | |
| -export([bin2dec/1, bin2dec_/2]). | |
| bin2dec("") -> | |
| 0; | |
| bin2dec(List) -> bin2dec_(List, 0). | |
| bin2dec_([], Sum) -> | |
| Sum; | |
| bin2dec_([48 | Tail], Sum) -> %48 is ascii code for 0 |
This file contains hidden or 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
| #!/bin/bash | |
| # Syntax: create_rabbit_vhost.sh <vhost> <user> <pass> | |
| if [ $# != 3 ]; then | |
| echo "Fail! Syntax: $0 <vhost> <user> <pass>" | |
| exit 1 | |
| fi | |
| rabbitmqctl add_vhost $1 |
This file contains hidden or 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
| 0 | |
| 01 | |
| 02 | |
| 03 | |
| 1 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 |
This file contains hidden or 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
| #!/bin/bash | |
| # Determine if cron is running | |
| # Comes from https://gist.github.com/3061023 | |
| UNKNOWN_STATE=3 | |
| CRITICAL_STATE=2 | |
| WARNING_STATE=1 | |
| OK_STATE=0 |
This file contains hidden or 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
| # Invocation example: | |
| # | |
| # $ curl -s "http://169.254.169.254/latest/user-data/" > /tmp/test.yaml | |
| # $ cat /tmp/test.yaml | |
| # instance: | |
| # flavor: application-server | |
| # $ abc=$(cat /tmp/test.yaml | python ec2-user-data-parser.py instance flavor) | |
| # $ echo $abc | |
| # application-server | |
| # $ |
This file contains hidden or 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
| file { '/etc/timezone': | |
| ensure => present, | |
| content => "Europe/Berlin\n", | |
| } | |
| exec { 'reconfigure-tzdata': | |
| user => root, | |
| group => root, | |
| command => '/usr/sbin/dpkg-reconfigure --frontend noninteractive tzdata', | |
| } |
OlderNewer