Skip to content

Instantly share code, notes, and snippets.

Avatar

Szymon Krajewski skrajewski

View GitHub Profile
@skrajewski
skrajewski / output.md
Created May 31, 2021
Global object difference between Browser and Node
View output.md

Output in Browser:

undefined
undefined
{test: "abcd"}
"abcd"

Output in Node:

@skrajewski
skrajewski / play.js
Last active Mar 18, 2021
Class or function. What is better?
View play.js
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 / pipe.js
Created Mar 18, 2021
Simple middleware processor
View pipe.js
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;
View AmbiguousElementException.php
<?php
declare(strict_types=1);
class AmbiguousElementException extends \InvalidArgumentException
{
}
@skrajewski
skrajewski / backup.sh
Last active Sep 18, 2021
Automate your macOS backup to Backblaze B2 using Restic and launchd.
View backup.sh
#!/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
@skrajewski
skrajewski / keybase.md
Last active Sep 16, 2019
Keybase proof
View keybase.md

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 Jan 27, 2019 — forked from bhstahl/README.md
A cli for launching/stopping Global Protect (and stopping it from auto-launching on restart)
View README.md
  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 / README.md
Created Apr 27, 2018 — forked from chadrien/README.md
Debug PHP in Docker with PHPStorm and Xdebug
View README.md

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 \
    && echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
@skrajewski
skrajewski / backup.sh
Created Oct 1, 2017
Mirror local files to encrypted Cryptomator's vault
View backup.sh
#!/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 / Dog.php
Created Nov 10, 2016
Create instance of me!
View Dog.php
<?php
class Dog {
private $dog;
public function __construct(Dog $dog)
{
$this->dog = $dog;
}