Skip to content

Instantly share code, notes, and snippets.

View evgkarasev's full-sized avatar
🎯
Focusing

Eugene Karasev evgkarasev

🎯
Focusing
View GitHub Profile
@evgkarasev
evgkarasev / pouring.scala
Created July 23, 2020 00:09
Case Study: the Water Pouring Problem
/**
* Case Study: the Water Pouring Problem
* https://www.coursera.org/learn/progfun2/lecture/EkEqR/lecture-2-5-case-study-the-water-pouring-problem
*
* @param capacity defines how many glasses the problem is and their capacity
* index = glass Id
* value = capacity of the glass in ml
*/
class Pouring(capacity: Vector[Int]) {
@evgkarasev
evgkarasev / README.md
Last active July 12, 2020 10:40
How to rotate a two dimensional array in javascript?

O(n^2) time and O(1) space algorithm

Rotate by +90:

  1. Transpose
  2. Reverse each row

Rotate by -90:

Method 1 :

@evgkarasev
evgkarasev / floodIt_Blocks.scala
Created May 16, 2020 09:29
Simple Scala / Swing Game
package floodIt
import floodIt._
case class Pos(val x: Int, val y: Int)
class Blocks(val width: Int, val height: Int) {
private val data = Array.ofDim[Int](width, height)
resetData()
// Create initial pattern
@evgkarasev
evgkarasev / ScalaCalcSheet_Arithmetic.scala
Last active May 16, 2020 09:20
SpreadSheet in Scala / Swing
package ScalaCalcSheet
import scala.math._
trait Arithmetic {
this: Evaluator =>
operations ++= List(
"sin" -> { case List(x) => sin(x) },
"cos" -> { case List(x) => cos(x) },
@evgkarasev
evgkarasev / dicee_main.dart
Created March 27, 2020 07:45
Dicee - simple app to learn Stateful Flutter widgets
import 'dart:math';
import 'package:flutter/material.dart';
void main() {
return runApp(
MaterialApp(
home: Scaffold(
backgroundColor: Colors.red,
appBar: AppBar(
backgroundColor: Colors.red,
@evgkarasev
evgkarasev / business_card_main.dart
Last active March 26, 2020 12:28
Simple Material UI App with Flutter Widgets
import 'package:flutter/material.dart';
void main() {
return runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
@evgkarasev
evgkarasev / install pihole
Created March 7, 2019 13:46 — forked from ridingintraffic/install pihole
recipe for pihole
PI install (scroll down for docker)
1. install raspbian lite
2. setup ssh
3. change hostname
4. set static ip on router, see why you changed the hostname now ;)
5. $ curl -sSL https://install.pi-hole.net | bash
6. follow the prompts and get everything turned on.
- set upstream DNS, google 8.8.8.8 or cloudflare 1.1.1.1
- use ipv4, ipv6 comes later
- enable the webinterface, we can script later
@evgkarasev
evgkarasev / readme.md
Last active February 20, 2024 02:44 — forked from noahcoad/readme.md
Code Minecraft with Python on Linux

Code Minecraft with Python on Linux

Here's a step-by-step to get started scripting Minecraft with Python on Linux

@evgkarasev
evgkarasev / minecraft_easy_start.py
Last active March 26, 2020 12:21
Start python commandline and start coding
#!/usr/bin/env python3
from mcpi.minecraft import Minecraft
# Подключаемся к серверу Minecraft - заменить SERVER_IP на реальный IP адрес сервера
mc = Minecraft.create('SERVER_IP')
# Пишем приветствие в чат
mc.postToChat("Hello world of Minecraft!")