Skip to content

Instantly share code, notes, and snippets.

Pavel Vlasov pvlasov

Block or report user

Report or block pvlasov

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
pvlasov /
Created Nov 7, 2019
An example of AES encryption and decryption in Java
// --- Encryption ---
// Init cipher
String encryptionKey = ...;
MessageDigest md = MessageDigest.getInstance("SHA-256");
byte[] digest = md.digest();
SecretKey secretKey = new SecretKeySpec(Arrays.copyOf(digest, 16), "AES");
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5PADDING");
String ivStr = ...; // Shared string or unencrypted part of message, or empty string.
IvParameterSpec iv = new IvParameterSpec(Arrays.copyOf(ivStr.getBytes(StandardCharsets.UTF_8), 16));
pvlasov /
Created Nov 4, 2019
Shows basic usage of a command hierarchy in PicoCli
import java.util.concurrent.Callable;
import picocli.CommandLine;
import picocli.CommandLine.Command;
import picocli.CommandLine.IVersionProvider;
import picocli.CommandLine.Model.CommandSpec;
import picocli.CommandLine.ParameterException;
import picocli.CommandLine.Spec;
public class PicoCliTest {
pvlasov /
Last active Nov 4, 2019
Shows how to use Zxing to write/read QR codes
import java.awt.image.BufferedImage;
import java.util.Base64;
import java.util.Random;
import javax.imageio.ImageIO;
pvlasov /
Created Oct 27, 2019
Shows how to use EReferenceItemProvider to create tree nodes (folders) for EReferences
public Collection<?> getChildren(Object object) {
List<EReferenceItemProvider> children = eReferenceItemProviders.get(object);
if (children == null) {
children = new ArrayList<>();
eReferenceItemProviders.put(object, children);
children.add(new EReferenceItemProvider(this, (EObject) object, AppPackage.Literals.CONTAINER__ELEMENTS));
children.add(new EReferenceItemProvider(this, (EObject) object, AppPackage.Literals.ABSTRACT_ACTION__ACTION_MAPPINGS));
children.add(new EReferenceItemProvider(this, (EObject) object, AppPackage.Literals.ACTION_BASE__CONTENT));
pvlasov /
Last active Oct 27, 2019
Shows how to use NasdanikaItemProvider.createItemPropertyDescriptor method
* This adds a property descriptor for the Color feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated NOT
protected void addColorPropertyDescriptor(Object object) {
pvlasov /
Last active Sep 16, 2019
Working with jGit

Maven dependency



pvlasov /
Last active Jul 29, 2019
Shows how to replace object selection dialog in a reference property editor
* @generated NOT
protected void addXXXPropertyDescriptor(Object object) {
EMFEditUIPropertyEditorFactory editorFactory = new EMFEditUIPropertyEditorFactory(null) {
public CellEditor createEditor(Object object, IItemPropertyDescriptor propertyDescriptor, Composite composite) {
ILabelProvider labelProvider = new org.eclipse.emf.edit.ui.provider.PropertyDescriptor(object, propertyDescriptor).getLabelProvider();
pvlasov /
Last active Jul 18, 2019
Headless generation of diagram images from Sirius representations (.aird) with image maps
pvlasov / constraint.ecore
Created Apr 23, 2019
Ecore constraint annotation for generation of validation methods
View constraint.ecore
<eAnnotations source="">
<details key="constraints" value="nonNegativeBalance"/>
pvlasov / clear-targets.bat
Created Jan 8, 2019
Recursively remove target directories in multiple Maven projects
View clear-targets.bat
for /f %i in ('dir /a:d /s /b target') do rd /s /q %i
You can’t perform that action at this time.