Skip to content

Instantly share code, notes, and snippets.

View mCzolko's full-sized avatar

Michael Czolko mCzolko

View GitHub Profile
@mCzolko
mCzolko / oracle.acconut
Created February 1, 2015 22:49
Oracle account
Username: [email protected]
Password: Heslo1234
@mCzolko
mCzolko / PersistLotEntitiesCommand.php
Created August 23, 2015 00:25
Base Command object for saving huge amout of entities to prevent memory leaks.
<?php
namespace Acme\DemoBundle\Command;
use Doctrine\ORM\EntityManager;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
abstract class PersistLotEntitiesCommand extends ContainerAwareCommand
<?php
namespace Duedil\Bundle\AppBundle\Command;
use Doctrine\ORM\EntityManager;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
abstract class PersistALotOfEntitiesCommand extends Command
<?php
class DateTimeHelper {
/**
* @param array $dateintervals Array of \DateInterval
* @return \DateInterval
*/
public function calculateIntervalAverage($dateintervals)
{
@mCzolko
mCzolko / ChainCommand.php
Last active October 22, 2015 19:50
It serves purpose decoupling logic into multiple Symfony2 commands and executing one after another.
<?php
namespace Railhard\ImportBundle\Command;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
abstract class ChainCommand extends Command
{
@mCzolko
mCzolko / warmup.js
Last active January 5, 2016 18:22
HackerRank
// Solution for:
// Simple Array Sum
// A Very Big Sum
function main() {
var n = parseInt(readLine());
arr = readLine().split(' ');
console.log(arr.map(Number).slice(0, n).reduce( (a, b) => a + b ));
}
// Staircase
@mCzolko
mCzolko / swipe.js
Last active August 4, 2016 17:41
Swipe javascript handler
document.addEventListener('touchmove', handleTouchMove, false)
document.addEventListener('touchend', handleTouchEnd, false)
class Position {
constructor(x, y) {
this.x = x
this.y = y
}
@mCzolko
mCzolko / font-responsive.scss
Created December 14, 2016 11:02
responsive font in specific viewport sizes
@mixin font-resposive($font-from, $font-to, $media-from, $media-to) {
@media screen and (max-width: $media-from) {
font-size: $font-from + 0px;
&:before { content: $font-from + ''; }
}
$iteration-count: $font-to - $font-from;
$divider: ($media-to - $media-from) / $iteration-count;
@mCzolko
mCzolko / undoable.js
Created October 23, 2018 15:12
Redux Immutable Undo with diffs instead of saving whole state.
import { Map, List } from 'immutable';
const diff = require('immutablediff');
const patch = require('immutablepatch');
export const ActionTypes = {
UNDO: 'undoable/UNDO',
REDO: 'undoable/REDO',
LOAD: 'undoable/LOAD',
CLEAR_PAST: 'undoable/CLEAR_PAST',
};
const CANVAS_WIDTH = 1000;
const CANVAS_HEIGHT = 800;
function resizeImage(imageWidth, imageHeight) {
const ratio = imageWidth / imageHeight;
let width = CANVAS_WIDTH;
let height = width / ratio;
if (height > CANVAS_HEIGHT) {
height = CANVAS_HEIGHT;