Skip to content

Instantly share code, notes, and snippets.

View cookavich's full-sized avatar
🎯
Focusing

Paul Cook cookavich

🎯
Focusing
View GitHub Profile
@cookavich
cookavich / feature-flag.service.ts
Created March 30, 2022 13:44
LaunchDarkly feature flag service in Angular using RxJS
import { Injectable, OnDestroy } from '@angular/core';
import { environment } from '@environments/environment';
import * as LaunchDarkly from 'launchdarkly-js-client-sdk';
import { LDFlagValue } from 'launchdarkly-js-client-sdk';
import { Observable, Subject } from 'rxjs';
import { map } from 'rxjs/operators';
@Injectable({
providedIn: 'root'
})
@cookavich
cookavich / SketchSystems.spec
Last active June 6, 2019 14:05
Promotion Stepper
Promotion Stepper
Step 1
select deals -> Deals Stepper
select new vendor -> New Vendor Stepper
Deals Stepper
Deals Step 2
next -> Deals Step 3
Deals Step 3
<?php
namespace App\Http\Controllers;
use Config;
use DB;
use Illuminate\Http\Request;
use App\Models\Quote;
use App\Models\QuoteOfTheDay;
class QuoteController extends Controller
{
/**
@cookavich
cookavich / laravel-cors.php
Created August 17, 2017 18:11 — forked from adamwathan/laravel-cors.php
Need to do something like this to serve APIs that are going to be consumed by JS clients.
<?php
App::before(function($request) {
if ($request->getMethod() == 'OPTIONS') {
$response = Response::make('', 204);
$response->header('Access-Control-Allow-Methods', 'GET, POST, PUT, OPTIONS');
$response->header('Access-Control-Allow-Origin', '*');
$response->header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, Authorization');
return $response;
}
@cookavich
cookavich / maxBy.php
Created August 17, 2017 18:10 — forked from adamwathan/maxBy.php
maxBy/minBy macros
<?php
Collection::macro('maxBy', function ($callback) {
$callback = $this->valueRetriever($callback);
return $this->reduce(function ($result, $item) use ($callback) {
if ($result === null) {
return $item;
}
return $callback($item) > $callback($result) ? $item : $result;
<?php
namespace App\Merge;
class Marge
{
protected $data = [];
public function setData($data)
{