Skip to content

Instantly share code, notes, and snippets.

View msfrms's full-sized avatar
🏠
Working from home

Mikhail Radaev msfrms

🏠
Working from home
View GitHub Profile
@msfrms
msfrms / MyAnalyzer
Created February 14, 2021 15:21 — forked from pcdinh/MyAnalyzer
Custom Lucene analyzer
import java.io.*;
import org.apache.lucene.analysis.*;
import org.apache.lucene.util.Version;
public class MyAnalyzer extends Analyzer {
public TokenStream tokenStream(String fieldName, Reader reader) {
return
new StopFilter(
true,
@msfrms
msfrms / build.sbt
Created December 14, 2020 06:07 — forked from channingwalton/build.sbt
Scala 2.13 compiler flags
val scalacOptions ++= Seq(
"-encoding",
"utf-8", // Specify character encoding used by source files.
"-deprecation", // Emit warning and location for usages of deprecated APIs.
"-explaintypes", // Explain type errors in more detail.
"-feature", // Emit warning and location for usages of features that should be imported explicitly.
"-language:existentials", // Existential types (besides wildcard types) can be written and inferred
"-language:experimental.macros", // Allow macro definition (besides implementation and application)
"-language:higherKinds", // Allow higher-kinded types
"-language:implicitConversions", // Allow definition of implicit functions called views
@msfrms
msfrms / scalac-compiler-flags-2.13.sbt
Created December 14, 2020 02:09 — forked from tabdulradi/scalac-compiler-flags-2.13.sbt
Scala Compiler flags for 2.13. Based on Tpolecat's 2.12 version
scalacOptions ++= Seq(
"-deprecation", // Emit warning and location for usages of deprecated APIs.
"-encoding", "utf-8", // Specify character encoding used by source files.
"-explaintypes", // Explain type errors in more detail.
"-feature", // Emit warning and location for usages of features that should be imported explicitly.
"-language:existentials", // Existential types (besides wildcard types) can be written and inferred
// "-language:experimental.macros", // Allow macro definition (besides implementation and application). Disabled, as this will significantly change in Scala 3
"-language:higherKinds", // Allow higher-kinded types
// "-language:implicitConversions", // Allow definition of implicit functions called views. Disabled, as it might be dropped in Scala 3. Instead use extension methods (implemented as implicit class Wrapper(va
@msfrms
msfrms / 1 - scalac options 2.13.scala
Created December 14, 2020 02:09 — forked from guilgaly/1 - scalac options 2.13.scala
Scala compiler options I typically use
val scalacOptions = Seq(
"-encoding",
"utf-8", // Specify character encoding used by source files.
"-Ybackend-parallelism", //
"8",
"-explaintypes", // Explain type errors in more detail.
"-feature", // Emit warning and location for usages of features that should be imported explicitly.
"-unchecked", // Enable additional warnings where generated code depends on assumptions.
"-Xcheckinit", // Wrap field accessors to throw an exception on uninitialized access.
// "-Ymacro-annotations", // Enable support for macro annotations, formerly in macro paradise.
@msfrms
msfrms / open_connect_auto.sh
Last active October 28, 2020 01:35
open_connect.sh
#!/bin/sh
# Должны быть установлены:
# brew (установить можно через скрипт /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)")
# brew install openconnect
# brew install oath-toolkit
# сохранить скрипт в файл vpn.sh
# перед запуском делаем chmod +x vpn.sh
# запускаем sudo vpn.sh
@msfrms
msfrms / postgresql-set-id-seq.sql
Created September 20, 2020 05:10 — forked from henriquemenezes/postgresql-set-id-seq.sql
PostgreSQL set Next ID Sequence Value to MAX(id) from Table
-- Get Max ID from table
SELECT MAX(id) FROM table;
-- Get Next ID from table
SELECT nextval('table_id_seq');
-- Set Next ID Value to MAX ID
SELECT setval('table_id_seq', (SELECT MAX(id) FROM table));
class GoodsListViewController: UIViewController {
struct ViewModel {
struct Goods {}
let prev: [Goods]
let current: Goods
let next: [Goods]
}
private var items: [ViewModel.Goods] = []
private let tableView: UITableView = UITableView(frame: .zero, style: .grouped)
class GoodsListViewController: UIViewController {
struct Goods {}
private var items: [Goods] = []
private let tableView: UITableView = UITableView(frame: .zero, style: .grouped)
func update(goods: [Goods]) {
items = goods
tableView.reloadData()
}
class LoginViewController: UIViewController {
struct ViewModel {
enum Status {
case inProgress
case failed(String, login: Command)
case login(Command)
}
let email: String
let password: String
let status: Status
class LoginViewController: UIViewController {
struct ViewModel {
let email: String
let password: String
let error: String
let isLoading: Bool
let login: () -> Void
}
private let activityIndicator = UIActivityIndicatorView()