$ bb toolbox.clj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(ns compress | |
"Compress given string so that consecutive characters are grouped into | |
a character itself and number of repetitions if the count is more | |
than one: | |
(compress 'aaaBBccBDH') | |
'a3B2c2BDH' | |
(compress 'aaa') | |
'a3' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Copyright (c) 2024 Vitaly Samigullin | |
Permission is hereby granted, free of charge, to any person obtaining a copy | |
of this software and associated documentation files (the "Software"), to deal | |
in the Software without restriction, including without limitation the rights | |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
copies of the Software, and to permit persons to whom the Software is | |
furnished to do so, subject to the following conditions: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime, timedelta | |
from dateutil.relativedelta import relativedelta | |
# working hours: 10:00 to 18:59 | |
day_start = 0 | |
day_end = 23 | |
work_start = 10 | |
work_end = 18 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(def openning ["(" "[" "{"]) | |
(def closing [")" "]" "}"]) | |
(def parens (zipmap openning closing)) | |
(defn parens-balanced? | |
[s] | |
(loop [input-string s | |
stack []] | |
(if (empty? input-string) | |
(empty? stack) |
I hereby claim:
- I am pilosus on github.
- I am pilosus (https://keybase.io/pilosus) on keybase.
- I have a public key ASB_iFYud-BE_njrIsrogstPTQGd_qt15lJ9EpyO8ATWVAo
To claim this, I am signing this object:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Comment(db.Model): | |
"""Comment is a message under a post. | |
Comment that has a parent treated as a reply. Comment with replies | |
(children) represents n-ary tree. | |
""" | |
__tablename__ = 'comments' | |
id = db.Column(db.Integer, primary_key=True) | |
parent_id = db.Column(db.Integer, db.ForeignKey('comments.id')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.stepic.java.module5.animalSerialization; | |
import org.junit.Test; | |
import static org.junit.Assert.*; | |
/** | |
* Created by vitaly on 03/10/16. | |
*/ | |
public class AnimalTest { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.stepic.java.module5.animalSerialization; | |
import java.io.Serializable; | |
import java.io.*; | |
import java.util.Objects; | |
/** | |
* Created by vitaly on 03/10/16. | |
*/ | |
public class Animal implements Serializable { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package org.stepic.java.module5.serializationDemo; | |
import java.io.*; | |
import java.nio.file.Files; | |
import java.nio.file.Path; | |
import java.nio.file.Paths; | |
import java.time.LocalDate; | |
/** | |
* Created by vitaly on 03/10/16. |
NewerOlder