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
// 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();
//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 / img.py
Created April 15, 2014 19:01 — forked from bobuk/img.py
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Video of this screencast: https://vimeo.com/57296525
#
#
from __future__ import print_function, division, absolute_import
from PIL import Image as pImage
import numpy
@lihonosov
lihonosov / nginx_limit_by_user_agent
Last active August 29, 2015 13:57 — forked from supairish/gist:2951524
How to limit nginx requests by user agent
http {
map $http_user_agent $limit_bots {
default '';
~*(google|bing|yandex|msnbot) $binary_remote_addr;
}
limit_req_zone $limit_bots zone=bots:10m rate=1r/m;
server {