Skip to content

Instantly share code, notes, and snippets.

@0xMatt
0xMatt / RouterServiceProvider.php
Created January 15, 2015 20:56
RouteServiceProvider
<?php
namespace Lithe\Routing;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
class RouteServiceProvider extends ServiceProvider
{
/**
*
@0xMatt
0xMatt / Cache.php
Last active August 29, 2015 14:13
Cache Decoration
<?php
namespace Lithe\Database;
use Illuminate\Cache\CacheManager;
use Lithe\Contracts\Database\CacheInterface;
class Cache implements CacheInterface
{
/**
@0xMatt
0xMatt / FizzBuzz.php
Created January 24, 2015 15:16
PHP FizzBuzz
<?php header('Content-Type: text/plain');
for($i = 1; $i <= 100; $i++) {
$string = '';
$string .= ($i % 3) == 0 ? "fizz" : '';
$string .= ($i % 5) == 0 ? "buzz" : '';
print (empty($string)) ? $i : $string;
print PHP_EOL;
}
@0xMatt
0xMatt / form.php
Last active August 29, 2015 14:15
A basic form. Susceptible to csrf and no post/redirect/get implementation.
<?php
$errors = [];
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
// Set required fields
$required = [
'field_1',
'field_2'
];
@0xMatt
0xMatt / Answer.php
Last active August 29, 2015 14:15
Interview answer
<?php
function most_letters_in_a_word($string) {
$string = preg_replace("/[^A-Za-z]/", ' ', $string);
foreach(array_filter(explode(' ', $string)) as $word) {
$words[max(count_chars($word, 1))] = $word;
}
return $words[max(array_keys($words))];
@0xMatt
0xMatt / UserManagerTest.php
Last active August 29, 2015 14:16
User service test
<?php
use Lithe\Testing\TestCase;
class UserManagerTest extends TestCase
{
/**
*
* @var UserManager
*/
@0xMatt
0xMatt / cache.conf
Created June 28, 2015 22:59
nginx setup
# Expire rules for static content
# No default expire rule. This config mirrors that of apache as outlined in the
# html5-boilerplate .htaccess file. However, nginx applies rules by location,
# the apache rules are defined by type. A consequence of this difference is that
# if you use no file extension in the url and serve html, with apache you get an
# expire time of 0s, with nginx you'd get an expire header of one month in the
# future (if the default expire rule is 1 month). Therefore, do not use a
# default expire rule with nginx unless your site is completely static
<?php
class ImplementationTest extends TestCase
{
public function setUp()
{
parent::setUp();
$this->setUpDb();
}
@0xMatt
0xMatt / mortgageJavascript.html
Created January 31, 2016 23:24 — forked from anonymous/mortgageJavascript.html
theomega76PHP-HELL
<!DOCTYPE html>
<html>
<head>
<title>Theomega76| Mortgage Table with Inputs</title>
<meta charset="utf-8" />
<!-- Move to bottom later on for better performance -->
<script src="js/jquery-1.11.2.js"></script>
</head>
import {Component} from '@angular/core';
import {ROUTER_DIRECTIVES} from '@angular/router';
import '../style/app.scss';
import {ToasterContainerComponent, ToasterService} from 'angular2-toaster/angular2-toaster';
import {MenuComponent} from './layout/menu/menu.component';
import {ContentComponent} from './layout/content/content.component';
import {AuthService} from "./modules/auth/auth.service";
/*
* App Component