Skip to content

Instantly share code, notes, and snippets.

@elw00d
elw00d / RusEnKeyboardLayoutFilter.java
Last active February 5, 2018 10:18
SOLR custom token filter
package ru.dz;
import org.apache.lucene.analysis.TokenFilter;
import org.apache.lucene.analysis.TokenStream;
import org.apache.lucene.analysis.tokenattributes.CharTermAttribute;
import org.apache.lucene.analysis.tokenattributes.PositionIncrementAttribute;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
@elw00d
elw00d / recursive.sql
Created August 12, 2014 09:43
Recursive CTE SQL Server
with cte as (
select id, parentId, name from Category where id = 17
union all
select c.id, c.parentId, c.name from Category c
join cte on c.id = cte.parentId
) select * from cte
@elw00d
elw00d / start.sh
Created August 5, 2014 08:50
Jetty start-stop sh scripts
export LC_ALL=en_US.UTF-8
nohup java -DSTOP.PORT=7575 -DSTOP.KEY=stop_jetty -Djetty.host=localhost -Djetty.port=8080 -jar start.jar &

По мотивам https://vk.com/id232967147 / https://vk.com/mgnoveniag

  1. Создаём пост с любой картинкой.
  2. Ждём полгода/год. Открываем газету, выбираем важные события современности.
  3. Редактируем у себя на комплюктере исходную картинку, описывая важные события современности.
  4. Открываем ту старую фотографию из поста ВКонтакте, нажимаем "Редактировать".
  5. Открываем инструменты разработчика в своём браузере и узнаём значение переменной cur.filterSaveOptions.upload_url.
  6. Пишем программу на HTML. Создаём файлик upload.html:
@elw00d
elw00d / group_concat
Created July 17, 2014 09:28
Group_concat for MS SQL
Tables:
a (id, name)
b (id, name)
a_to_b (a_id, b_id)
Outputs:
a_id a_name b_ids_over_comma
select *, STUFF(
(SELECT ',' + LTRIM(RTRIM(b.name))
@elw00d
elw00d / import.sh
Created May 22, 2014 05:49
2 scripts: to split mysql dump file to multiple files (one per table) and to import all sql files in current directory to local mysql instance.
#!/bin/bash
for FILE in ./*.sql; do
echo "Importing $FILE"
/cygdrive/c/Program\ Files/MySQL/MySQL\ Server\ 5.6/bin/mysql.exe -u root -padmin --database mydb < $FILE
done
@elw00d
elw00d / example.jsp
Created April 16, 2014 07:16
Model to Json serializer JSP tag (by Eugene Dolganov)
<%@ taglib tagdir="/WEB-INF/tags/util" prefix="util" %>
<%-- tag should be placed to Web-inf/tags/util/toJson.tag --%>
<script id="scheduleData" type="json-data"><util:toJson source="${schedule}"/></script>
package su.elwood;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
import javax.servlet.http.HttpServletRequest;
package com.playground.myapp.web;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.service.ServiceRegistryBuilder;
import javax.servlet.ServletContext;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
@elw00d
elw00d / index.html
Created April 5, 2014 08:50 — forked from kg/index.html
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
</head>
<body onload="onLoad()">
<script type="text/javascript">
var jsilConfig = {
printStackTrace: false,
xna: 4,