Skip to content

Instantly share code, notes, and snippets.

View ryun's full-sized avatar
🤘

Ryun Shofner ryun

🤘
View GitHub Profile
@ryun
ryun / CronManagerCommand.php
Created April 20, 2017 00:03
Add and remove cron entry for scheduler.
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Process;
class CronManagerCommand extends Command
{
@ryun
ryun / README.MD
Last active March 1, 2017 22:16
Add keys on startup

INSTALL

curl -o ~/Library/LaunchAgents/ssh.add.a.plist https://gist.githubusercontent.com/ryun/556a852b39d30909a6ed1c45101f22c6/raw/55ce45ff58212ca85c1d84c0edab36e398538136/ssh.add.a.plist
@ryun
ryun / retry.php
Created October 19, 2016 23:31
Retry without using goto
<?php
if (! function_exists('retry')) {
function retry(callable $callback, $times = 3, $sleep = 3)
{
$attempts = 0;
do {
try
{
return $callback();

Caching issues

Update /etc/nginx/nginx.conf to have sendfile off;

Then find the location of opcache.so (/usr/lib/php5/20131226/opcache.so):

sudo find / -name 'opcache.so'
Verifying that +ryun33 is my blockchain ID. https://onename.com/ryun33
@ryun
ryun / RedisHandler.php
Last active August 29, 2015 14:24
Monolog Redis Setup
<?php namespace App\Core\Logs;
use DateTime;
use Illuminate\Redis\Database;
use Monolog\Formatter\JsonFormatter;
use Monolog\Handler\AbstractProcessingHandler;
use Monolog\Logger;
/**
* Logs to a Redis key using rpush
var customFilterData = {};
$('#data-table')
.on('preXhr.dt', function ( e, settings, d )
{
d.page = Math.ceil(d.start / d.length) + 1;
if ( d.page <= 1 ) d.page = 1;
for (var i in customFilterData)
@ryun
ryun / keybase.md
Last active August 29, 2015 14:19

Keybase proof

I hereby claim:

  • I am ryun on github.
  • I am ryuns (https://keybase.io/ryuns) on keybase.
  • I have a public key whose fingerprint is 93AC E767 402D 762A 16B7 327E E847 F29B 3C7A BFB9

To claim this, I am signing this object:

<?php
Event::listen('illuminate.query', function($query, $bindings, $time, $name)
{
$data = compact('bindings', 'time', 'name');
// Format binding data for sql insertion
foreach ($bindings as $i => $binding)
{
if ($binding instanceof \DateTime)
{

Event Sourcing (ES) & Command Query Responsibility Segregation (CQRS)

Event Sourcing allows you to store all the domain events that affect an entity, and replay these events to restore the object’s state.

The fundamental idea of Event Sourcing is that of ensuring every change to the state of an application is captured in an event object, and that these event objects are themselves stored in the sequence they were applied for the same lifetime as the application state itself.

Practical Event Sourcing (Video & Slides)

ES - Overview & Diagrams