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
import RPi.GPIO as GPIO | |
import urllib.request | |
PIN = 5 | |
LOW_CALLBACK_ADDRESS = 'http://google.com' | |
HIGH_CALLBACK_ADDRESS = 'http://facebook.com' | |
DEBOUNCE_TIME_MS = 200 |
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 | |
/* | |
* File Name: Database.php | |
* Date: November 18, 2008 | |
* Author: Angelo Rodrigues | |
* Description: Contains database connection, result | |
* Management functions, input validation | |
* | |
* All functions return true if completed | |
* successfully and false if an error |
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
import sys | |
import random | |
import math | |
from collections import defaultdict | |
if len(sys.argv) != 3: | |
print "Usage: ./playcount.py <file_to_parse> <output_counts_to_file>" | |
exit(1) | |
countmap = defaultdict(int) |
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
class Container(dict): | |
def __init__(self, *args, **kwargs): | |
super(Container, self).__init__(*args, **kwargs) | |
self._shared = set() | |
self._instances = {} | |
def __getitem__(self, key): | |
if key in self._instances: | |
return self._instances[key] | |
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 RegistrationForm extends Validation { | |
public function __construct(Array $array) { | |
parent::__construct($array); | |
$this->rule('username', 'not_empty'); | |
$this->rule('password', 'not_empty'); | |
$this->rule('password_confirmation', 'matches', array(':validation', 'confirm', 'password')); | |
} | |
public function check() { |
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 | |
$data = file_get_contents('https://www.iis.se/data/bardate_domains.txt'); | |
$limit = 4; | |
$domains = array(); | |
foreach(explode("\n", $data) as $line) { | |
$parts = array_filter(array_map('trim', explode("\t", $line))); | |
if($parts && strlen($parts[0]) < $limit + 3) | |
$domains[$parts[0]] = $parts[1]; | |
} |
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 | |
function val_somewhat_nested($name = null, $value = null, $is_mutable = false) { | |
static $values = array(); | |
static $mutables = array(); | |
if($name === null) | |
return $values; | |
if($value === null) | |
return isset($values[$name]) ? $values[$name] : null; |
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
class Tag { | |
public $name; | |
public $contents; | |
public function __construct($name, $contents = array()) { | |
$this->name = $name; | |
$this->contents = $contents; | |
} | |
public function has_contents() { |
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 Kohana_Mustache extends Mustache { | |
protected function _getPartial($tag_name) { | |
$filename = Kohana::find_file('templates', $tag_name, 'mustache'); | |
return file_exists($filename) ? file_get_contents($filename) : parent::_getPartial($tag_name); | |
} | |
} |
NewerOlder