This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class GenericSerializable | |
{ | |
public $id = null; | |
public $name = 'genericThing'; | |
public $someProperties = array(); | |
public function exchangeArray($data) | |
{ | |
// Includes all public variables of children classes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Zend\Authentication\Storage; | |
use Zend\Authentication\Storage\StorageInterface as AuthStorageInterface; | |
use Zend\Cache\Storage\StorageInterface as CacheStorageInterface; | |
class Cache implements AuthStorageInterface | |
{ | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$fileUrl = 'http://t2.gstatic.com/images?q=tbn:ANd9GcS8ntYWjylXybJ4WIr5WvFJiknlXdS8jkhwpaRXqhCY3w2vFyuR-Q'; | |
// Get the file's MIME type | |
// This method is used because many file URLs hosted on CDNs do not contain file extensions | |
$finfo = new finfo(FILEINFO_MIME_TYPE); | |
$mediaType = $finfo->buffer(file_get_contents($fileUrl)); | |
// Is this an image, audio, text, video, etc.? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
r.db('local').table('TableName') | |
.replace(function (doc) { | |
return doc.merge({ | |
newFieldName: doc('oldFieldName') | |
}).without('oldFieldName'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
defmodule SchoolYear do | |
# "17-18" | |
def get_two_digit_school_year do | |
[DateTime.utc_now.year, DateTime.utc_now.year + 1] # calendar years | |
|> Enum.map( | |
(fn (calendar_year) -> Integer.digits(calendar_year) | |
|> Enum.slice(2, 2) | |
|> Enum.join end) | |
) | |
|> Enum.join("-") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def snake_case_to_start_case(snake_case) do | |
snake_case | |
|> String.replace("_", " ") | |
|> String.split | |
|> Enum.map(&String.capitalize(&1)) | |
|> Enum.join(" ") | |
end |