Skip to content

Instantly share code, notes, and snippets.

View crisu83's full-sized avatar
🎩
Coding

Christoffer Niska crisu83

🎩
Coding
View GitHub Profile
@crisu83
crisu83 / coderwall-provider.js
Created October 17, 2013 16:13
Coderwall provider for StartHQ
[
  {
    query: 'https://coderwall.com/p/search?scope=everything&search={{term}}',
    translate: 'parseHTML(response)',
    icon:{
      selector: '.avatars li:first-child a',
      expression: 'app.url|icons'
    },
    name:{
      selector: '.protip a.title',
@crisu83
crisu83 / JsonAttributeBehavior.php
Created October 11, 2013 08:01
Active record behavior for handling JSON attributes.
<?php
/**
* Active record behavior for handling JSON attributes.
*
* @property CActiveRecord $owner
*/
class JsonAttributeBehavior extends CActiveRecordBehavior
{
/**
@crisu83
crisu83 / jsWarriorLogic
Last active December 25, 2015 05:49
Logic for jsWarrior to beat the game. http://jswarrior.fusioncharts.com/
var maxHealth = 20,
criticalHealth = 5,
checkedBehind = false;
jsWarrior.turn = function(warrior) {
warrior.takingDamage = warrior.lastHealth > warrior.getHealth();
if (warrior.check() == "enemy") {
warrior.attack();
}
/**
* Initializes the application.
*/
var initialize = function() {
var self = this;
$('*[data-view]').each(function() {
var $el = $(this),
viewClass = 'app/views/' + $el.data('view');
require([viewClass], function(View) {
new View({el: $el[0], app: self});
<?php
class I18nAttributeBehavior extends CActiveRecordBehavior
{
/**
* @var array a list of translatable attributes.
*/
public $attributes = array();
/**
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
# VMWare
config.vm.box = "precise64_vmware"
config.vm.box_url = "http://files.vagrantup.com/precise64_vmware.box";
config.vm.network :public_network
<?php
/**
* Returns the active language.
* @return string the locale.
*/
public function resolveActiveLanguage()
{
$user = user();
$matches = array();
if ($user->hasState('__locale')) {
@crisu83
crisu83 / ConfigRenderer.php
Last active December 21, 2015 09:59
Component for Yii for rendering configuration files.
<?php
class ConfigRenderer extends CComponent
{
/**
* @var string
*/
public $tab = ' ';
/**
@crisu83
crisu83 / MigratePathCommand.php
Created August 20, 2013 21:41
Migration command for Yii that allows for adding (and removing) of external migrations.
<?php
Yii::import('system.cli.commands.MigrateCommand');
class MigratePathCommand extends MigrateCommand
{
/**
* @var string
*/
public $migrationTable = 'migration';
<?php
/**
* Web user component with support for loading the associated model.
*
* You can request attributes on the model object the following way:
* Yii::app()->user->model->username;
*/
class WebUser extends CWebUser
{
/**