Skip to content

Instantly share code, notes, and snippets.

@andiogenes
andiogenes / list.c
Last active March 16, 2018 04:00
Yet another doubly linked list
#include <stdio.h>
#include <stdlib.h>
// другие компиляторы могут потребовать особого хедера для работы с памятью
typedef struct {
int cnt;
char name[255];
} Data;
// SList фактически узел списка, доступ к списку осуществляется через указатель на узел
; Заяц
(define fib (lambda (n fib-1 fib-2)
(if (<= n 1)
(+ fib-1 fib-2)
(fib (- n 1) (+ fib-1 fib-2) fib-1)))
)
; Черепаха
(define slow-fib (lambda (n)
(if (equal? n 0)
@andiogenes
andiogenes / SExpParser.hx
Created March 24, 2018 02:30
Parser which represents string of s-expressions as list of strings and nested lists
import js.Browser;
import js.html.ButtonElement;
import js.html.TextAreaElement;
/**
* @author Anton
* s-expressions parser
*/
class Test

Как собрать PDCurses под VC++

Шаги:

  1. Скачиваем PDCurses (https://github.com/wmcbrine/PDCurses)
  2. Заходим в папку wincon, находим файл Makefile.vc
  3. Пишем в командной строке: (inline) nmake -f [path]Makefile.vc [DEBUG=] [DLL=] [WIDE=] [UTF8=] [target]
  4. Добавляем к проекту собранные файлы, подключаем заголовочные файлы (curses.h, panel.h, etc...)

P.S.: В папке demos есть исходный код нескольких демок curses, они собираются в бинарные файлы при удачной сборке через makefile.

@andiogenes
andiogenes / Game.hx
Created May 25, 2018 02:47
Platformer example code
package core;
import js.Browser;
import js.html.CanvasElement;
import js.html.CanvasRenderingContext2D;
/**
* ...
* @author Wookie
*/
class Game
@andiogenes
andiogenes / Raycaster.hx
Created May 25, 2018 04:01
Haxe written Raycaster based on lodev's tutorials
package;
import js.Browser;
import js.html.CanvasElement;
import js.html.CanvasRenderingContext2D;
import js.html.KeyboardEvent;
import js.Lib;
/**
* @name ОНО РАБОТАЕТ
let lnPrec x eps =
Seq.unfold (fun (s, n) ->
if (s/(float n) < eps) then None
else Some( (s, n), (s*(x-1.0)/x, n+1) )) ((x-1.0)/x, 1)
|> Seq.fold (fun acc (s, n) -> acc + s/(float n)) 0.0
let lnRange x range =
Seq.unfold (fun (s, n) ->
if (n > range) then None
else Some( (s, n), (s*(x-1.0)/x, n+1) )) ((x-1.0)/x, 1)
@andiogenes
andiogenes / .clang-format
Created September 28, 2019 07:18
My basic clang-format configuration
BasedOnStyle: LLVM
UseTab: Never
IndentWidth: 4
TabWidth: 4
BreakBeforeBraces: Linux
AllowShortIfStatementsOnASingleLine: false
IndentCaseLabels: false
ColumnLimit: 0
AccessModifierOffset: -4
NamespaceIndentation: All
@andiogenes
andiogenes / SuffixArrayLCP.kt
Created November 20, 2019 14:09
Slow but useful implementations of suffix array and LCP
fun naiveLCP(string: String): List<Int> {
val suffixes = makeSuffixArray(string)
val lcp = (suffixes.indices).map {
if (it - 1 < 0) {
0
} else {
string.substring(suffixes[it - 1]).commonPrefixWith(string.substring(suffixes[it])).length
}
}
return lcp
val alphabet = "ABC"
val randString = (1..Random.nextInt(0, 5))
.map { alphabet.random() }
.joinToString("")