Skip to content

Instantly share code, notes, and snippets.

View nickname55's full-sized avatar
๐Ÿ˜…

Nnevld nickname55

๐Ÿ˜…
View GitHub Profile
SHOULD MATCH:
http://foo.com/blah_blah
http://foo.com/blah_blah/
http://foo.com/blah_blah_(wikipedia)
http://foo.com/blah_blah_(wikipedia)_(again)
http://www.example.com/wpstyle/?p=364
https://www.example.com/foo/?bar=baz&inga=42&quux
http://โœชdf.ws/123
http://userid:password@example.com:8080
http://userid:password@example.com:8080/
// Code of your Java application that uses the Kafka Streams library
Properties settings = new Properties();
settings.put(StreamsConfig.APPLICATION_ID_CONFIG, "secure-kafka-streams-app");
settings.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "kafka.example.com:9093");
// ...further non-security related settings may follow here...
settings.put(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG, "SSL");
settings.put(SslConfigs.SSL_TRUSTSTORE_LOCATION_CONFIG, "/etc/security/tls/kafka.client.truststore.jks");
settings.put(SslConfigs.SSL_TRUSTSTORE_PASSWORD_CONFIG, "test1234");
settings.put(SslConfigs.SSL_KEYSTORE_LOCATION_CONFIG, "/etc/security/tls/kafka.client.keystore.jks");
settings.put(SslConfigs.SSL_KEYSTORE_PASSWORD_CONFIG, "test1234");
@blzjns
blzjns / MultipartFormData.scala
Last active August 30, 2019 13:27
multipart akka http scala request formdata file client
import java.nio.file.{Path, Paths}
import akka.stream.scaladsl.Source
val foo: Path = Paths.get("/images/foo.jpg")
val bar: Path = Paths.get("/images/bar.png")
val data = Multipart.FormData {
Source {
List (
Multipart.FormData.BodyPart.fromPath("foo", ContentTypes.`application/octet-stream`, foo),
ะฟะพัะบะพะปัŒะบัƒ ะฒั€ะตะผะตะฝะธ ะฝะตะผะฝะพะณะพ,
ั ะฒะบั€ะฐั‚ั†ะต ะผะฐั‚ะพะผ ะพะฑัŠััะฝัŽ
***
ะฝะต ะฝะฐะดะพ ะดะตะปะฐั‚ัŒ ะผะฝะต ะบะฐะบ ะปัƒั‡ัˆะต,
ะพัั‚ะฐะฒัŒั‚ะต ะผะฝะต ะบะฐะบ ั…ะพั€ะพัˆะพ
***
ั ะฝะต ั…ะพั‚ะตะปะฐ ะฒะฐั ะพะฑะธะดะตั‚ัŒ,
ัะปัƒั‡ะฐะนะฝะพ ะฟั€ะพัั‚ะพ ะฟะพะฒะตะทะปะพ
***
ะฑะฐัˆะบะฐ ัะตะณะพะดะฝั ะพั‚ะบะปัŽั‡ะธะปะฐััŒ,
@abhirockzz
abhirockzz / BeanValConstrainViolationExceptionMapper.java
Created January 22, 2016 05:09
Overriding the default exception mapper supplied by JAX-RS implementations
@Provider
public class BeanValConstrainViolationExceptionMapper implements ExceptionMapper<ConstraintViolationException>{
@Override
public Response toResponse(ConstraintViolationException e) {
System.out.println("BeanValConstrainViolationExceptionMapper in action");
ConstraintViolation cv = (ConstraintViolation) e.getConstraintViolations().toArray()[0];
//oh yeah... you need to shell out some $$$ !
return Response.status(Response.Status.PAYMENT_REQUIRED)
@erickok
erickok / OkHttpGzippedLoggingInterceptor.java
Last active November 20, 2025 13:00
Simple logging interceptor for OkHttp that logs full request headers and response headers + body (useful for use with Retrofit 2 where logging was removed)
if (BuildConfig.DEBUG) {
httpclient.interceptors().add(new LoggingInterceptor());
}
public class LoggingInterceptor implements Interceptor {
@Override
public Response intercept(Chain chain) throws IOException {
Request request = chain.request();
long t1 = System.nanoTime();
@arunma
arunma / git-cheatsheet
Last active April 21, 2018 09:39 — forked from TomyJaya/git-cheatsheet.md
git-cheatsheet
# Cloning a remote repository (SSH)
git clone <user@server:path/to/repo.git>
e.g. git clone git@github.com:TomyJaya/git-real.git
# Cloning a remote repository (https)
git clone <URL>
e.g. git clone https://github.com/TomyJaya/git-real.git
# Checking the Status of Your Files
git status
@beradrian
beradrian / ServletUtils.java
Last active April 18, 2024 23:45
Get baseUrl for a servlet request
String getBaseUrl(HttpServletRequest request) {
String baseUrl = request.getRequestURL().substring(0, request.getRequestURL().length() - request.getRequestURI().length()) + request.getContextPath();
return baseUrl;
}
@cmelchior
cmelchior / CustomTypeAdapter.java
Created April 9, 2015 06:35
Realm, GSON and primitive JSON arrays
// Make a custom Gson instance, with a custom TypeAdapter for each wrapper object.
// In this instance we only have RealmList<RealmInt> as a a wrapper for RealmList<Integer>
Type token = new TypeToken<RealmList<RealmInt>>(){}.getType();
Gson gson = new GsonBuilder()
.setExclusionStrategies(new ExclusionStrategy() {
@Override
public boolean shouldSkipField(FieldAttributes f) {
return f.getDeclaringClass().equals(RealmObject.class);
}
@geekmanager
geekmanager / make-git-use-sublime.markdown
Last active May 7, 2025 12:34
Making git use Sublime Text for rebase etc

Making git use Sublime Text

First up, let's make Sublime Text 2 available from the command line in terminal, by creating a link to subl which is the launcher from terminal:

ln -s /Applications/Sublime\ Text\ 2.app/Contents/SharedSupport/bin/subl /usr/local/bin/sublime

(added bonus of this approach is when you upgrade to ST3 or change text editor, you can just redirect the symlink).

If there's any chance that bash doesn't check usr/local/bin then use [Launch Sublime Text 2 from Mac OSX Terminal] for more detailed instructions on how to make this happen.