Skip to content

Instantly share code, notes, and snippets.

Avatar
🎩
Coding

Christoffer Niska crisu83

🎩
Coding
View GitHub Profile
@crisu83
crisu83 / Rot13.js
Created Dec 14, 2011
Rot13 static JavaScript class
View Rot13.js
/**
* Rot13 class.
* @author Christoffer Niska <christoffer.niska@nordsoftware.com>
* @copyright Copyright (c) 2011, Christoffer Niska
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
*/
var Rot13 = {
map: null,
length: 0,
init: function() {
@crisu83
crisu83 / Position.cpp
Created Apr 12, 2012
OgreChess Position.cpp
View Position.cpp
#include "stdafx.h"
Position::Position(void)
: mTurn(0)
{
}
Position::~Position(void)
{
}
View ImageBehavior.php
<?php
/**
* ImageBehavior class file.
* @author Christoffer Niska <ChristofferNiska@gmail.com>
* @copyright Copyright &copy; Christoffer Niska 2011-
* @license http://www.opensource.org/licenses/bsd-license New BSD License
* @since 1.1.0
*/
class ImageBehavior extends CBehavior
{
View CmsUrlManager.php
<?php
/**
* CmsUrlManager class file.
* @author Christoffer Niska <christoffer.niska@nordsoftware.com>
* @copyright Copyright &copy; 2012, Nord Software Ltd
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @package cms.components
*/
/**
@crisu83
crisu83 / DynamicForm.php
Created Dec 8, 2012
Dynamic form model for Yii
View DynamicForm.php
<?php
class DynamicForm extends CFormModel
{
private $_rules = array();
private $_properties = array();
public function __set($name, $value)
{
if (isset($this->_properties[$name]))
@crisu83
crisu83 / AuthItemController.php
Created Dec 23, 2012
A single action from a work in progress AuthItemController.
View AuthItemController.php
<?php
public function actionDelete()
{
$request = Yii::app()->request;
if ($request->isPostRequest && isset($_GET['name']))
{
$name = $_GET['name'];
/* @var $am CAuthManager|AuthBehavior */
$am = Yii::app()->getAuthManager();
$item = $am->getAuthItem($name);
@crisu83
crisu83 / CachedDbAuthManager.php
Created Dec 30, 2012
A cached database authorization manager for Yii.
View CachedDbAuthManager.php
<?php
class CachedDbAuthManager extends CDbAuthManager
{
const CACHE_KEY_PREFIX = 'Auth.CachedDbAuthManager.';
/**
* @var integer the time in seconds that the messages can remain valid in cache.
* Defaults to 0, meaning the caching is disabled.
*/
@crisu83
crisu83 / AuthFilter.php
Created Jan 12, 2013
AuthFilter class from the Auth module for the Yii PHP framework.
View AuthFilter.php
<?php
/**
* AuthFilter class file.
* @author Christoffer Niska <ChristofferNiska@gmail.com>
* @copyright Copyright &copy; Christoffer Niska 2012-
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @package auth.components
*/
/**
@crisu83
crisu83 / TbApiRegisterEvents.php
Last active Dec 11, 2015
A function for registering JavaScript events based on an array ($name => $handler).
View TbApiRegisterEvents.php
<?php
/**
* Registers a specific Bootstrap plugin with the given selector and options.
* @param string $name the plugin name.
* @param string $selector the CSS selector.
* @param array $options plugin JavaScript options.
* @param int $position the position of the JavaScript code.
*/
public function registerPlugin($name, $selector, $options = array(), $position = CClientScript::POS_END)
{
View TbHtml.php
<?php
/**
* Generates a button group.
* @param array $buttons the button configurations.
* @param array $htmlOptions additional HTML options. The following special options are recognized:
* todo: write the options
* @return string the generated button group.
*/
public static function buttonGroup($buttons, $htmlOptions = array())
{