Skip to content

Instantly share code, notes, and snippets.

Avatar
😀
coding in TeX...

Yegor Bugayenko yegor256

😀
coding in TeX...
View GitHub Profile
@yegor256
yegor256 / quiz.java
Last active August 18, 2022 17:47
quiz.java
View quiz.java
/**
* Please review the class below and suggest improvements. How would
* you refactor this class if it would be in a real-life project?
* There are many problems here, both high-level design mistakes,
* and low-level implementation bugs. We're interested to see high-level
* problems first, since they are most critical. The more mistakes
* you can spot, the better programmer you are.
*/
/**
@yegor256
yegor256 / Agents.java
Last active February 18, 2022 19:02
Object-oriented dependency injection
View Agents.java
final Agent agent = new Agent.Iterative(
new Array<Agent>(
new Understands(
this.github,
new QnSince(
49092213,
new QnReferredTo(
this.github.users().self().login(),
new QnParametrized(
new Question.FirstOf(
@yegor256
yegor256 / keybase.md
Created May 2, 2016 16:44
keybase.md
View keybase.md

Keybase proof

I hereby claim:

  • I am yegor256 on github.
  • I am yegor256 (https://keybase.io/yegor256) on keybase.
  • I have a public key ASDIUlRwZERl47w7DgZXmyiI5INXc0pQyfYDd3aFsLWupAo

To claim this, I am signing this object:

@yegor256
yegor256 / document.php
Last active December 21, 2015 16:39
PHP user+document
View document.php
<?php
class Document {
public $user;
public $name;
public function init($name, User $user) {
assert(strlen($name) > 5);
$this->user = $user;
@yegor256
yegor256 / singleton.php
Created August 25, 2013 17:48
PHP singleton
View singleton.php
<?php
class DB1 {
protected static $_db;
public static function query($sql) {
return self::_connect()->mysql_query($sql);
}
protected static function _connect() {
if (!isset(self::$_db))
self::$_db = mysql_connect(/*... params ...*/);
return self::$_db;
View finder.php
class Code {
private Option[] options;
ctor(Option[] opts) {
this.options = opts;
}
public get() {
Result result = null;
for (opt in this.options) {
if (opt.matches()) {
result = opt.get();