Skip to content

Instantly share code, notes, and snippets.

View raydac's full-sized avatar
🐷
working

Igor Maznitsa raydac

🐷
working
View GitHub Profile
@raydac
raydac / IcnsGen.java
Last active November 2, 2019 18:00
Java class to generate ICNS from image under MacOS
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.geom.AffineTransform;
import java.awt.image.BufferedImage;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileOutputStream;
import java.nio.file.FileSystems;
import java.nio.file.Path;
@raydac
raydac / AbstractFsm.java
Last active July 27, 2018 19:33
Auxiliary Java class to organize FSM
package com.igormaznitsa.misc;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
@raydac
raydac / gist:2d7bb49494b55ffd1bfc91a4616723ca
Last active April 22, 2017 10:37
Script to make UDEV rule (for Ubuntu 16.04) to enable access of "scanner" group to port of Brother DCP-7055
#!/bin/bash
echo Make rule to enable USB port of Brother DCP-7055
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
RULE_FOLDER=/etc/udev/rules.d
@raydac
raydac / class2jbbp
Last active June 25, 2016 13:11
Function to generate [JBBP DSL script](https://github.com/raydac/java-binary-block-parser) from a class contains fields marked by `@Bin` annotations
/**
* Generates <a href="https://github.com/raydac/java-binary-block-parser">JBBP DSL script</a> from class @BIN annotated fields. Extra field of @BIN annotation is used as expression for array length if the text starts with 'expr:'
* <p>Example code:
* <pre>{@code
* public static class Chunk {
* @Bin(outOrder = 1, type = BinType.INT)
* int length;
* @Bin(outOrder = 2, type = BinType.INT)
* int type;
* @Bin(outOrder = 3, type = BinType.BYTE_ARRAY, extra = "expr:length")
@raydac
raydac / Arrow.java
Created December 6, 2015 19:03
Draw arrows in Java Swing
package com.presidentgame.game.utils;
import com.igormaznitsa.jhexed.engine.HexEngine;
import java.awt.Graphics2D;
import java.awt.Stroke;
import java.awt.geom.GeneralPath;
import java.awt.geom.Point2D;
public enum Arrow {;
@raydac
raydac / initscanner
Created October 7, 2015 07:12
Bash script to provide needed rights for USB port for Brother DCP-7055
#!/bin/bash
echo
echo The Script provides needed rights for USB port of a scanner
echo it was developed for MFC Brother DCP7055 to avoid 'invalid argument' error
echo
echo Author : Igor Maznitsa \(http://www.igormaznitsa.com\)
echo Version: 1.00
echo
@raydac
raydac / JHtmlLabel.java
Created August 25, 2015 11:35
an adaptation of javax.swing.JLabel to process clicks on links in HTML content
/*
* Copyright 2015 Igor Maznitsa.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software