Skip to content

Instantly share code, notes, and snippets.

View mlesikov's full-sized avatar
😀

Mihail Lesikov mlesikov

😀
View GitHub Profile
@mlesikov
mlesikov / gist:753d4439944c7a908c8779b8d66fb975
Last active July 27, 2018 11:27
Chain of responsibility example
core.security
interface SessionHandler {
fun getSessionById(sessionId: String): Session
fun saveSessionInCache(session: Session)
}
data class Session(val sid: String = "")
class PubSubsMessageHandler(val eventBus:EventBus){
fun handleMsg(json:String){
val gson = Gson()
val pubSubMsg = gson.fromJson(json, PubSubMessage::class.java)
val eventType = eventBus.typeOf(pubSubMsg.event) ?: return
val event = gson.fromJson(pubSubMsg.data, eventType)
@mlesikov
mlesikov / contact-form-servlet
Created June 2, 2017 08:47 — forked from fizerkhan/contact-form-servlet
Google App Engine Servlet for Contact form
String name = req.getParameter("name");
String email = req.getParameter("email");
String message = req.getParameter("message");
// Create Mail message
Properties props = new Properties();
Session session = Session.getDefaultInstance(props, null);
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress("[email protected]",
"Acme Support Team"));
@mlesikov
mlesikov / completion-for-gradle.md
Created July 22, 2016 06:56 — forked from nolanlawson/completion-for-gradle.md
Gradle tab completion for Bash. Works on both Mac and Linux.

Gradle tab completion script for Bash

A tab completion script that works for Bash. Relies on the BSD md5 command on Mac and md5sum on Linux, so as long as you have one of those two commands, this should work.

Usage

$ gradle [TAB]
---------- Forwarded message ----------
From: <[email protected]>
Date: 14 Jul 2016 18:08
Subject: Персонал за Велико Търново
To: <[email protected]>
Cc:
Здравей Анатоли,
в продължение на разговора ви с Емо ти изпращам повече информация:
Имаме нужда от 5 момчета, които да ни помогнат за едно събитие на Кока Кола (23-24.07.)
@mlesikov
mlesikov / angularjs_directive_attribute_explanation.md
Created June 14, 2016 15:00 — forked from CMCDragonkai/angularjs_directive_attribute_explanation.md
JS: AngularJS Directive Attribute Binding Explanation

AngularJS Directive Attribute Binding Explanation

When using directives, you often need to pass parameters to the directive. This can be done in several ways. The first 3 can be used whether scope is true or false. This is still a WIP, so validate for yourself.

  1. Raw Attribute Strings

    <div my-directive="some string" another-param="another string"></div>
public class PageRoutingServlet extends HttpServlet {
private Map<String, PageController> pages = Maps.newHashMap();
@Override
public void init(ServletConfig config) throws ServletException {
super.init(config);
pages.put("/page1", new PageController() {
@Override
package com.google.sitebricks.persist;
/**
* Persister Service that manages an entire data store or set of data
* stores as identified by an annotation.
*
* @author [email protected] (Dhanji R. Prasanna)
*/
public abstract class Persister {
public abstract void start();
/**
* @author Mihail Lesikov ([email protected])
*/
public class CsvBuilder {
private final StringBuilder sb;
private String separator = ",";
private String end = "\n";
private static final String NONE = "N/A";
private static final String ZERO = "0";
@mlesikov
mlesikov / FieldsSchema
Created September 1, 2014 06:21
FieldsSchema builder
/**
* @author Mihail Lesikov ([email protected])
*/
public class FieldsSchema {
public static Builder aNewFieldSchema() {
return new Builder();
}
public static class Builder {