This file contains hidden or 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
from google.appengine.ext import ndb | |
class AuditMixin(object): | |
"""Audit fields for datastore objects""" | |
created_at = ndb.DateTimeProperty(auto_now_add=True) | |
created_user = ndb.StringProperty(indexed=False) | |
modified_at = ndb.DateTimeProperty(auto_now=True) | |
modified_user = ndb.StringProperty(indexed=False) |
This file contains hidden or 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 | |
/** | |
* User Getter Sort - Sorts an array using a user defined getter function. | |
* | |
* An imaginary user defined sort alternative where you pass a function that | |
* returns the data that should be used to determine sort order | |
* @param array &$array Array to sort in place | |
* @param Callable $itemfunc The callable that receives the array | |
* item and returns the value that should |
This file contains hidden or 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 | |
/** | |
* Lamp object to be manipulated because a Lamp is a thing | |
*/ | |
class Lamp { | |
public function turn_on() { | |
echo 'The light is on' . PHP_EOL; | |
} | |
public function turn_off() { | |
echo 'the light is off' . PHP_EOL; |
This file contains hidden or 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 | |
/** | |
* Simple Command Pattern Class | |
*/ | |
class MyCommand { | |
private $arg1; | |
private $arg2; | |
public function __construct($arg1, $arg2) { | |
$this->arg1 = $arg1; | |
$this->arg2 = $arg2; |
This file contains hidden or 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
class Switch(object): | |
"""The INVOKER class""" | |
@classmethod | |
def execute(cls, command): | |
command.execute() | |
class Command(object): | |
"""The COMMAND interface""" | |
def __init__(self, obj): | |
self._obj = obj |
This file contains hidden or 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
#include <stdio.h> | |
#include <stdlib.h> | |
typedef struct node { | |
struct node *prev; | |
struct node *next; | |
int info; | |
} Node_t; | |
void display(Node_t *start); |
This file contains hidden or 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 | |
function index_action(TemplateRendererInterface $templateRenderer) { | |
return function (ServerRequestInterface $request, | |
ResponseInterface $response, | |
callable $next = null) use ($templateRenderer) { | |
$html = templateRenderer->render('app::index'); | |
$response->getBody()->write($html); | |
return $response->withHeader('Content-Type', 'text/html'); | |
} | |
} |
This file contains hidden or 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
@login_manager.user_loader | |
def load_user(user_id): | |
user = models.User.get_by_id(user_id) | |
if user and not user.timezone: | |
lat_long = request.headers.get('X-Appengine-Citylatlong', None) | |
deferred.defer(set_user_timezone, user_id, lat_long) | |
return user | |
def set_user_timezone(user_id, lat_long): |
This file contains hidden or 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
package main | |
import ( | |
"fmt" | |
"sync" | |
) | |
type Fetcher interface { | |
// Fetch returns the body of URL and | |
// a slice of URLs found on that page. |
This file contains hidden or 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
{ | |
"name": "Continuous Verification Framework", | |
"type": "json" | |
} |