Skip to content

Instantly share code, notes, and snippets.

ansible-playbook -i <inventory-file> deploy_authorized_keys.yml --ask-become-pass --ask-pass --extra-vars='pubkey="<pubkey-for-super-user>”’
---
- hosts: all
become: true
become_user: "super-user"
tasks:
- name: make direcotry
file:
path: "/home/<super-user>/.ssh"
state: directory
- name: create empty file
[defaults]
host_key_checking = False
@visualskyrim
visualskyrim / gist:a2d0bc6541fa6709c79afdf1e524e086
Created November 9, 2017 06:30
Execute deploy_authorized_keys.yml as the same user as that in remote host
ansible-playbook -i <inventory-file> deploy_authorized_keys.yml --ask-pass --extra-vars='pubkey="<pubkey>"'
@visualskyrim
visualskyrim / deploy_authorized_keys.yml
Created November 9, 2017 06:28
deploy_public_key_as_same_user.yml
---
- hosts: all
tasks:
- name: make direcotry
file:
path: "/home/<username>/.ssh"
state: directory
- name: create empty file
file:
path: "/home/<username>/.ssh/authorized_keys"
@visualskyrim
visualskyrim / DataTransfer.java
Created June 13, 2017 13:20
Simple Flink job streaming data from Kafka to local files.
import org.apache.flink.api.common.restartstrategy.RestartStrategies;
import org.apache.flink.api.java.utils.ParameterTool;
import org.apache.flink.streaming.api.CheckpointingMode;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.CheckpointConfig;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.streaming.connectors.fs.bucketing.BucketingSink;
import org.apache.flink.streaming.connectors.fs.bucketing.DateTimeBucketer;
import org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer08;
import org.apache.flink.streaming.util.serialization.SimpleStringSchema;
@visualskyrim
visualskyrim / kafka_consumer.logstash
Created June 13, 2017 13:00
Simple Kafka consumer
input {
kafka {
group_id => "flink-test"
topics => ["flink-test"]
bootstrap_servers => "localhost:9092"
}
}
output {
stdout {}
}
@visualskyrim
visualskyrim / Producer.py
Created June 13, 2017 12:58
Simple python Kafka producer
from kafka import KafkaProducer
from kafka.errors import KafkaError
import json
import time
producer = KafkaProducer(bootstrap_servers=['localhost:9092'], value_serializer=lambda m: json.dumps(m).encode('ascii'))
# Asynchronous by default
future = producer.send('flink-test', b'raw_bytes')
# Block for 'synchronous' sends
@visualskyrim
visualskyrim / ShowBox.jsx
Last active May 22, 2017 12:34
Use Enzyme to test React/Redux container - simulate & find
it("should render a text box with no string inside if search string is not provided by store", () => {
const testState = {
showBox: {
search: ""
}
};
const store = createMockStore(testState)
const component = shallowWithStore(<ConnectedShowBox />, store);
expect(component).to.be.a('object');
@visualskyrim
visualskyrim / ShowBox.jsx
Created May 22, 2017 10:48
Use Enzyme to test React/Redux container - dive
describe('ConnectedShowBox', () => {
it("should render a text box with empty string inside if string is not provided by store", () => {
const testState = {
searchBox: {}
};
const store = createMockStore(testState)
const component = shallowWithStore(<ConnectedShowBox />, store);
expect(component).to.be.a('object');
expect(component.dive().find("").prop("value")).to.equal("")
});