Skip to content

Instantly share code, notes, and snippets.

@zymsys
zymsys / fg_gems.md
Last active March 1, 2021 14:56
Hidden Gems in Fantasy Grounds

Debug.print()

/debug on

onValueChanged

You can use printstack from this to see why a value has changed. I'd like to build a listener extension fror OOB. Maybe I could support listening for values too. Was going to support listening for dice rolls.

Session.isHost

This is a variable, so is faster than User.isHost(). All the cool kids are using it.

@zymsys
zymsys / multiplier_filter.dart
Created January 17, 2014 19:26
Trying to solve the 'Explore More' challenge from https://github.com/angular/angular.dart.tutorial/wiki/Introducing-filters-and-services, but I can't find the right approach to a filter which modifies the output. This loops forever because the list is changed by the filter. For now this just prepends an x to each ingredient. This is a placeholde…
library multiplier_filter;
import 'package:angular/angular.dart';
import '../recipe.dart';
@NgFilter(name: 'multiplierfilter')
class MultiplierFilter {
call(recipeList, multiplier) {
if (recipeList is List && multiplier is int) {
var result = recipeList.map((recipe) {
@zymsys
zymsys / journal.md
Last active November 5, 2015 17:06
DBAL & MySQL JSON

When I have a table in a database which has a json column I can't use doctrine:schema:update --force because I get this error:

[Doctrine\DBAL\DBALException]
Unknown database type json requested, Doctrine\DBAL\Platforms\MySQL57Platform may not support it.

Break on exception shows this happening at \Doctrine\DBAL\Platforms\AbstractPlatform\getDoctrineTypeMapping because 'json' can't be found in $this->doctrineTypeMapping. This is initialized by the abstract function initializeDoctrineTypeMappings which in this case is implemented in \Doctrine\DBAL\Platforms\MySqlPlatform. Sure enough there is no 'json' key.

It looks like the array keys are native column types, and the array values are DBAL column types.

I know that mysql has a 'json' column type, and I know that DBAL has a 'json_array' column type. Let's take a shot in the dark...

@zymsys
zymsys / gist:4176392
Created November 30, 2012 15:23
Creating a Composer Package with its own Dependency
I'm trying to set up composer for a package I maintain called Zymurgy:CM, which is on github but not on packagist. I created a 'composer' branch which has the following composer.json file:
{
"name": "zymurgy/zymurgy-cm",
"type": "library",
"description": "Zymurgy:CM Content Management",
"license":"MIT",
"authors": [
{
"name": "Vic Metcalfe",
@zymsys
zymsys / events.js
Created April 21, 2012 05:53
Meteor First Impressions
Template.leaderboard.events = {
'click input.inc': function () {
Players.update(Session.get("selected_player"), {$inc: {score: 5}});
},
'click #sort': function () {
Session.set("sort_by_name", !Session.get("sort_by_name"));
}
};
@zymsys
zymsys / trafficlight_ocp.rb
Created April 14, 2012 19:01
SRP and OCP example
class TrafficLightDisplay
def showState(state)
puts state == :LIGHT_STATE_RED ? "* RED *" : " red"
puts state == :LIGHT_STATE_AMBER ? "* AMBER *" : " amber"
puts state == :LIGHT_STATE_GREEN ? "* GREEN *" : " green"
puts "---------"
end
end
class TrafficLight
@zymsys
zymsys / DIP.php
Created April 8, 2012 15:53
SOLID Sample Code
<?php
class FooControllerConventional
{
function indexView() {
$model = new FooModel();
$viewData = $model->fetchAll();
$view = new FooView();
$view->render($viewData);
}
}
@zymsys
zymsys / LSPExampleViolation.php
Created March 8, 2012 03:11
Rectangle / Square LSP Example Violation in PHP
<?php
class Rectangle
{
private $_width;
private $_height;
public function getWidth()
{
return $this->_width;
@zymsys
zymsys / fiddle.response.json
Created January 23, 2012 00:53
Demo JSON data
[
{
"name":"Tanner Young",
"phones":[
{
"name": "home",
"number": "1-802-826-8704"
},
{
"name": "fax",
@zymsys
zymsys / gist:1595001
Created January 11, 2012 14:52
How I build PHP 5.4 on OSX from source
I had to run find to figure out where bz2.so was:
$ sudo find / -name bz2.so
...
Should turn something up - I hope. Change the eclipse path below to whatever you find. If you can't find anything you might have to install Zend Studio or figure out another source. Then from the PHP source folder:
$ ./configure --enable-mysqlnd --with-gd --enable-mbstring --with-bz2=/Applications/eclipse/plugins/org.zend.php.debug.debugger.macosx_5.3.7.v20091124/resources/php5/ext/ --with-zlib --with-curl --with-curlwrappers
$ make