I've been working with Apache Kafka for over 7 years. I inevitably find myself doing the same set of activities while I'm developing or working with someone else's system. Here's a set of Kafka productivity hacks for doing a few things way faster than you're probably doing them now. 🔥
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.reflect.Field; | |
import sun.misc.Unsafe; | |
public class TestThreadStackSize { | |
private static void crashVM() { | |
try { | |
makeSegfault(getUnsafe()); | |
} catch (Exception e) { | |
// swallow | |
} |
A complete list of RxJS 5 operators with easy to understand explanations and runnable examples.
First of all, please note that token expiration and revoking are two different things.
- Expiration only happens for web apps, not for native mobile apps, because native apps never expire.
- Revoking only happens when (1) uses click the logout button on the website or native Apps;(2) users reset their passwords; (3) users revoke their tokens explicitly in the administration panel.
A JWT token that never expires is dangerous if the token is stolen then someone can always access the user's data.
Quoted from JWT RFC:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
AfterContentInit, Directive, ElementRef, EventEmitter, Inject, Input, OnDestroy, Output, PLATFORM_ID, | |
Renderer2 | |
} from "@angular/core"; | |
import {isPlatformBrowser} from "@angular/common"; | |
@Directive({ | |
selector: '[image-loader]' | |
}) | |
export class ProgressiveImageLoaderDirective implements AfterContentInit, OnDestroy { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RequestMapping(value = "/runJobAndGetLogs", method = RequestMethod.GET) | |
public ResponseEntity<StreamingResponseBody> runJobAndGetLogs() throws IOException { | |
final InputStream inputStream = someService.runJobAndGetReportProgress(); | |
StreamingResponseBody body = StreamingResponseBody body = (outputStream) -> { | |
try (BufferedInputStream br = new BufferedInputStream(inputStream)) { | |
// just copying to the outputstream | |
byte[] contents = new byte[1024]; | |
int bytesRead = 0; | |
while ((bytesRead = br.read(contents)) != -1) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var http = require("http"), | |
url = require("url"), | |
path = require("path"), | |
fs = require("fs") | |
port = process.argv[2] || 8888; | |
http.createServer(function(request, response) { | |
var uri = url.parse(request.url).pathname | |
, filename = path.join(process.cwd(), uri); |