Skip to content

Instantly share code, notes, and snippets.

@ilguzin
ilguzin / gen-self-signed.txt
Created November 26, 2013 06:01
Create self-signed certificate
# Create key:
openssl genrsa -out DOMAINCOM.com.key 2048
# And the certificate:
openssl req -new -x509 -key DOMAINCOM.key -out DOMAINCOM.cert -days 3650 -subj /CN=DOMAIN.COM
@ilguzin
ilguzin / progress.sh
Last active December 28, 2015 18:49
Progress bar (dots...) on operations execution
#
# Utilities
#
dot_progress() {
while true
do
echo -n "."
sleep 2
done
}
#!/usr/bin/env bash
C="0" # count
while [ $C -lt 20 ]
do
case "$(($C % 4))" in
0) char="/"
;;
1) char="-"
;;
@ilguzin
ilguzin / Boot.scala
Created November 12, 2013 06:39
Turn on ssl support in spray
import spray.routing._
import spray.routing.directives.LogEntry
import spray.http.HttpRequest
import spray.httpx.encoding.{Gzip, NoEncoding}
import akka.event.Logging._
/** Main class to start up the application */
object Boot extends App with SimpleRoutingApp {
#
# Slightly tighter CORS config for nginx
#
# A modification of https://gist.github.com/1064640/ to include a white-list of URLs
#
# Despite the W3C guidance suggesting that a list of origins can be passed as part of
# Access-Control-Allow-Origin headers, several browsers (well, at least Firefox)
# don't seem to play nicely with this.
#
@ilguzin
ilguzin / nginx_redirect_2named_location
Created November 6, 2013 07:03
NGINX: Redirect from current location into named location
# Use only codes greater than 418, do not use common status codes 404, 402, 403, etc
location /js {
error_page 418 = @backend; return 418;
}
location /data {
error_page 418 = @backend; return 418;
}
@ilguzin
ilguzin / gist:6606011
Last active March 9, 2018 07:46
How to convert Java Key Store file to pem/key for nginx
1. Convert our ".jks" file to ".p12" (PKCS12 key store format):
keytool -importkeystore -srckeystore oldkeystore.jks -destkeystore newkeystore.p12 -deststoretype PKCS12
1.1. List new keystore file contents:
keytool -deststoretype PKCS12 -keystore newkeystore.p12 -list
2. Extract pem (certificate) from ".p12" keysotre file:
@ilguzin
ilguzin / idea.vmoptions
Last active March 21, 2022 14:46
High performance Mac OS X IntelliJ IDEA options: /Applications/IntelliJ IDEA 12 CE.app/bin/idea.vmoptions
-server
-Xms512m
-Xmx2048m
-XX:MaxPermSize=512m
-XX:ReservedCodeCacheSize=256m
-XX:+UseCodeCacheFlushing
-XX:+UseCompressedOops
-XX:+UseConcMarkSweepGC
-XX:+AggressiveOpts
-XX:+CMSClassUnloadingEnabled
@ilguzin
ilguzin / OAuth2Authenticator.scala
Last active April 11, 2024 19:27
OAuth2 authenticator for support this kind of auth in JavaMail IMAP folder requests
import com.typesafe.scalalogging.slf4j.Logging
import com.sun.mail.imap.IMAPSSLStore
import javax.mail.{Store, Session}
import java.security.{Provider, Security}
import java.util.Properties
import OAuth2SaslClientFactory
/**
@ilguzin
ilguzin / socket_idle_timeout.java
Created June 5, 2013 08:44
The way to organize read timeout (read idle timeout) for socket connection with Netty. See. http://docs.jboss.org/netty/3.2/api/org/jboss/netty/handler/timeout/ReadTimeoutHandler.html
public class MyPipelineFactory implements ChannelPipelineFactory {
private final Timer timer;
private final ChannelHandler timeoutHandler;
public MyPipelineFactory(Timer timer) {
this.timer = timer;
this.timeoutHandler = new ReadTimeoutHandler(timer, 30), // timer must be shared.
}