Skip to content

Instantly share code, notes, and snippets.

View gcphost's full-sized avatar

William gcphost

  • Los Angeles, CA
View GitHub Profile
@gcphost
gcphost / pretty-php-numbers.php
Last active July 18, 2024 08:25
Pretty PHP Numbers, convert a number to K, M, B, etc.
<?php
function human_number($number) {
$number = preg_replace('/[^\d]+/', '', $number);
if (!is_numeric($number)) {
return 0;
}
if ($number < 1000) {
@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;
@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();
<?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 / 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;
}
@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;
}
<?php
namespace App;
use Illuminate\Database\Eloquent\Model;
class User extends Model
{
use \Illuminate\Database\Eloquent\SoftDeletes;
use \Askedio\SoftCascade\Traits\SoftCascadeTrait;
@gcphost
gcphost / Http.routes.php
Last active April 20, 2018 15:43
Sanitize input with Laravel 5 Validator https://github.com/Askedio/laravel-validator-filter
<?php
Route::get('/', function () {
app('sanitizer')->register('reverse', function ($field) {
return strrev($field);
});
/** custom filter */
$validator = app('validator')->make(request()->all(), [
@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: