Skip to content

Instantly share code, notes, and snippets.

View lihonosov's full-sized avatar
Talk is cheap. Show me the code © Linus Torvalds

Oleksandr Lykhonosov lihonosov

Talk is cheap. Show me the code © Linus Torvalds
  • The Future
View GitHub Profile
@lihonosov
lihonosov / zsh.md
Last active August 29, 2015 14:19 — forked from tsabat/zsh.md
@lihonosov
lihonosov / eclipse_content_assist_favorites_java
Created March 30, 2015 13:53
My Eclipse Content Assist Favorites for Java
com.google.common.collect.Lists
com.google.common.collect.Maps
com.google.common.collect.Sets
org.hamcrest.CoreMatchers
org.hamcrest.Matchers
org.junit
org.junit.Assert
org.junit.Assume
org.junit.matchers.JUnitMatchers
org.mockito.Matchers

NOTE: You can check, if your config here:
http://www.sslshopper.com/ssl-checker.html

Decrypt the private key using the password you entered when you created your key:
openssl rsa -in ssl.key -out /etc/nginx/conf/ssl.key

Protect your key from prying eyes:
chmod 600 /etc/nginx/conf/ssl.key

// Setup the LDAP client (normally done via Spring context file).
LdapContextSource contextSource = new LdapContextSource();
contextSource.setUrl("ldap://adserver.mycompany.com:3268");
contextSource.setBase("DC=AD,DC=MYCOMPANY,DC=COM");
contextSource.setUserDn("[email protected]");
contextSource.setPassword("password1");
contextSource.afterPropertiesSet();
LdapTemplate ldapTemplate = new LdapTemplate(contextSource);
ldapTemplate.afterPropertiesSet();
@lihonosov
lihonosov / remote_debug_tomcat_eclipse
Created October 15, 2014 21:15
Remote debug tomcat in eclipse
Starting Apache Tomcat in debug mode
First of all we have to restart the Tomcat with debug option for this purpose we need to pass to JVM (Java Virtual Machine) the options
-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n
JVM opens a port in current machine allowing external applications (like Eclipse) to connect for debugging purposes.
To do that with Tomcat we have to set the environment variable JAVA_OPTS that is read by Tomcat in startup.sh file.
1) Set variable and make it available. we can choose the port number, in this example is used 8000 number.
export JAVA_OPTS="-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n"
2) Start Tomcat (from bin folder):
@lihonosov
lihonosov / ant_tomcat_start_stop_deploy
Last active August 29, 2015 14:07
Ant tomcat targets
<project name="testproject" default="tomcat-start">
<property name="tomcat.home" value="/Downloads/apache-tomcat"/>
<path id="tomcat.class.path">
<fileset dir="${tomcat.home}/lib">
<include name="**/*.jar"/>
<include name="**/*.zip"/>
</fileset>
<pathelement location="${tomcat.home}/bin/bootstrap.jar"/>
<pathelement location="${tomcat.home}/bin/tomcat-juli.jar"/>
</path>
//This sample is how to use websocket of Tomcat.
package wsapp;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.CharBuffer;
import java.util.ArrayList;
import org.apache.catalina.websocket.MessageInbound;
import org.apache.catalina.websocket.StreamInbound;
import org.apache.catalina.websocket.WebSocketServlet;
@lihonosov
lihonosov / nginx_ssl
Created July 28, 2014 08:42
Дружим nginx + ssl
touch /etc/nginx/ssl.conf
# Подключение самоподписанного сертификата
# генерация сертификата:
# openssl req -new -x509 -days 9999 -nodes -out cert.pem -keyout cert.key
ssl on;
ssl_protocols SSLv3 TLSv1;
ssl_certificate /etc/nginx/ssl/cert.pem;
ssl_certificate_key /etc/nginx/ssl/cert.key;
@lihonosov
lihonosov / Bind_GeoDNS
Created July 27, 2014 13:09
Bind GeoDNS
Для популярного сервера BIND существует GeoDNS Patch (http://www.caraytech.com/geodns/). Он позволяет указывать различные записи в зависимости от места положения клиента. В качестве базы геоданных используется Max Mind (https://www.maxmind.com/en/country).
Пример конфигурации для различных стран:
view "usa" {
match-clients { country_US; country_CA; country_MX; };
recursion no;
zone "ruhighload.com" {
type master;
file "pri/ruhighload.usa.db";
};
@lihonosov
lihonosov / protecting_folders_with_nginx
Created July 2, 2014 19:22
Protecting Folders with Nginx
//Creating .htpasswd
htpasswd -c /var/www/html/admin/.htpasswd username
//Setting up Nginx
server {
listen 80;
server_name domain.com www.domain.com;
location / {
# your normal content