Skip to content

Instantly share code, notes, and snippets.

@cemo
cemo / kafka-cheat-sheet.md
Created February 19, 2018 19:14 — forked from filipefigcorreia/kafka-cheat-sheet.md
Apache Kafka Cheat Sheet

Kafka Topics

List existing topics

bin/kafka-topics.sh --zookeeper localhost:2181 --list

Purge a topic

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

@cemo
cemo / firehose-to-athena.js
Created February 16, 2018 16:25 — forked from tomodian/firehose-to-athena.js
Firehose to Athena
'use strict';
const aws = require('aws-sdk');
const s3 = new aws.S3({ apiVersion: '2006-03-01' });
exports.handler = (event, context, callback) => {
const key = decodeURIComponent(event.Records[0].s3.object.key);
const meta = key.split('/');

Keybase proof

I hereby claim:

  • I am cemo on github.
  • I am cemo (https://keybase.io/cemo) on keybase.
  • I have a public key whose fingerprint is 34D6 0B1E 2F59 6BA1 2E10 E476 427D 912F 0D3A 06E7

To claim this, I am signing this object:

@cemo
cemo / idea.vmoptions
Created November 1, 2016 11:18
IntelliJ IDEA vm options
-server
-Xss256k
-Xms1536m
-Xmx1536m
-Xmn512m
-XX:PermSize=350m
-XX:MaxPermSize=350m
-XX:MetaspaceSize=350m
-XX:MaxMetaspaceSize=350m
-XX:+UseParNewGC
@cemo
cemo / web-servers.md
Created October 12, 2016 08:05 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@cemo
cemo / slackNotify.js
Created June 20, 2016 08:50 — forked from delemach/slackNotify.js
Parse SNS notification from Elastic Beanstalk and publish to Slack channel
var http = require('https');
var querystring = require('querystring');
// set the post request options
var reqOptions = {
hostname: 'hooks.slack.com',
port: 443,
path: '/services/YOUR/SLACK/HOOK_HERE',
method: 'POST'
};
#!/bin/sh
# set the configuration variables below, before running the script
# get the solr nightly build download link from https://builds.apache.org/job/Solr-Artifacts-4.x/lastSuccessfulBuild/artifact/solr/package/
JETTY_URL="http://eclipse.org/downloads/download.php?file=/jetty/stable-9/dist/jetty-distribution-9.0.5.v20130815.tar.gz&r=1"
JETTY_HOME="/opt/jetty"
JAVA='/usr/local/jdk1.7.0_09/bin/java'
JETTY_PORT=8085
JETTY_HOST=127.0.0.1
[INFO]
[INFO] --- maven-dependency-plugin:2.1:tree (default-cli) @ test ---
[INFO] com.example:test:jar:1.0-SNAPSHOT
[INFO] +- com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:jar:2.3.0-SNAPSHOT:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.3.0-SNAPSHOT:compile
[INFO] | \- com.fasterxml.jackson.core:jackson-annotations:jar:2.3.0-SNAPSHOT:compile
[INFO] +- com.fasterxml.jackson.core:jackson-core:jar:2.3.0-SNAPSHOT:compile
[INFO] \- com.codahale.dropwizard:dropwizard-core:jar:0.7.0-SNAPSHOT:compile
[INFO] +- com.codahale.dropwizard:dropwizard-util:jar:0.7.0-SNAPSHOT:compile
[INFO] | +- com.google.guava:guava:jar:14.0.1:compile
org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestWrapper#getUserPrincipal
old:
public Principal getUserPrincipal() {
Authentication auth = getAuthentication();
if ((auth == null) || (auth.getPrincipal() == null)) {
return null;
}
protected long getGeneratedLongKey(PreparedStatement stmt) throws SQLException {
ResultSet rs = null;
long result = 0;
try {
rs = stmt.executeQuery("SELECT @@IDENTITY");
rs.next();
result = rs.getLong(1);
} finally {
if (rs != null)
rs.close();