Skip to content

Instantly share code, notes, and snippets.

@dkraczkowski
dkraczkowski / styled_text.py
Created September 7, 2023 09:17
Style your output in cli with this class
from __future__ import annotations
from enum import Enum
from typing import List, Union
class TextStyles(Enum):
OK = "\033[92m"
WARNING = "\033[93m"
FAIL = "\033[91m"
@dkraczkowski
dkraczkowski / runWatch.sh
Created August 16, 2018 13:55 — forked from osrec/runWatch.sh
Watch a particular directory for changes and kill and restart a process on change
# In the example below, the command we want to run is `php -f "$DIR/../run.php"` - change this on lines 30 and 46
# $DIR is just the directory containing this script file (computed automatically, but you can hardcode it if you want).
# Use $DIR to specify paths relative to the script's path.
# The PROCESS_NAME variable is the name of the process to kill and restart
# You must ensure your process has the same name each time it runs (we use a file at $DIR/../servername to store the name)
# Alternatively, you can hard code the PROCESS_NAME on line 15 if you like
#!/bin/bash
@dkraczkowski
dkraczkowski / php-hard-way.md
Last active February 9, 2024 20:24
PHP the hard way.md

PHP the hard way!

About you

This course is for humans only. To be more particular you are a human with some computer science knowledge (programming especially)- you know terms like: variable, constant, function, data type, array and you are quite comfortable with using your computer.

About this course

What the hard way means? More or less that I am not going to put here useless knowledge and tons of descriptions. Idea of this course is to go example by example with no or really small explanation. Each example is going to be your teacher. Your role is to play with examples, understand how it works and mix them up to solve concrete problem which is going to be raised at the en

@dkraczkowski
dkraczkowski / mc_test.php
Created January 19, 2017 15:34
Middleware Composer Test
<?php namespace OctopusTest;
use OctopusTest\Fixtures\DI\A;
use OctopusTest\Fixtures\DI\B;
use RuntimeException;
use Octopus\MiddlewareComposer;
use OctopusTest\TestCase;
class MiddlewareComposerTest extends TestCase
{
@dkraczkowski
dkraczkowski / php_middleware_composer.php
Last active August 19, 2017 17:01
PHP middleware composer
<?php namespace Octopus;
use \Closure;
class MiddlewareComposer
{
protected $pipe;
protected $context;
protected $errorHandler;
protected $successHandler;
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
/**
*
* Copyright (C) 2011 by crac <![[dawid.kraczkowski[at]gmail[dot]com]]>
* Thanks for Hardy Keppler<![[Keppler.H[at]online.de]]> for shortened version
*
* 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
/**
*
* Copyright (C) 2011 by crac <![[dawid.kraczkowski[at]gmail[dot]com]]>
* Thanks for Hardy Keppler<![[Keppler.H[at]online.de]]> for shortened version
*
* 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
@dkraczkowski
dkraczkowski / copy primitive object
Created August 3, 2014 11:17
javascript copy object
var util = require('util');
var isLiteral = require('./isLiteralObject');
function copyPrimitive(object) {
var copy;
if (typeof object !== 'object') {
return object;
}
if (isLiteral(object)) {