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 get_google_spreadsheet($key) { | |
| $url = "https://spreadsheets.google.com/feeds/list/{$key}/od6/public/values"; | |
| $google_sheet = file_get_contents($url); | |
| $xml = simplexml_load_string($google_sheet); | |
| $data = array(); | |
| foreach($xml->entry as $entry) { | |
| $row = array(); | |
| // The fields are in the gsx: namespace, so we need to specify that to be able to access them through SimpleXML. |
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 latest_video($id_only = False) { | |
| $url = trim(file_get_contents('/home/cyklarunt/latest')); | |
| return $id_only ? end(explode('=', $url)) : $url; | |
| } |
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
| def pick_by_keys(d, ks): | |
| return dict((k, v) for k, v in d.iteritems() if k in ks) | |
| d = { | |
| 'hello': 'world', | |
| 'foo': 'bar', | |
| 'romeo': 'juliet', | |
| 'alice': 'bob' | |
| } |
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 alias.models import Alias | |
| from django.contrib import admin | |
| class AliasAdmin(admin.ModelAdmin): | |
| list_display = ('path', 'target') | |
| admin.site.register(Alias, AliasAdmin) |
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
| $some_array[$some_id]['key_one'] = $value_one; | |
| $some_array[$some_id]['key_two'] = $value_two; | |
| $some_array[$some_id]['key_three'] = $value_three; |
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 | |
| class ActiveCollab { | |
| protected $base_url; | |
| protected $api_key; | |
| public function __construct($base_url, $api_key) { | |
| $this->base_url = $base_url; | |
| $this->api_key = $api_key; | |
| } |
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 | |
| 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); | |
| } | |
| } |
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 Tag { | |
| public $name; | |
| public $contents; | |
| public function __construct($name, $contents = array()) { | |
| $this->name = $name; | |
| $this->contents = $contents; | |
| } | |
| public function has_contents() { |
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 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; |