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 / 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(" ", " ", $str);
@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 / 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 / README.md
Created January 27, 2019 15:36 — forked from bhstahl/README.md
A cli for launching/stopping Global Protect (and stopping it from auto-launching on restart)
  1. Create a folder to hold your custom bash commands
$ mkdir ~/.bin
  1. Download the vpn file above to that directory
curl https://gist.githubusercontent.com/bhstahl/a90d747683ea0598c673e42d7f5a8900/raw/75cf1751c315795619399ef0e6b53a0297af3040/vpn --output ~/.bin/vpn
@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 / backup.sh
Last active December 19, 2023 14:54
Automate your macOS backup to Backblaze B2 using Restic and launchd.
#!/bin/bash
PID_FILE=~/.restic_backup.pid
TIMESTAMP_FILE=~/.restic_backup_timestamp
if [ -f "$PID_FILE" ]; then
if ps -p $(cat $PID_FILE) > /dev/null; then
echo $(date +"%Y-%m-%d %T") "File $PID_FILE exist. Probably backup is already in progress."
exit 1
else