Skip to content

Instantly share code, notes, and snippets.

View skrajewski's full-sized avatar

Szymon Krajewski skrajewski

View GitHub Profile
@skrajewski
skrajewski / EAN13.php
Created July 29, 2014 07:33
Class EAN13
class EAN13 {
protected $code;
public function __construct($code)
{
if (preg_match("/^[0-9]{12}$/", $code))
{
$this->code = $code . $this->calculateChecksumNumber($code);
}
@skrajewski
skrajewski / resolutions.txt
Created November 22, 2014 08:06
Screen resolutions
1920x1200
1920x1080
1680x1050
1600x900
1440x900
1366x768
1360x768
1280x1024
1280x800
1280x720
@skrajewski
skrajewski / Gulpfile.js
Created March 29, 2016 10:14
Gulpfile.js with browserify and external vendor file
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var browserify = require('browserify');
var watchify = require('watchify');
var babelify = require('babelify');
var assign = require('lodash.assign');
var gutil = require('gulp-util');
var chalk = require('chalk');
@skrajewski
skrajewski / Dog.php
Created November 10, 2016 21:42
Create instance of me!
<?php
class Dog {
private $dog;
public function __construct(Dog $dog)
{
$this->dog = $dog;
}
@skrajewski
skrajewski / backup.sh
Created October 1, 2017 09:59
Mirror local files to encrypted Cryptomator's vault
#!/bin/sh
CRYPTOMATOR_PATH="/usr/local/bin/cryptomator-cli.jar"
DIR_TO_SYNC_PATH="$HOME/Private"
MOUNT_PATH="$HOME/VAULT_$RANDOM"
VAULT_PATH="$HOME/PATH/TO/ENCRYPTED/VAULT"
VAULT_PASSWORD="`security find-generic-password -a KEYCHAIN_ENTRY_VAULT_PASSPHRASE -w`"
VAULT_NAME="vault"
BIND_HOST="localhost"
BIND_PORT="8198"
@skrajewski
skrajewski / keybase.md
Last active September 16, 2019 16:31
Keybase proof

Keybase proof

I hereby claim:

  • I am skrajewski on github.
  • I am skrajewski (https://keybase.io/skrajewski) on keybase.
  • I have a public key ASCSI-KUF183sZkTmzIqlLncVTha8L0s27RxQvMHK-vQIwo

To claim this, I am signing this object:

@skrajewski
skrajewski / README.md
Created April 27, 2018 09:13 — forked from chadrien/README.md
Debug PHP in Docker with PHPStorm and Xdebug

Debug your PHP in Docker with Intellij/PHPStorm and Xdebug

  1. For your local dev, create a Dockerfile that is based on your production image and simply install xdebug into it. Exemple:
FROM php:5

RUN yes | pecl install xdebug \
&amp;&amp; echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" &gt; /usr/local/etc/php/conf.d/xdebug.ini \
@skrajewski
skrajewski / pipe.js
Created March 18, 2021 10:33
Simple middleware processor
const pipe = async (stack, context) => {
const execute = (context) => {
let prevIndex = -1;
const runner = async (innerContext, index) => {
if (index == prevIndex) {
throw new Error('next() called more than once');
}
prevIndex = index;
@skrajewski
skrajewski / play.js
Last active March 18, 2021 13:24
Class or function. What is better?
const stackA = new Stack();
stackA.push("abc");
stackA.push("xyz");
console.log(stackA.stack);
stackA.stack = [];
console.log(stackA.stack);
const stackB = createStack()
stackB.push("abc");
stackB.push("xyz");
@skrajewski
skrajewski / removeNbps.php
Last active April 9, 2021 11:19
Replace non-breaking spaces with normal spaces
/**
* Replace non-breaking spaces with normal spaces
*
* @param $str
* @return string
*/
public function removeNbsp($str)
{
$str = htmlentities($str);
$str = str_replace("&nbsp;", " ", $str);