Skip to content

Instantly share code, notes, and snippets.

@elw00d
elw00d / pager.jsp
Created February 27, 2014 11:48
Simple pagination for JSP
<%@page language="java" contentType="text/html; charset=UTF-8" pageEncoding="utf-8" session="false" %>
<%--@elvariable id="url" type="java.lang.String"--%>
<%--@elvariable id="total_records" type="java.lang.Integer"--%>
<%--@elvariable id="current_page" type="java.lang.Integer"--%>
<%--@elvariable id="page_size" type="java.lang.Integer"--%>
<style type="text/css">
div.pagination {
margin-top: 10px;
@elw00d
elw00d / patch-xorg-ubuntu-16.04.3.sh
Last active January 9, 2023 17:59
How to patch xorg in ubuntu 16.04.3 (bug of keyboard layout change)
# Bug https://bugs.launchpad.net/ubuntu/+source/xorg-server/+bug/1683383
# Original article https://habrahabr.ru/post/87408/
# create directory
mkdir xorg-server
cd xorg-server
# get sources of required package
# may be need to uncomment 'deb-src' lines in sources.list before
apt-get source xserver-xorg-core-hwe-16.04
@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>
// http://blog.sandwormz.com/2010/11/rolling-counter-algorithm-pattern.html
class Scratch {
public static void main(String[] args) {
convertPennies(150);
}
public static String[] labels = {"Nickles", "Dimes", "Quarters", "Dollars"};
public static int[] units = {5, 10, 25, 100};
public static void convertPennies(int pennies) {
@elw00d
elw00d / screenshots.js
Last active February 4, 2020 15:50
Скрипт ходит по страницам и делает скриншоты div'а
// Скрипт ходит по страницам и делает скриншоты div'а
// Установка: `npm install puppeteer`
// Запуск: `nodejs screenshot.js`
//
// После работы в директории будет набор файлов 001.png 002.png ... итд
// Чтобы их сконвертировать в pdf, можно воспользоваться imagemagick
//
// # Установить imagemagick
// sudo apt-get install imagemagick
//
namespace
{
inline std::size_t
unaligned_load(const char* p)
{
std::size_t result;
__builtin_memcpy(&result, p, sizeof(result));
return result;
}
/* Точки под Windows 9x/NT/ME/2000/XP */
/* Copyright (c) 2004 by Zealot [WB Team] */
#include <windows.h>
#pragma hdrstop
#include "points.h"
HDC hdc;
PAINTSTRUCT ps;
HPEN hpen;
HBRUSH hbrush;
@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 / autostart.rc.lua
Created August 29, 2017 07:25
piece of rc.lua at the end of my awesome config
-- После запуска unity-settings-daemon нужно некоторое время подождать, прежде чем
-- менять настройки клавиатуры, иначе unity-settings-daemon может поменять их обратно
-- Наверное, можно как-то по логам демона понять, что он запустился, но пока сделал по-простому
os.execute("pgrep unity-settings-daemon || unity-settings-daemon&")
os.execute("sleep 1.5")
os.execute("setxkbmap -layout \'\' -option")
os.execute("setxkbmap -layout \'us,ru\' -option \'grp:ctrl_shift_toggle\'")
os.execute("setxkbmap -option compose:ralt")
@elw00d
elw00d / Dockerfile
Created July 24, 2017 08:21
KeePass dockerfile
FROM ubuntu:14.04
RUN apt-get update && apt-get install -y wget unzip
RUN wget https://downloads.sourceforge.net/project/keepass/KeePass%202.x/2.36/KeePass-2.36.zip
RUN unzip -d /KeePass KeePass-2.36.zip
# xdotool allows KeePass to initiate autoinput (when you press Ctrl+V)
RUN apt-get update && apt-get install -y mono-complete xdotool
WORKDIR /KeePass/