Skip to content

Instantly share code, notes, and snippets.

View antonmedv's full-sized avatar

Anton Medvedev antonmedv

View GitHub Profile
@antonmedv
antonmedv / ActiveRecord.php
Created October 22, 2017 07:43
Facade in Symfony
<?php
namespace AppBundle\Entity;
use AppBundle\DependencyInjection\Container;
class ActiveRecord extends Container
{
protected static function getDoctrine()
{
@antonmedv
antonmedv / main.c
Created September 15, 2017 07:29
Sieve of Eratosthenes (bit array optimized)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define LIMIT 23e9
typedef unsigned char word_t;
int check(word_t *primes, uint64_t i)
{
@antonmedv
antonmedv / check.php
Created June 19, 2017 08:40
Check SSH multiplexing initialization
<?php
$host = 'beta'; // WRITE YOU HOSTNAME HERE
$run = function ($cmd, $write = '') {
static $i = 0;
$i++;
$descriptors = array(
array("pipe", "r"),
array("pipe", "w"),
array("pipe", "w")
%{ var indents = [0], indent = 0, dedents = 0 %}
%lex
DecimalDigit [0-9]
DecimalDigits [0-9]+
NonZeroDigit [1-9]
OctalDigit [0-7]
HexDigit [0-9a-fA-F]
UnicodeIdentifierStart [\xaa\xb5\xba\xc0-\xd6\xd8-\xf6\xf8-\u02c1\u02c6-\u02d1\u02e0-\u02e4\u02ec\u02ee\u0370-\u0374\u0376\u0377\u037a-\u037d\u0386\u0388-\u038a\u038c\u038e-\u03a1\u03a3-\u03f5\u03f7-\u0481\u048a-\u0527\u0531-\u0556\u0559\u0561-\u0587\u05d0-\u05ea\u05f0-\u05f2\u0620-\u064a\u066e\u066f\u0671-\u06d3\u06d5\u06e5\u06e6\u06ee\u06ef\u06fa-\u06fc\u06ff\u0710\u0712-\u072f\u074d-\u07a5\u07b1\u07ca-\u07ea\u07f4\u07f5\u07fa\u0800-\u0815\u081a\u0824\u0828\u0840-\u0858\u08a0\u08a2-\u08ac\u0904-\u0939\u093d\u0950\u0958-\u0961\u0971-\u0977\u0979-\u097f\u0985-\u098c\u098f\u0990\u0993-\u09a8\u09aa-\u09b0\u09b2\u09b6-\u09b9\u09bd\u09ce\u09dc\u09dd\u09df-\u09e1\u09f0\u09f1\u0a05-\u0a0a\u0a0f\u0a10\u0a13-\u0a28\u0a2a-\u0a30\u0a32\u0a33\u0a35\u0a36\u0a38\u0a39\u0a59-\u0a5c\u0a5e\u0a72-\u0a74\u0a85-\u0a8d\u0a8f-\u0a91\u0a93-\u0aa8\u0a
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import TodoItem from './TodoItem'
import Footer from './Footer'
import { SHOW_ALL, SHOW_COMPLETED, SHOW_ACTIVE } from '../constants/TodoFilters'
const TODO_FILTERS = {
[SHOW_ALL]: () => true,
[SHOW_ACTIVE]: todo => !todo.completed,
[SHOW_COMPLETED]: todo => todo.completed
@antonmedv
antonmedv / foo.coffee
Created May 18, 2017 06:20
CoffeeScript with Tree Shaking
export foo = 'foo'
export unused = -> foo
@antonmedv
antonmedv / extends.js
Last active June 2, 2016 13:59
Monkberry v4
import AppView from './AppView.monk';
export class App extends AppView {
construction() {
this.state = {...};
}
update(data) {
// Do something...
Object.assign(this.state, data);
@antonmedv
antonmedv / monkberry.js
Created June 26, 2015 11:40
Monkberry and Temple generated templates
(function (monkberry, filters, document, undefined) {
monkberry.mount({
"average_prices": function () {
// Create elements
var a0 = document.createElement('a'),
p1 = document.createElement('p'),
text2 = document.createTextNode(""),
for0 = document.createComment('for'),
children0 = {},
div3 = document.createElement('div');
@antonmedv
antonmedv / async_dom_loaded.js
Created June 10, 2015 12:06
Async DOM Content Loaded
/**
* Async DOM Content Loaded
*/
function onAsyncDOMContentLoaded(callback) {
if (document.readyState == 'loading') {
document.addEventListener('DOMContentLoaded', callback);
} else {
callback();
}
@antonmedv
antonmedv / inception.php
Created February 25, 2015 07:12
We need to go deeper.
<?php
$dream = 'Unicorn';
${'3 level'} = 'dream';
${'2 level'} = '3 level';
${'1 level'} = '2 level';
$DiCaprio = '1 level';
echo $$$$$DiCaprio;
// http://3v4l.org/RiB8b