Skip to content

Instantly share code, notes, and snippets.

@awei01
awei01 / not_dry_fake_test
Created February 26, 2014 20:51
some fake testing code that is not dry because i'm faking methods
<?php
// class definitions
abstract class AbstractFactory {
protected function makeWidget()
{
return new Widget;
}
}
class FactoryOne extends AbstractFactory {
@awei01
awei01 / Mockery throws "must be instance of" exception when it shouldn't
Last active August 29, 2015 13:56
Also posted here (http://stackoverflow.com/questions/22104314/php-mockery-throwing-unexpected-must-implement-interface-exception-when-functi). I'm using Mockery to unit test an admittedly edge case. It's failing and I don't think it should fail, so there could be a bug within Mockery. Consider an object that has a method. The method has an argum…
<?php
use PHPUnit_Framework_TestCase;
use Mockery;
class SomeTest extends PHPUnit_Framework_TestCase {
function testRealFooObject_BarImplementation_NotThrowingException()
{
$foo = new FooObject;
@awei01
awei01 / BarDependencyServiceProvider.php
Last active August 29, 2015 13:57
Example detailing Laravel ServiceProvider registration error. Refer to this issue: https://github.com/laravel/framework/issues/2760
<?php
use Illuminate\Support\ServiceProvider;
class BarDependencyServiceProvider extends ServiceProvider {
public $defer = true;
public function register()
{
@awei01
awei01 / react-broken.spec.js
Created April 21, 2014 23:24
Code sample of my test that is breaking when I don't think it should.
/** @jsx React.DOM */
'use strict';
describe('sample test', function() {
var Broken, Working;
beforeEach(function() {
Broken = React.createClass({
@awei01
awei01 / some-file.js
Last active September 5, 2015 22:09
Astronomy Validators: Am I missing something really simple?
Model = Astro.createClass({
name: "Model",
fields: {
height: "number",
}
});
Model.addValidator('height', Validators.number());
if (Meteor.isClient) {
Template.hello.events({

Define a simple property

Access in template is provided via property name

HTML

<template name="parent">
	parent template

Some simple helper method

Using a method

HTML

<template name="parent">
	<h2>parent template</h2>
	{{ simpleMethod }}
<head>
	<title>9tailors Admin</title>
</head>
<body>
	{{| > header }}

	{{ foo.bar }}

	{{ foo.baz }}
@awei01
awei01 / cerebral_example.js
Created May 29, 2016 05:41
example for issue on cerebral
const controller = Controller(Model({}));
function setFoo({ input, state }) {
state.set('example.foo', input.value);
}
const changeInput = [setFoo];
const Module = (options = {}) => {
return (module, controller) => {
module.addState({
foo: "original value"
@awei01
awei01 / defaults.json
Last active February 24, 2017 17:49
Default sublimetext 3
// go here to install package control
// https://packagecontrol.io/installation
// install Babel
// install Sass
{
"always_show_minimap_viewport": true,
"binary_file_patterns":
[
"*.sqlite",