Skip to content

Instantly share code, notes, and snippets.

View b3k's full-sized avatar

Bartosz Pietrzak b3k

  • CodeCargo
  • Poland
View GitHub Profile
@b3k
b3k / Pesel.class.php
Created April 18, 2012 14:49
Pesel Class - Class that extract data and validate PESEL number in object-oriented style
<?php
/**
* Class that validate and retrieve data from PESEL number in object-oriented style
*
* Example:
* $pesel = new Pesel('85042510356');
* $pesel->getBirthday()->format("d-m-Y")
* $pesel->getSex()
* $pesel->getAge("%a")
@b3k
b3k / Sort.class.php
Created August 1, 2013 13:40
Multiple sort implementations in one class
<?php
class Sort {
public static function radix_sort($input) {
$min = min($input);
$max = max($input);
$temp = array_fill($min, $max - $min + 1, 0);
foreach ($input as $key => $val) {
$temp[$val]++;
}
@b3k
b3k / mado.php
Last active December 20, 2015 19:28
Magento CLI tool for creating new module/model etc.. still in dev progressUse: php bin/mado.php create_module community/Namespace/ModuleNamephp mado.php create_symlinks /target/absolute/path /source/absolute/path [--dry-run]
#!/usr/bin/env php
<?php
$mado = new Mado();
try {
if (isset($argv[1]) && strlen($argv[1]) > 0) {
$mado->run($argv[1], array_slice($argv, 2));
} else {
$mado->run('help', null);
}
} catch (Exception $e) {
@b3k
b3k / getCheapestProductFromCategory.php
Created March 14, 2014 10:22
Get cheapest active product from given category.
<?php
class Product {
public function getCheapestProduct() {
$data = Mage::getModel("catalog/product")->getCollection()
->addAttributeToSelect(Mage::getSingleton("catalog/config")->getProductAttributes())
->addAttributeToFilter('offer', Mage_MultiVendor_Model_Offer::STATE_ACTIVE)
->addCategoryFilter($this->getCategory())
->setPage(1, 1)
->addMinimalPrice()
->addFinalPrice()

The introduction to Reactive Programming you've been missing

(by @andrestaltz)

So you're curious in learning this new thing called (Functional) Reactive Programming (FRP).

Learning it is hard, even harder by the lack of good material. When I started, I tried looking for tutorials. I found only a handful of practical guides, but they just scratched the surface and never tackled the challenge of building the whole architecture around it. Library documentations often don't help when you're trying to understand some function. I mean, honestly, look at this:

Rx.Observable.prototype.flatMapLatest(selector, [thisArg])

Projects each element of an observable sequence into a new sequence of observable sequences by incorporating the element's index and then transforms an observable sequence of observable sequences into an observable sequence producing values only from the most recent observable sequence.

This file has been truncated, but you can view the full file.
ProblemType: Crash
Architecture: amd64
CrashCounter: 1
Date: Tue Feb 14 14:50:13 2017
Disassembly:
=> 0x7f0badc47536 <match+6>: push %r12
0x7f0badc47538 <match+8>: mov %rdi,%r12
0x7f0badc4753b <match+11>: push %rbp
0x7f0badc4753c <match+12>: push %rbx
0x7f0badc4753d <match+13>: sub $0x1b8,%rsp
@b3k
b3k / Flexible Dockerized Phoenix Deployments.md
Created February 26, 2018 12:31 — forked from jswny/Flexible Dockerized Phoenix Deployments.md
A guide to building and running zero-dependency Phoenix (Elixir) deployments with Docker. Works with Phoenix 1.2 and 1.3.

Prelude

I. Preface and Motivation

This guide was written because I don't particularly enjoy deploying Phoenix (or Elixir for that matter) applications. It's not easy. Primarily, I don't have a lot of money to spend on a nice, fancy VPS so compiling my Phoenix apps on my VPS often isn't an option. For that, we have Distillery releases. However, that requires me to either have a separate server for staging to use as a build server, or to keep a particular version of Erlang installed on my VPS, neither of which sound like great options to me and they all have the possibilities of version mismatches with ERTS. In addition to all this, theres a whole lot of configuration which needs to be done to setup a Phoenix app for deployment, and it's hard to remember.

For that reason, I wanted to use Docker so that all of my deployments would be automated and reproducable. In addition, Docker would allow me to have reproducable builds for my releases. I could build my releases on any machine that I wanted in a contai

@b3k
b3k / ubuntu_agnoster_install.md
Created May 18, 2021 08:12 — forked from renshuki/ubuntu_agnoster_install.md
Ubuntu 16.04 + Terminator + Oh My ZSH with Agnoster Theme

Install Terminator (shell)

sudo add-apt-repository ppa:gnome-terminator
sudo apt-get update
sudo apt-get install terminator

Terminator should be setup as default now. Restart your terminal (shortcut: "Ctrl+Alt+T").

Install ZSH

The Freenode resignation FAQ, or: "what the fuck is going on?"

IMPORTANT NOTE:

It's come to my attention that some people have been spamming issue trackers with a link to this gist. While it's a good idea to inform people of the situation in principle, please do not do this. By all means spread the word in the communities that you are a part of, after verifying that they are not aware yet, but unsolicited spam is not helpful. It will just frustrate people.

Update 3 (May 24, 2021)

A number of things have happened since the last update.