Skip to content

Instantly share code, notes, and snippets.

@avshabanov
avshabanov / RequestScopeThreadLocalBinder.java
Last active August 29, 2015 14:25
Example, how to propagate Spring MVC's request context into the new thread
import com.truward.brikar.common.executor.ThreadParametersBinder;
import org.springframework.web.context.request.RequestAttributes;
import org.springframework.web.context.request.RequestContextHolder;
public final class RequestScopeThreadLocalBinder implements ThreadParametersBinder {
@Override
public Object getLocalObject() {
return RequestContextHolder.getRequestAttributes();
@avshabanov
avshabanov / rsvp-promise-testing.js
Created August 7, 2015 06:21
Testing rsvp Promises in Jest
it('should check promise', function () {
// Given:
var rsvp = require('rsvp');
var holder = {val: 0};
// When:
var promise = new rsvp.Promise(function (resolve) { resolve(1); });
promise.then(function (d) { holder.val = d; });
// Then:
@avshabanov
avshabanov / Comparison.md
Created October 10, 2015 20:00
brikar(Spring Core+MVC) vs Guice+Jersey

Web apps were deployed on local computer.

user-service-app

H2+Brikar(AOP)+Spring Core+Spring MVC+Protobuf/Jackson

1000 request, 10 threads, post-warm-up, ab -n 1000 -c 10 -A testonly:test -H 'Accept: application/json' 127.0.0.1:11280/rest/user/account/20:

  50%      2
@avshabanov
avshabanov / Flux Presentation Notes.md
Created October 13, 2015 02:26
Flux Presentation Notes
@avshabanov
avshabanov / H2-backup.md
Last active February 3, 2022 13:11
H2 Tools

Backup by dumping to/restoring from SQL

SCRIPT TO '/tmp/dump.sql';

Then connect to the new database, e.g. [1], then do:

@avshabanov
avshabanov / FastFrameSpeed.java
Created November 29, 2015 23:41
AWT - Fast 2D
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferStrategy;
import javax.swing.JFrame;
import javax.swing.JPanel;
@avshabanov
avshabanov / TestingEmbeddedPromises.js
Created March 27, 2016 04:38
Testing embedded (ES2015) promises in jest
'use strict';
describe('catalog service test', () => {
pit('testing pure promise', () => {
return new Promise((resolve) => {
resolve("getting something");
}).then(() => { expect(1).toBe(1); });
});
});
@avshabanov
avshabanov / sshawsn.sh
Created August 6, 2016 03:27
AWS Scripts
# !/bin/bash
# Easy-to-use access to AWS EC2 - e.g. sshawsn.sh test 1
# hosts.txt - contains ec2 public DNS records
PEM_FILE=$HOME/opt/config/aws/$1.pem
if [ ! -f $PEM_FILE ]; then
echo "Non-existent pem file: $PEM_FILE"
exit -1
fi

Overview

The following cheats apply to PostgreSQL 9.4 on CentOS (and also RHEL and standard Amazon Linux on EC2 instances).

Install and init DB

sudo yum install postgresql94 postgresql94-docs postgresql94-server postgresql94-test postgresql94-contrib
sudo service postgresql94 initdb
<!-- Sample range enumeration -->
<div>
<#list 0..9 as x>
<span><img src="/demo/media/image" width="64" height="64"/></span>
</#list>
</div>