Skip to content

Instantly share code, notes, and snippets.

View skrajewski's full-sized avatar

Szymon Krajewski skrajewski

View GitHub Profile
@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
@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
<?php
declare(strict_types=1);
class AmbiguousElementException extends \InvalidArgumentException
{
}
@skrajewski
skrajewski / output.md
Created May 31, 2021 07:04
Global object difference between Browser and Node

Output in Browser:

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

Output in Node:

@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);
@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 / 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 / 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 / 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
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"