Skip to content

Instantly share code, notes, and snippets.

------- Foo ---------
Expected: {
"under_me": [
{
"foo": "BAR"
},
{
"baz": "BAM"
}
]
@ukautz
ukautz / EncryptEnvCommand.php
Last active July 19, 2016 23:35
Laravel command to encrypt environment variable values for safe storage
<?php
// app/Console/Commands/EncryptEnvCommand.php
namespace Ictus\Hub\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Encryption\Encrypter;
use Symfony\Component\Console\Input\InputArgument;
@ukautz
ukautz / encrypt.php
Created September 1, 2015 16:12
Encrypt environment variables for safe storage
<?php
if ($argc < 2) fail();
switch ($argv[1]) {
case "genkey":
printKey();
break;
case "enc":
case "encrypt":
if ($argc != 4) fail();
@ukautz
ukautz / decrypt.php
Created September 1, 2015 16:13
Decrypt previously encrypted environment variables
<?php
$secEnv = [];
function bootstrapSecEnv($key) {
global $secEnv;
foreach ($_SERVER as $name => $value) {
if (is_string($value) && strpos($value, 'ENC:') === 0) {
$secEnv[$name] = decryptEnv($key, substr($value, 4));
}
@ukautz
ukautz / craft-security.patch
Created February 11, 2016 16:03
Dirty patch to fix signing of cookies with set `validationKey`
diff --git a/craft/app/etc/web/WebApp.php b/craft/app/etc/web/WebApp.php
index 7d68344..504007a 100644
--- a/craft/app/etc/web/WebApp.php
+++ b/craft/app/etc/web/WebApp.php
@@ -118,6 +118,7 @@ class WebApp extends \CWebApplication
if ($validationKey = $this->config->get('validationKey'))
{
$this->security->setValidationKey($validationKey);
+ $this->getComponent('securityManager')->setValidationKey($validationKey);
}
@ukautz
ukautz / workers-with-laravel-on-fortrabbit.md
Last active January 4, 2019 17:25
Workers with Laravel on fortrabbit

Workers with Laravel on fortrabbit

Use-case example: Making scheduled database backups using a Worker Cron Job.

Prerequisites

  • Setup Laravel locally
  • Create App on fortrabbit
@ukautz
ukautz / cert_load.go
Created March 2, 2016 18:55
Go: Load all .pem files containing private key and certificate(s) from directory
package common
import (
"crypto"
"crypto/ecdsa"
"crypto/rsa"
"crypto/tls"
"crypto/x509"
"encoding/pem"
"fmt"
@ukautz
ukautz / README.md.patch
Created June 13, 2016 14:23
Update for README to contain endpoint
diff --git a/README.md b/README.md
index b971bc8..0c1a433 100644
--- a/README.md
+++ b/README.md
@@ -40,11 +40,13 @@ $schemes = [
'StorageClass' => 'REDUCED_REDUNDANCY',
],
- 'protocol' => 'https', // Will be autodetected based on the current request.
+ 'protocol' => 'https', // Will be autodetected based on the current request.
@ukautz
ukautz / freeze-glide-versions.pl
Last active July 31, 2016 13:13
Perl script to insert all versions from glide.lock into glide.yaml for app unversioned packages
#!/usr/bin/perl
#
# Freezes all versions found in glide.lock by setting commiot as version in glide.yaml
# for each package which does not explicitly has a version
#
use strict;
use warnings;
@ukautz
ukautz / MY_Log.php
Created July 26, 2016 18:23
Code Igniter Logging
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
// Store in `application/libraries/MY_Log.php`
// this class is adapted from system/libraries/Log.php
/**
* CodeIgniter
*
* An open source application development framework for PHP 5.1.6 or newer
*