Skip to content

Instantly share code, notes, and snippets.

View acmi's full-sized avatar

Aleksey Sazonov acmi

View GitHub Profile
import android.content.Context;
import android.net.wifi.WifiManager;
import android.os.Handler;
import android.os.Looper;
import android.text.format.Formatter;
import android.util.Log;
import android.widget.Toast;
import java.io.BufferedReader;
import java.io.IOException;
#include <windows.h>
void DumpFile()
{
typedef void (__cdecl *f_appLoadFileToArray)(char *, wchar_t *, int);
typedef void (__cdecl *f_appSaveArrayToFile)(char *, wchar_t *, int);
f_appLoadFileToArray appLoadFileToArray = (f_appLoadFileToArray)GetProcAddress(GetModuleHandleA("Core.dll"), "?appLoadFileToArray@@YAHAAV?$TArray@E@@PBGPAVFFileManager@@@Z");
f_appSaveArrayToFile appSaveArrayToFile = (f_appSaveArrayToFile)GetProcAddress(GetModuleHandleA("Core.dll"), "?appSaveArrayToFile@@YAHABV?$TArray@E@@PBGPAVFFileManager@@@Z");
@acmi
acmi / JustifyTextView.java
Created June 29, 2016 11:01
Android text justify
import android.content.Context;
import android.graphics.Canvas;
import android.text.Layout;
import android.text.StaticLayout;
import android.util.AttributeSet;
import android.widget.TextView;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@acmi
acmi / AutoCompleteComboBox.java
Created May 18, 2016 16:51
Auto comple ComboBox for JavaFX.
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.event.EventHandler;
import javafx.scene.control.ComboBox;
import javafx.scene.input.KeyCode;
import javafx.scene.input.KeyEvent;
import java.util.function.BiPredicate;
import java.util.stream.Collectors;
@acmi
acmi / T1.java
Created April 27, 2016 06:13
roads sql
import engine.osm.xml.Node;
import engine.osm.xml.Way;
import org.apache.commons.compress.compressors.bzip2.BZip2CompressorInputStream;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBElement;
import javax.xml.bind.Unmarshaller;
import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.events.XMLEvent;
public static int log2(int bits) {
int log = 0;
if (bits >= 0x10000) {
bits >>>= 16;
log = 16;
}
if (bits >= 0x100) {
bits >>>= 8;
log += 8;
}
@acmi
acmi / UnrealScript.g4
Created April 14, 2016 06:35
UnrealScript antlr4 grammar
grammar UnrealScript;
program : classdecl
( declarations | replicationblock | body)*
( defaultpropertiesblock )?
;
// CLASS
classdecl : CLASS identifier ( EXTENDS packageidentifier )? ( classparams )* ';';
classparams : constclassparams
| WITHIN packageidentifier
@acmi
acmi / ObservableBase.java
Created February 11, 2016 08:34
simple Observable non thread safe implementation
import javafx.beans.InvalidationListener;
import javafx.beans.Observable;
import java.util.HashSet;
import java.util.Set;
public abstract class ObservableBase implements Observable {
private Set<InvalidationListener> listeners = new HashSet<>(1);
@Override
@acmi
acmi / VKAuth.groovy
Last active October 18, 2016 01:02
VK auth javafx app
import javafx.application.Application
import javafx.application.Platform
import javafx.beans.InvalidationListener
import javafx.beans.Observable
import javafx.scene.Scene
import javafx.scene.web.WebView
import javafx.stage.Stage
class VKAuth extends Application{
private static final String REDIRECT_URI = 'https://oauth.vk.com/blank.html'
import javafx.application.Application;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.geometry.HPos;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.layout.ColumnConstraints;
import javafx.scene.layout.GridPane;