Skip to content

Instantly share code, notes, and snippets.

View SpiralAlgorithm.java
import javax.swing.JOptionPane;
/**
* @author aNNiMON
*/
public class SpiralAlgorithm {
private static enum Directions {
UP {
@Override
View MathAlgo.java
private int julery_isqrt(int val) {
int temp, g = 0, b = 0x8000, bshft = 15;
do {
if (val >= (temp = (((g << 1) + b) << bshft--))) {
g += b;
val -= temp;
}
} while ((b >>= 1) > 0);
return g;
}
@aNNiMON
aNNiMON / Java8Examples.java
Last active Aug 29, 2015
Java 8 examples
View Java8Examples.java
package com.app1;
import java.time.Duration;
import java.time.Instant;
import java.time.LocalDate;
import java.time.LocalTime;
import java.time.Month;
import java.time.Period;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
View HttpServer.java
package socket;
import java.net.ServerSocket;
import java.net.Socket;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.InputStreamReader;
import java.io.BufferedReader;
/**
@aNNiMON
aNNiMON / PrintJar.java
Created Apr 5, 2014
Java 8 print text based resource file inside a jar file. (eg: META-INF/MANIFEST.MF)
View PrintJar.java
package ztools;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Optional;
import java.util.jar.JarEntry;
import java.util.jar.JarFile;
/**
View MonitorBrightness.cs
public static ushort GetMonitorBrightness() {
using (var mclass = new ManagementClass("WmiMonitorBrightness")) {
mclass.Scope = new ManagementScope(@"\\.\root\wmi");
using (var instances = mclass.GetInstances()) {
foreach (ManagementObject instance in instances) {
return (byte) instance.GetPropertyValue("CurrentBrightness");
}
}
}
return 0;
@aNNiMON
aNNiMON / AlgorithmMarkov.java
Last active Aug 29, 2015
Алгоритм Маркова
View AlgorithmMarkov.java
package algorithmmarkov;
import java.util.ArrayList;
public class AlgorithmMarkov {
public static void main(String[] args) {
Rules rules4to2 = Rules.create()
.add("~0", "00~")
.add("~1", "01~")
@aNNiMON
aNNiMON / Activity.md
Last active Aug 29, 2015
Android Best Practices
View Activity.md

Activity

New Instance

public class ExampleActivity extends Activity {

    public static final String EXTRA_PRODUCT_ID = "product_id";
    public static final String EXTRA_PRODUCT_TITLE = "product_title";

    public static Intent newIntent(Context context, long productId, String productTitle) {
        final Intent intent = new Intent(context, ExampleActivity.class);
@aNNiMON
aNNiMON / Lang.class.php
Last active Aug 29, 2015
Php multlang support
View Lang.class.php
<?php
/**
* Класс работы с мультиязычностью.
*
* @author aNNiMON, web_demon
*/
final class Lang {
const PATH = 'lang/';
@aNNiMON
aNNiMON / JoinImage.java
Created Sep 26, 2014
Join Images by ARGB-array
View JoinImage.java
private BufferedImage joinHorizontally(BufferedImage[] img) {
// Считаем ширину всех картинок
int width = img[0].getWidth() * img.length;
//int width = 0;
//for (int i = 0; i < img.length; i++) width += img[i].getWidth();
// Создаём массив ARGB для полной картинки
final int[] all = new int[width*img[0].getHeight()];
for (int i = 0; i < img.length; i++) {
// Получаем пиксели очередной картинки