Skip to content

Instantly share code, notes, and snippets.

Avatar
🏞️
Working from home

Whizark whizark

🏞️
Working from home
View GitHub Profile
@whizark
whizark / InterfaceAndTrait.php
Last active Aug 29, 2015
Interface and Trait #test #php
View InterfaceAndTrait.php
<?php
interface FlyableThingInterface
{
public function fly();
}
interface AnimalInterface
{
public function eat();
}
@whizark
whizark / extendingTraits.php
Created Jul 10, 2014
Extending Traits #test #php
View extendingTraits.php
<?php
trait FirstTrait
{
public function firstMethod() {
echo 'This is the firstMethod()' . PHP_EOL;
}
}
trait SecondTrait
{
@whizark
whizark / constructorTrait.php
Created Jul 10, 2014
Constructor trait #test #php
View constructorTrait.php
<?php
interface PersonInterface
{
public function getFullname();
}
trait PersonTrait
{
private $name;
@whizark
whizark / dci.php
Last active Aug 29, 2015
DCI in PHP #test #php
View dci.php
<?php
interface AccountInterface
{
public function getBalance();
public function increase($money);
public function decrease($money);
}
trait AccountTrait
{
@whizark
whizark / wp-service-provider.php
Last active Aug 29, 2015
Register WordPress $GLOBALS as services with a container (The simplest way) #test #wordpress
View wp-service-provider.php
<?php
// This is just an example FOR WORDPRESS USERS.
//
// To make this better:
// * use namespace/class/closure etc.
// * use autoloader
// * create & use service provider classes
// * create & use factory for WP_Query, WP_User etc.
// interface ContainerInterface
@whizark
whizark / SassMeister-input.scss
Last active Aug 29, 2015
Sass: Map getter & overridding #sass
View SassMeister-input.scss
// ----
// Sass (v3.4.1)
// Compass (v1.0.1)
// ----
// A property map
$properties: (
prop-1: "raw-prop-1-value",
prop-2: "raw-prop-2-value"
);
@whizark
whizark / SassMeister-input-HTML.html
Created Aug 31, 2014
Sass: Polymorphic placeholder & mixins #sass
View SassMeister-input-HTML.html
<a class="button" href="#">&lt;a&gt; button</a>
<button class="button">&lt;button&gt; button</button>
@whizark
whizark / SassMeister-input-HTML.html
Last active Aug 29, 2015
Sass & BEM: A flexible component definition #sass
View SassMeister-input-HTML.html
<div class="collection">
<div class="collection__item">Item 1</div>
<div class="collection__item">Item 2</div>
<div class="collection__item">Item 3</div>
</div>
<ul class="collection">
<li class="collection__item">Item 1</li>
<li class="collection__item">Item 2</li>
<li class="collection__item">Item 3</li>
@whizark
whizark / SassMeister-input.scss
Last active Aug 29, 2015
Sass: Typed value factory & validator using Map #sass
View SassMeister-input.scss
// ----
// Sass (v3.4.1)
// Compass (v1.0.1)
// ----
// Sass: Typed value factory & validator using Map
// Direction type that accepts only top, right, left, bottom
// Direction type factory
@function dir-new($dir) {
@whizark
whizark / SassMeister-input-HTML.html
Created Sep 6, 2014
Sass: Dependency Injection into Mixins #sass
View SassMeister-input-HTML.html
<div class="container--micro">
<!-- The style attributes only for the purpose of the demo -->
<div style="float: left; height: 100px; background: #0f0;">
content
</div>
<div style="float: left; height: 100px; background: #00f;">
content
</div>
</div>