Skip to content

Instantly share code, notes, and snippets.

@EugW
EugW / SimpleMap.kt
Created March 3, 2018 15:39
Kotlin simple map
class SimpleMap<in K, V> {
private var keys = ArrayList<K>()
private var values = ArrayList<V>()
operator fun get(key: K): V {
return values[keys.indexOf(key)]
}
operator fun set(key: K, value: V) {
registerReceiver(object : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
if ((intent.extras["networkInfo"] as NetworkInfo).state != NetworkInfo.State.CONNECTED) {
Toast.makeText(context, R.string.networkErr, Toast.LENGTH_LONG).show()
unregisterReceiver(this)
finish()
return
}
}
}, IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION))
@EugW
EugW / login.kt
Created May 21, 2018 15:42
kundelik login
package pro.eugw.lessoncountdown.dialog
import android.content.Context
import android.os.Bundle
import android.support.v4.app.DialogFragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.android.volley.RequestQueue
import com.android.volley.Response
@EugW
EugW / login.kt
Created May 21, 2018 15:45
kundelik login
package pro.eugw.lessoncountdown.dialog
import android.content.Context
import android.os.Bundle
import android.support.v4.app.DialogFragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import com.android.volley.RequestQueue
import com.android.volley.Response
@EugW
EugW / main.kt
Created September 29, 2019 09:21
SystemColorAndroid
val array = theme.obtainStyledAttributes(intArrayOf(android.R.attr.colorAccent))
val backgroundcolor = array.getColor(0, 0xFF00FF)
println(String.format("#%06X", (0xFFFFFF and backgroundcolor)))
@EugW
EugW / main.kt
Last active September 29, 2019 09:22
Language to TrainedData for Tesseract OCR
val langData = mapOf(
Pair("English", "eng.traineddata"),
Pair("Spanish", "spa.traineddata"),
Pair("Italian", "ita.traineddata"),
Pair("Russian", "rus.traineddata"),
Pair("Polish", "pol.traineddata"),
Pair("French", "fra.traineddata"),
Pair("German", "deu.traineddata"),
Pair("Portuguese", "por.traineddata"),
Pair("Japanese", "jpn.traineddata"),
@EugW
EugW / diff.sh
Created May 7, 2020 18:01
Differences in zip
echo "$1 vs $2"
mkdir temp/
unzip -q $1 -d temp/$1.d/
unzip -q $2 -d temp/$2.d/
cd temp
cd $1.d
find -type f > ../$1.txt
cd ..
cd $2.d
find -type f > ../$2.txt
@EugW
EugW / main.log
Created November 25, 2020 18:59
Лаб5/6 выполнение
----------------------------------------------
Address of int = 000000419718FAC4
Value of pointer to int = 1
Address of pointer to int = 000000419718FB28
Value of int = 1
Size of int = 4
Size of pointer to int = 8
----------------------------------------------
Address of char = 000000419718FAE4
Value of pointer to char = z
@EugW
EugW / main.c
Last active November 25, 2020 19:16
Лаб5/6
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// d)
char* getAlphabet() {
char* pAlp = malloc(26); //Выделение памяти
if (pAlp == NULL) {
printf("Cannot allocate memory");
return NULL;
@EugW
EugW / lab7.c
Last active December 22, 2020 10:04
Лаб7
#include <stdio.h> // Стандартный ввод/вывод
#include <stdlib.h> // Стандартная библиотека
#ifdef _WIN32
#define CLEAR_COMM "cls"
#else
#define CLEAR_COMM "clear"
#endif
typedef enum { // Перечисление типов ламп