Take log message and parse as JSON (create new column jsonobj
):
parse "*" as jsonobj
Take new jsonobj
column and create a new column for the specified key in the JSON:
json field=jsonobj "my-obj-key"
The problem: | |
I wanted to use the jinja 'map' filter to modify each item in a string, in this simple | |
example, adding '.conf' to each item. | |
The 'format' filter in jinja takes arguments (value, *args, **kwargs). Unfortunately, | |
it uses 'value' as the pattern. When called inside map 'value' is the current item in | |
the list, or in other words *args as far as format is concerned. So it's the wrong way | |
around. |
<?xml version="1.0"?> | |
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?> | |
<!-- Put site-specific property overrides in this file. --> | |
<configuration> | |
<property> | |
<name>mapreduce.framework.name</name> | |
<value>yarn</value> |
Take log message and parse as JSON (create new column jsonobj
):
parse "*" as jsonobj
Take new jsonobj
column and create a new column for the specified key in the JSON:
json field=jsonobj "my-obj-key"
#!/usr/bin/ruby | |
require 'net/ssh' | |
require 'pp' | |
def fetch(host) | |
data = [] | |
Net::SSH.start(host, 'virool') do |ssh| | |
index_folders = ssh.exec!("ls -d /var/lib/kafka/*").split("\n") | |
data = index_folders.flat_map do |ifolder| |
Here are 10 one-liners which show the power of scala programming, impress your friends and woo women; ok, maybe not. However, these one liners are a good set of examples using functional programming and scala syntax you may not be familiar with. I feel there is no better way to learn than to see real examples.
Updated: June 17, 2011 - I'm amazed at the popularity of this post, glad everyone enjoyed it and to see it duplicated across so many languages. I've included some of the suggestions to shorten up some of my scala examples. Some I intentionally left longer as a way for explaining / understanding what the functions were doing, not necessarily to produce the shortest possible code; so I'll include both.
The map
function takes each element in the list and applies it to the corresponding function. In this example, we take each element and multiply it by 2. This will return a list of equivalent size, compare to o
#!/usr/bin/env ruby | |
require 'thread' | |
Thread.abort_on_exception = true | |
module Enumerable | |
def peach n=nil, &block | |
pmap n, &block | |
self | |
end |
Once in a while, you may need to cleanup resources (containers, volumes, images, networks) ...
// see: https://github.com/chadoe/docker-cleanup-volumes
$ docker volume rm $(docker volume ls -qf dangling=true)
$ docker volume ls -qf dangling=true | xargs -r docker volume rm
Assuming device /dev/xvdd
being mounted to /data
.
sudo mkfs -t ext4 /dev/xvdd
sudo mkdir /data
sudo mount /dev/xvdd /data
Add line to /etc/fstab
to mount every boot:
sudo vi /etc/fstab
/dev/xvdd /data ext4 defaults,nofail 0 2
bin/kafka-topics.sh --zookeeper localhost:2181 --list
bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic mytopic --config retention.ms=1000
... wait a minute ...
bin/kafka-topics.sh --zookeeper localhost:2181 --alter --topic mytopic --delete-config retention.ms