Skip to content

Instantly share code, notes, and snippets.

@andiogenes
andiogenes / shell-here.el
Created March 20, 2025 05:17
Open shell in directory corresponding to buffer
(defun shell-here ()
"Create new shell rooted at default-directory and open it in
new window if there is no other shells associated with
default-directory, open existing shell otherwise."
(interactive)
(let* ((buffer-dir (directory-file-name (expand-file-name default-directory)))
(shell-buffer-name (concat "*shell*<" buffer-dir "/>")))
(shell shell-buffer-name)))
@andiogenes
andiogenes / foo.scala
Created February 18, 2025 07:44
Comments section of TASTy file
/** ScalaDoc for `object foo`. */
object foo {
/** This ScalaDoc will be listed. */
def foo = 42
// This comment won't be listed
def bar = 43
/** Multi-
* -line
@andiogenes
andiogenes / du-example.md
Created February 5, 2025 07:14
Пример того, как может выглядеть такое надмножество языка

Just a bit of syntactic sugar for Go's composition and methods.

Example

// Base class Foo
type foo class {
  (f) Test() {
    fmt.Println("foo!")
  }
}
@andiogenes
andiogenes / unroll.scala
Created July 12, 2024 04:04
Recursive inline in Scala 3
inline def unroll(inline times: Int)(inline action: Int => Unit): Unit =
if (times > 0)
action(times)
unroll(times - 1)(action)
unroll(4)(println)
// Emulating loop breaks with loop condition
object A {
def main(args: Array[String]) = {
val start = System.currentTimeMillis
val until = Int.MaxValue
var i = 0
var c = 0

Пример задач к контрольной работе

Арифметика

sh :: Double -> Double
sh x = undefined
final class AnyRefOption[T >: Null <: AnyRef] private(private val value: T) extends AnyVal {
def isEmpty = value == null
def isDefined: Boolean = !isEmpty
def get: T = value
def foreach[U](fn: T => U): Unit = {
if (isDefined) fn(value)
}
def let[U](fn: T => U) = if (isDefined) fn(value) else AnyRefOption(null)
@andiogenes
andiogenes / emacs.plugin.zsh
Last active December 13, 2022 08:37
Better Eshell experience with Oh My Zsh
# open eshell in terminal emacsclient
alias tesh="te --eval '(restart-eshell)'"
;; Enable Company in selected major modes
(let ((hooks '(java-mode-hook)))
(dolist (hook hooks)
(add-hook hook (lambda ()
(company-mode 1)))))
;;; Rebind 'GOTO beginning/end of buffer' to "C-M-v"
(defun edge-of-buffer ()
(interactive)
(if (and current-prefix-arg (eq current-prefix-arg '-))
(beginning-of-buffer) (end-of-buffer)))
(global-set-key (kbd "C-M-v") 'edge-of-buffer)