sudo mkdir /etc/mesos-dns
sudo vi /etc/mesos-dns/config.json
<?xml version="1.0"?> | |
<!DOCTYPE fontconfig SYSTEM "fonts.dtd"> | |
<fontconfig> | |
<match> | |
<edit mode="prepend" name="family"><string>Noto Sans</string></edit> | |
</match> | |
<match target="pattern"> | |
<test qual="any" name="family"><string>serif</string></test> | |
<edit name="family" mode="assign" binding="same"><string>Noto Serif</string></edit> | |
</match> |
DROP TABLE if exists d_date; | |
CREATE TABLE d_date | |
( | |
date_dim_id INT NOT NULL, | |
date_actual DATE NOT NULL, | |
epoch BIGINT NOT NULL, | |
day_suffix VARCHAR(4) NOT NULL, | |
day_name VARCHAR(9) NOT NULL, | |
day_of_week INT NOT NULL, |
import logging | |
import uuid | |
import time | |
from mesos.interface import Scheduler | |
from mesos.native import MesosSchedulerDriver | |
from mesos.interface import mesos_pb2 | |
logging.basicConfig(level=logging.INFO) |
Beautiful is better than ugly. Explicit is better than implicit.
I frequently deal with collections of things in the programs I write. Collections of droids, jedis, planets, lightsabers, starfighters, etc. When programming in Python, these collections of things are usually represented as lists, sets and dictionaries. Oftentimes, what I want to do with collections is to transform them in various ways. Comprehensions is a powerful syntax for doing just that. I use them extensively, and it's one of the things that keep me coming back to Python. Let me show you a few examples of the incredible usefulness of comprehensions.
All of the tasks presented in the examples can be accomplished with the extensive standard library available in Python. These solutions would arguably be more terse and efficient in some cases. I don't have anything against the standard library. To me there is a certain
import sys | |
'''sum of digits in a number''' | |
print(sum(int(i) for i in sys.argv[1])) |
Instructions to run the programs | |
Download the gist | |
Run hiphop.py by using command | |
$> python hiphop.py | |
Run freqcount.oy by passing the file name containing numbers as an argument for script. Note : place the FILE with numbers in same directory as freqcount.py or specify full path | |
$> python freqcount.py numbers |
#! /bin/bash | |
WALLPAPERS="/path/to/wallpapers/directory" | |
ALIST=( `/bin/ls -w1 $WALLPAPERS` ) | |
RANGE=${#ALIST[@]} | |
let "number = $RANDOM" | |
let LASTNUM="`/bin/cat $WALLPAPERS/.last` + $number" | |
let "number = $LASTNUM % $RANGE" | |
echo $number > $WALLPAPERS/.last | |
feh --bg-center $WALLPAPERS/${ALIST[$number]} |
## # Run /bin/false every minute year round | |
* * * * * /bin/false | |
## # Run /bin/false at 1:35 on the mon,tue,wed and the 4th of every month | |
35 1 4 * mon-wed /bin/false | |
## # Run /bin/true at 22:25 on the 2nd of March | |
25 22 2 3 * /bin/true | |
## # Run /bin/false at 2:00 every Monday, Wednesday and Friday |
chmod +x /path_to_script |