Skip to content

Instantly share code, notes, and snippets.

View simensen's full-sized avatar
🎯
Focusing

Beau Simensen simensen

🎯
Focusing
View GitHub Profile
<?php
// We want to make certain we have the repose context
// included so that we can get the reposeSessionFactory
// object.
$context->import('repose.context.php');
$context->set('spaceRepository', array(
'className' => 's3a_domain_ReposeSpaceRepository',
'constructorArgs' => array(
<?php
// Called when the POST form is submitted.
protected function onSubmit(halo_HttpRequest $httpRequest, halo_HttpResponse $httpResponse) {
$space = $this->spaceRepository->findById(
$httpRequest->getUrlParam('spaceId')
);
$space->setName($httpRequest->getPostParam('name'));
$space->setPhone($httpRequest->getPostParam('phone'));
$space->setAddressLine1($httpRequest->getPostParam('addressLine1'));
$space->setAddressLine2($httpRequest->getPostParam('addressLine2'));
<?php
// Import the Space Repository.
$context->import('s3a_spaceRepository.context.php');
// Define the Space Edit controller, and make certain that the Space Repository
// is set.
$context->set('spaceEditController', array(
'className' => 's3a_controllers_admin_SpaceEditController',
'properties' => array(
'spaceRepository' => $context->ref('spaceRepository'),
<?php
curl_setopt_custom_postfields($ch, array(
'file' => '@/path/to/file',
'tag' => array('a', 'b', 'c'),
));
?>
<?php
function curl_setopt_custom_postfields($ch, $postfields, $headers = null) {
$algos = hash_algos();
$hashAlgo = null;
foreach ( array('sha1', 'md5') as $preferred ) {
if ( in_array($preferred, $algos) ) {
$hashAlgo = $preferred;
break;
}
}
<fb:narrow>
  <div class="header">Header</div>
  <div class="image">
  <fb:random>
    <fb:random-option>
      <img src="sample1.jpg" />
    </fb:random-option>
    <fb:random-option>
      <img src="sample2.jpg" />
    </fb:random-option>
import pycurl
import sys
class Storage:
def __init__(self):
self.contents = ''
self.line = 0
def store(self, buf):
self.line = self.line + 1
jQuery('.emailLink').click(function(e) {
e.preventDefault();
var $link = jQuery(this);
var $sending = jQuery('<span>Sending...</span>');
$link.after($sending);
$link.hide();
var restoreCb = function() {
$link.show();
$sending.remove();
};
# Works as expected for .htaccess
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule / http://example.com/ [L]
# Works as expected for main configuration
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
RewriteRule / http://example.com/ [L]
<?php
class SomeModel extends Model {
function doSomething ($foo) {
// need to work with another model...
$CI =& get_instance();
$CI->load->model('SomeOtherModel','NiceName',true);
// use $CI instead of $this to query the other models. Shorter anyway ;-)
$CI->NiceName->doSomethingElse();
}
?>