Skip to content

Instantly share code, notes, and snippets.

View gcphost's full-sized avatar

William gcphost

  • Los Angeles, CA
View GitHub Profile
private function array_keys_multi(array $array)
{
$results = [];
foreach ($array as $key => $value) {
if (is_array($value)) {
$results = array_merge($results, [$key => array_merge(array_keys($value),$this->array_keys_multi($value))]);
}
}
return $results;
}
@gcphost
gcphost / LICENSE
Last active March 26, 2016 21:35
Laravel 5 PHPUnit SeeOrSaveJsonStructure Trait to automatically save json results then validate them.
The MIT License (MIT)
Copyright (c) 2016 William Bowman (gcphost@gmail.com, asked.io)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
<?php
Route::get('/', function () {
app('sanitizer')->register('reverse', function ($field) {
return strrev($field);
});
/** custom filter */
$validator = app('validator')->make(request()->all(), [
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
use \Illuminate\Database\Eloquent\SoftDeletes;
use \Askedio\SoftCascade\Traits\SoftCascadeTrait;
@gcphost
gcphost / Medium.php
Created May 7, 2016 04:45
Fetch Medium Stories with PHP
function fetchMedium($user, $slug = 'latest')
{
$client = new \GuzzleHttp\Client();
try {
$res = $client->request('GET', sprintf('https://medium.com/%s/%s?format=json', $user, $slug));
} catch (Exception $exception) {
return false;
}
@gcphost
gcphost / MediumStories.php
Last active May 7, 2016 07:12
Fetch Medium story list and story content
<?php
class MediumStories{
protected $user;
protected $slug;
protected $body;
public function __construct($user)
{
$this->user = $user;
}
<?php
/**
* Created by Will Bowman, 2016, twitter.com/asked_io & asked.io.
*/
$Cacher = new Cacher;
$Cacher->add('js/analytics.js', 'http://www.google-analytics.com/analytics.js');
$Cacher->fetch()->withErrors();
@gcphost
gcphost / ng2-facebook-class.ts
Last active September 15, 2017 20:47
A simple typescript class for Angular 2 to enable the facebook sdk and allow login.
import {BehaviorSubject} from 'rxjs/BehaviorSubject';
declare const FB: any;
export class Facebook {
private appId: string
public response = new BehaviorSubject<boolean>(false);
public data = this.response.asObservable();
@gcphost
gcphost / ng2-accountkit-class.ts
Created August 4, 2016 18:00
A simple Typescript class for Angular 2 and AccountKit login SDK
import {BehaviorSubject} from 'rxjs/BehaviorSubject';
declare const AccountKit: any;
interface LocalWindow extends Window {
AccountKit_OnInteractive(): void
}
declare var window: LocalWindow;