Skip to content

Instantly share code, notes, and snippets.

View mlesikov's full-sized avatar
😀

Mihail Lesikov mlesikov

😀
View GitHub Profile
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
@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>
---------- Forwarded message ----------
From: <[email protected]>
Date: 14 Jul 2016 18:08
Subject: Персонал за Велико Търново
To: <[email protected]>
Cc:
Здравей Анатоли,
в продължение на разговора ви с Емо ти изпращам повече информация:
Имаме нужда от 5 момчета, които да ни помогнат за едно събитие на Кока Кола (23-24.07.)
@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]
@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"));
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 / 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 = "")
@mlesikov
mlesikov / ShardedSequence.java
Created August 9, 2018 07:49 — forked from cilogi/ShardedSequence.java
A sharded sequence generator for App Engine. Useful for a short URL generator
import com.google.appengine.api.datastore.*;
import com.google.appengine.api.memcache.MemcacheService;
import com.google.appengine.api.memcache.MemcacheServiceFactory;
import com.google.common.collect.ImmutableMap;
import java.util.ConcurrentModificationException;
import java.util.Map;
import java.util.Random;
import java.util.logging.Level;
import java.util.logging.Logger;
'use strict';
angular
.module('datetimepicker', [])
.provider('datetimepicker', function () {
var default_options = {};
this.setOptions = function (options) {
default_options = options;
fix for hotkeys not functional in non-latin keyboard layout in 13.10 / 14.04
tested on ubuntu 14.04, jvm7 and rubymine 6.3
sudo add-apt-repository ppa:attente/java-non-latin-shortcuts
sudo apt-get update
sudo apt-get dist-upgrade
restart unity-settings-daemon
now ctrl+c, ctrl-v etc should work in most java applications like IDEA, RubyMine IDE even on russian keyboard layout