Skip to content

Instantly share code, notes, and snippets.

@mariuskubilius
mariuskubilius / countrylist.php
Last active December 6, 2021 09:00
Only Independent Countries from wikipedia in Array format.
<?php
/**
* List of independent countries originaly found at: https://en.wikipedia.org/wiki/ISO_3166-1#Current_codes
* date of creation 06 dec 2021
*/
return [
"AF" => "Afghanistan",
"AL" => "Albania",
"DZ" => "Algeria",
"AD" => "Andorra",
@mariuskubilius
mariuskubilius / extractTranslationStrings.php
Created January 23, 2019 15:09
Laravel artisan command to extract translation strings from templates and add them into {language}.json file for localization.
<?php
namespace App\Console\Commands;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\File;
class extractTranslationStrings extends Command
{
@mariuskubilius
mariuskubilius / transactions.php
Created May 6, 2014 22:19
Transaction support in lithium.
/**
*Since Lithium uses PDO, you can just get the PDO object and call the beginTransaction() method.
*/
$foo = app\models\Foo::create();
$pdo = Connections::get('default')->connection;
$pdo->beginTransaction();
$foo->bar = 'Hello';
$foo->save();
$pdo->commit();
@mariuskubilius
mariuskubilius / Call Stack
Last active August 29, 2015 13:57
Li3 tests throwing exception in tests->affected
! ) Notice: Use of undefined constant type - assumed 'type' in /Applications/mampstack-5.4.17-0/apache2/htdocs/libraries/lithium/analysis/Inspector.php on line 543
Call Stack
# Time Memory Function Location
1 0.0000 239680 {main}( ) ../index.php:0
2 0.0093 1652672 lithium\action\Dispatcher::run( ) ../index.php:41
3 0.0094 1654448 lithium\core\StaticObject::_filter( ) ../Dispatcher.php:155
4 0.0094 1657264 lithium\util\collection\Filters::run( ) ../StaticObject.php:147
5 0.0094 1660208 lithium\core\Libraries::{closure:/Applications/mampstack-5.4.17-0/apache2/htdocs/libraries/li3_docs/config/bootstrap.php:26-38}( ) ../Filters.php:184
6 0.0097 1690304 lithium\util\collection\Filters->next( ) ../bootstrap.php:32
7 0.0097 1690464 {closure:/Applications/mampstack-5.4.17-0/apache2/htdocs/app/config/bootstrap/action.php:41-52}( ) ../Filters.php:203
@mariuskubilius
mariuskubilius / app.js
Last active January 15, 2018 19:29 — forked from zoranf/app.js
app.get('/lobby/:id', function(req, res) {
db.games.find( { name: req.params.id }, function(err, game) {
if (err) {
console.log('error');
return res.render('404', {
title: 'Game not found',
message: 'Game ' + req.params.id + 'not found'
});
$result = Model::find('all', array(
'conditions' => array(
'$or' => array(
array('hierarchy' => $p->_id),
array('_id' => (string)$c->_id)
)
),
'fields' => array('_id', 'title'),
));
@mariuskubilius
mariuskubilius / media.php
Created November 9, 2012 15:36
Lithium media class to serve layouts from app
use lithium\net\http\Media;
Media::type('default', null, array(
'view' => 'lithium\template\View',
'paths' => array(
'layout' => array(
'{:library}/views/layouts/{:layout}.{:type}.php',
LITHIUM_APP_PATH.'/views/layouts/{:layout}.{:type}.php'
),
'template' => '{:library}/views/{:controller}/{:template}.{:type}.php',
@mariuskubilius
mariuskubilius / config\bootstrap\action.php
Created March 18, 2012 17:38
LI3 Change layout depending whether admin continuation route is used or not
use lithium\action\Dispatcher;
//Allow admin continuation routes to be made.
Dispatcher::config(
array(
'rules' => array(
'admin' => array('action' => 'admin_{:action}')
)
)
);
@mariuskubilius
mariuskubilius / CategoriesController.php
Created December 28, 2011 22:13
Lithium Model and Controller for taxonomies
<?php
namespace app\controllers;
use \app\models\Taxonomies;
use MongoId;
class CategoriesController extends \lithium\action\Controller {
/**
* @var Protected $_type - protected variable which define type of taxonomy,
* Can be omited if there is no need for additional types of taxonomy.