Skip to content

Instantly share code, notes, and snippets.

View tomekl007's full-sized avatar

Tomasz Lelek tomekl007

View GitHub Profile
#pragma clang diagnostic ignored "-Wold-style-cast"
@rmoff
rmoff / msg.json
Last active November 21, 2022 21:36
Kafka Connect JSON message with schema/payload
{
"schema": {
"type": "struct",
"fields": [{
"type": "int32",
"optional": true,
"field": "c1"
}, {
"type": "string",
"optional": true,
@staltz
staltz / introrx.md
Last active July 19, 2024 22:21
The introduction to Reactive Programming you've been missing
@jkreps
jkreps / benchmark-commands.txt
Last active June 17, 2024 03:54
Kafka Benchmark Commands
Producer
Setup
bin/kafka-topics.sh --zookeeper esv4-hcl197.grid.linkedin.com:2181 --create --topic test-rep-one --partitions 6 --replication-factor 1
bin/kafka-topics.sh --zookeeper esv4-hcl197.grid.linkedin.com:2181 --create --topic test --partitions 6 --replication-factor 3
Single thread, no replication
bin/kafka-run-class.sh org.apache.kafka.clients.tools.ProducerPerformance test7 50000000 100 -1 acks=1 bootstrap.servers=esv4-hcl198.grid.linkedin.com:9092 buffer.memory=67108864 batch.size=8196
import net.liftweb.common._
import net.liftweb.http.LiftRules._
import net.liftweb.http.rest.RestHelper
import net.liftweb.http.{S, JsonResponse, LiftResponse, Req}
import net.liftweb.json.JsonDSL._
import scala.concurrent.duration.Duration
object RateLimit {
public class CorsHeadersFilter implements Filter {
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
if (response instanceof HttpServletResponse) {
HttpServletResponse httpServletResponse = (HttpServletResponse) response;
HttpServletRequest httpServletRequest = (HttpServletRequest) request;
httpServletResponse.addHeader("Access-Control-Allow-Origin", "http://127.0.0.1:3030");
httpServletResponse.addHeader("Access-Control-Allow-Credentials", "true");
httpServletResponse.addHeader("Access-Control-Expose-Headers", "true");
@tomekc
tomekc / absurd_rest_service.js
Created July 4, 2013 21:59
Before running, install express by running npm install express and run with: node absurd_rest_service.js in this script's directory. Then: To submit calculation to curl -i -H "Content-Type: application/json" -d '{ "operation" : "+", "operands" : [ 2,3] }' http://localhost:3000/calculations To see results, use link from response: curl http://loca…
/*
Before running, install express by running
npm install express
and run with:
node absurd_rest_service.js
in this script's directory.
@benjchristensen
benjchristensen / CallbackB.java
Last active January 16, 2024 15:09
CallbackB.java Example of using Callbacks for nested calls showing the incidental complexity that results and how eventually the asynchronous paths need to be synchronized together.
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
public class CallbackB {
/**
@benjchristensen
benjchristensen / FuturesA.java
Last active November 13, 2022 18:34
FuturesA.java Simple example of using Futures.
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
public class FuturesA {
public static void run() throws Exception {
@ngocdaothanh
ngocdaothanh / gist:3764694
Created September 22, 2012 00:43
Scala Assignment: Recursion
package recfun
import scala.collection.mutable.ListBuffer
import common._
/** https://class.coursera.org/progfun-2012-001/assignment/view?assignment_id=4 */
object Main {
def main(args: Array[String]) {
println("Pascal's Triangle")
for (row <- 0 to 10) {