Skip to content

Instantly share code, notes, and snippets.

View martinkadlec0's full-sized avatar

Martin Kadlec martinkadlec0

View GitHub Profile
@martinkadlec0
martinkadlec0 / poly
Created February 27, 2012 18:29
Polynom operations
var a = "5x^5+3x^3-7x^2+4x+30";
var b = "8x^5+4x^4-2x^3-2x^2+4x";
function secti(a, b) {
var koefA = getKoef(a);
var koefB = getKoef(b);
var res = '', tmp;
for (var i=Math.max(koefA.length, koefB.length); i--;) {
if (koefA[i] && koefB[i] && (koefA[i] || 0) + (koefB[i] || 0)) {
tmp = koefA[i] + koefB[i];
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title></title>
<script src="scripts/libs/jquery.min.js"></script>
<script src="scripts/libs/underscore.min.js"></script>
<script src="scripts/libs/backbone.min.js"></script>
<script src="scripts/libs/backbone.marionette.min.js"></script>
<script>
Marionette.Region.prototype.open = function(view) {
this.$el.replaceWith(view.el);
};
Marionette.Region.prototype.realClose = Marionette.Region.prototype.close;
Marionette.Region.prototype.close = function(view) {
if (this.currentView) {
this.currentView.$el.replaceWith(this.$el);
this.realClose(view);
const fetchSaga = function* fetchSaga(action) {
// objScanned -> itemScanned as I assume that was a typo?
const itemScanned = yield call(scanProduct, action.payload.id);
const {id, user} = action.payload;
try {
const result = yield cps(AxusLogger.logScan, {id, user});
// Or like this if logScan needs AxusLogger context:
// const result = yield cps([AxusLogger, 'logScan'], {id, user});
dispatchScan(result);
@martinkadlec0
martinkadlec0 / tictactoe.ts
Last active December 21, 2023 12:13
Advent of Typescript - Day 21 - Tic Tac Toe
type TicTacToeChip = '❌' | '⭕';
type TicTacToeEndState = '❌ Won' | '⭕ Won' | 'Draw';
type TicTacToeState = TicTacToeChip | TicTacToeEndState;
type TicTacToeEmptyCell = ' '
type TicTacToeCell = TicTacToeChip | TicTacToeEmptyCell;
type TicTacToeYPositions = 'top' | 'middle' | 'bottom';
type TicTacToeXPositions = 'left' | 'center' | 'right';
type TicTacToePositions = `${TicTacToeYPositions}-${TicTacToeXPositions}`;
type TicTactToeBoard = TicTacToeCell[][];
type TicTacToeGame = {
@martinkadlec0
martinkadlec0 / maze.ts
Last active December 24, 2023 12:58
Advent of Typescript - Day 24 - Santa Maze
type Alley = " ";
type MazeItem = "🎄" | "🎅" | Alley;
type Maze = MazeItem[][]
type DELICIOUS_COOKIES = "🍪";
type MazeMatrix = MazeItem[][];
type Directions = "up" | "down" | "left" | "right";
type CoordState = 'win' | 'valid' | 'invalid'
type Inc<N extends number> = [
1,2,3,4,5,6,7,8,9,10,11,