In my database I have 5 separate schemas so that I can organize objects into logical groups. I used dbicdump to create my DBIx::Class schema, but noticed that it only loaded tables from the public schema. I figured out how to load all my schemas using dbicdump, but now I'm at a loss on where to go from here setting everything up and using it. I've looked online for any resources, and found very little documentation. The only thing I did find, I really wasn't too happy with the solution. I am wondering if anyone has encountered this before, and how they dealt with it.
You'll need a recent DBIx::Class I believe, but I use something like this:
#!/usr/bin/perl
use v5.14;
use DBIx::Class::Schema::Loader qw/ make_schema_at /;
use Path::Tiny;
my $dest_dir = '.';
my $pkg_base = 'Foo';
(my $pkg_dir = $pkg_base) =~ s/::/\//g;
# Delete any previous run
path($dest_dir.'/'.$pkg_base)->remove_tree;
make_schema_at(
$pkg_base.'::Schema',
{
debug => 0,
dump_directory => $dest_dir,
db_schema => '%',
moniker_parts => ['schema', 'name'],
#rescan => 1,
},
[ 'dbi:Pg:dbname=mydb port=5432', 'dbuser', 'dbpass' ],
);
exit;
That gives me something like:
Foo::Schema::Result::PublicTable1
Foo::Schema::Result::Schema2Table2
etc
There are details of the various options in the docs. I seem to remember I cross-referenced the docs with the source of dbicdump when I put it together.
HTH
I found this, and it was nearly what I needed. But I wanted traditional :: and separation of true classes (based on tables) with view classes that contain random bits of sql so, I have:
#!/usr/bin/perl
use DBIx::Class::Schema::Loader qw/ make_schema_at /;
use Path::Tiny;
my $dest_dir = '../sql' ;
my $pkg_base = 'Cclite2';
# Delete any previous run
path($dest_dir.'/'.$pkg_base)->remove_tree;
make_schema_at(
$pkg_base.'::Schema',
{
debug => 0,
dump_directory => $dest_dir,
db_schema => 'cclite2',
moniker_parts => ['schema', 'name'],
moniker_part_separator => '::',
naming => {
relationships => 'v8',
monikers => 'v8',
column_accessors => 'v8',
force_ascii => 1,
},
},
[ 'dbi:Pg:dbname=dbname', 'dbuser', 'dbpass' ],
);
exit;
This gives this:
├── Schema
│ │ └── Result
│ │ ├── Cclite2
│ │ │ ├── OmAuth.pm
│ │ │ ├── OmCategory.pm
etc.
│ │ │ └── OmYellowpage.pm
│ │ ├── OmAdminBalanceView.pm
│ │ ├── OmAdsRss.pm
etc.
│ │ ├── OmTradesByUserView.pm
│ │ └── OmVolumeView.pm
│ └── Schema.pm
This is not criticism of the first answer. It's just an alternative that suits me and may suit others.
Related
my directory structure is
├── xxx
│ ├── 01.md
| └── 02.md
├── auth
│ ├── j1.json
│ ├── j2.json
│ └── j3.json
└── default.template.html
And I link jsons from markdowns like Auth. It makes sense as we use there files as test scenarios and in json files we have credentials and roles. But if I try to generate html it fails on unresolved internal reference: ../auth/aspect_admin.json. I tried to exclude the link checking but without any help. The best would be to leave it as a link in md file but somehow follow the link and include the json as code block in generated html. Is it possible?
It was a bug and will be fixed in next version https://github.com/planet42/Laika/issues/148
import InlineEditor from '#ckeditor/ckeditor5-build-inline';
// import Bold from '#ckeditor/ckeditor5-basic-styles/src/bold';
InlineEditor
.create( document.querySelector( '#editor' ), {
// plugins: [ Bold ],
toolbar: [ 'bold' ]
} )
.then((editor) => {
editor.setData('Some Text');
})
.catch( error => {
console.error( error );
} );
When I enable plugins:
import InlineEditor from '#ckeditor/ckeditor5-build-inline';
import Bold from '#ckeditor/ckeditor5-basic-styles/src/bold';
InlineEditor
.create( document.querySelector( '#editor' ), {
plugins: [ Bold ],
toolbar: [ 'bold' ]
} )
.then((editor) => {
editor.setData('Some Text');
})
.catch( error => {
console.error( error );
} );
My npm packages
webpack-demo#1.0.0 /var/www/english.dev.*******/frontend/web/js/npm/webpack-demo
├── #ckeditor/ckeditor5-autoformat#1.0.0-alpha.2
├── #ckeditor/ckeditor5-basic-styles#1.0.0-alpha.2
├── #ckeditor/ckeditor5-build-inline#1.0.0-alpha.2
├── #ckeditor/ckeditor5-core#1.0.0-alpha.2
├── #ckeditor/ckeditor5-editor-classic#1.0.0-alpha.2
├── #ckeditor/ckeditor5-engine#1.0.0-alpha.2
├── #ckeditor/ckeditor5-essentials#1.0.0-alpha.2
├── #ckeditor/ckeditor5-image#1.0.0-alpha.2
├── #ckeditor/ckeditor5-markdown-gfm#1.0.0-alpha.2
├── #ckeditor/ckeditor5-paragraph#1.0.0-alpha.2
├── #ckeditor/ckeditor5-ui#1.0.0-alpha.2
├── #ckeditor/ckeditor5-utils#1.0.0-alpha.2
├── babel-cli#6.26.0
├── babel-core#6.26.0
├── babel-loader#7.1.2
├── babel-plugin-transform-class-properties#6.24.1
├── babel-plugin-transform-decorators-legacy#1.3.4
├── babel-preset-env#1.6.1
├── babel-preset-react#6.24.1
├── compression-webpack-plugin#1.1.2
├── css-loader#0.28.7
├── fade-props#2.1.0
├── gzip-loader#0.0.1
├── jquery#3.2.1
├── lodash#4.17.4
├── mobx#3.4.1
├── mobx-react#4.3.5
├── node-sass#4.7.2
├── raw-loader#0.5.1
├── react#15.6.2
├── react-addons-css-transition-group#15.6.2
├── react-addons-update#15.6.2
├── react-css-transition-replace#3.0.2
├── react-dom#15.6.2
├── react-redux#5.0.6
├── react-router#4.2.0
├── react-router-dom#4.2.2
├── redux#3.7.2
├── redux-devtools#3.4.1
├── sass-loader#6.0.6
├── style-loader#0.19.1
└── webpack#3.10.0
.html
<div id="editor"></div>
Actually my goal is to insert html with tag , via method setData(), but as I underdtood, I need to use plugin Markdown. But anyway I can't make it work with any plugins. Thank you.
P. S. I tried basic and inline forms but the same problem.
I found out that it was because there wasn't imported and used Paragraph
import Paragraph from '#ckeditor/ckeditor5-paragraph/src/paragraph';
....
plugins: [ Paragraph ]
.....
I think it's not good behavior for ckeditor. But it is 1.0.0 what do I want from it.. xD
CKEditor 5 is highly modular and even features such as support for typing are separate plugins which you need to load. An editor creator cannot assume which modules should be loaded and leaves all that to the developers.
You can read more about the architecture in "Architecture overview".
So, it's your obligation to load all necessary plugins when you're building the editor from source. If you use existing editor builds you don't have to do that because builds have a set of plugins built in.
BTW, loading Paragraph is not enough to create an editor. You won't be able to type or paste. Therefore, there's a plugin which enables all these essential features – Essentials.
Refer to the CKEditor 5 Framework's "Quick start" guide for more information (e.g. ready-to-use code snippets).
I would like to fake the LED (character device) of an embedded linux board (BeagleBone Black) in a user space library written in D.
Via the command line the led driver is represented to the user space as "device file" (e.g. for led "USER LEDS D2 0"):
debian#beaglebone:/sys/class/leds/beaglebone:green:usr0$ tree
.
├── brightness
├── device -> ../../../leds
├── invert
├── max_brightness
├── power
│ ├── async
│ ├── autosuspend_delay_ms
│ ├── control
│ ├── runtime_active_kids
│ ├── runtime_active_time
│ ├── runtime_enabled
│ ├── runtime_status
│ ├── runtime_suspended_time
│ └── runtime_usage
├── subsystem -> ../../../../../class/leds
├── trigger
└── uevent
Via the command line single entities like e.g. the brightness (turn on and off) can be written to and read from like files:
cd /sys/class/leds/beaglebone:green:usr0
echo none > trigger
echo 1 > brightness
echo 0 > brightness
I consider it reasonable to abstract the whole device as interface and implement a production class and a test class (hand-made fake object) which implements the interface. The client code of the library could then use either the production code or the fake class which could be injected using dependency injection.
Could a mock framework like https://github.com/QAston/DMocks-revived provide functionality to use a fake driver in client code out of the box instead of using the handmade fake led driver described above? (I guess to fake more complicated character devices it would be necessary to "hand-implement" anyway.)
Or are there better approaches to fake a character device (e.g. make the production class require a root path of the driver when creating an instance via "constructor injection")?
I have created a plugin at this location moodle/local/redirectafterlogin with the following structure :
redirectafterlogin/
├── db
│ ├── classes
│ │ └── observer.php
│ └── events
│ └── events.php
└── version.php
version.php:
defined('MOODLE_INTERNAL') || die();
$plugin->version = 20170333;
$plugin->requires = 2015111000;
$plugin->component = 'local_redirectafterlogin';
events.php:
defined('MOODLE_INTERNAL') || die();
$observers = array(
array(
'eventname' => 'core\event\user_loggedin',
'callback' => 'local_redirectafterlogin_observer::user_loggedin',
),
array(
'eventname' => 'core\event\user_loggedout',
'callback' => 'local_redirectafterlogin_observer::user_loggedin',
),
);
observer.php:
class local_redirectafterlogin_observer
{
public static function user_loggedin(core\event\base $event)
{
$event_data = $event->get_data();
var_dump($event_data);
die();
}
}
Cached has been cleared a lot of time and version number has been bumped too but the callback is never called!
What's wrong, why does the callback is not triggered?
How can I debug events (is there a way in Moodle to see dispatched events)?
It was a structure mistake! I put the classes folder containing observer.php in the db folder!
After moving the classes folder at the root of the plugin as follow, this is ok, observer is triggered!
Structure that is ok:
redirectafterlogin/
├── classes
│ └── observer.php
├── db
│ └── events.php
└── version.php
I don't think the automatic class loading will be able to find your observer class.
Try adding to the top of the observer class file:
namespace local_redirectafterlogin;
Then change the events.php to:
'callback' => 'local_redirectafterlogin\local_redirectafterlogin_observer'
(You could also greatly shorten the class name, now it is namespaced). Make sure you bump the version number, to reload the events.php file.
You may want to reconsider the naming of your plugin, though, as redirection is not allowed from within an event handler, as that would cause a great many problems.
I made the experience that var_dump or output do stdout gets not trigggert. As quick "debug" i use file_put_contents to a temp logfile
I am documenting a matlab code that I have with sphinx. I am using the package sphinxcontrib-matlabdomain.
My directory tree is as follows:
me:~/.../doc$ tree ../
../
├── doc
│ ├── conf.py
│ ├── make.bat
│ ├── Makefile
│ ├── index.rst
│ ├── BaseClass.rst
│ └── DerivedClass.rst
├── LICENSE.md
├── README.md
└── src
├── BaseClass.m
└── DerivedClass.m
The problem comes when I want to show inheritance diagrams. I have added the necessary things in my config.py file:
matlab_src_dir = os.path.abspath('..')
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.inheritance_diagram',
'sphinx.ext.graphviz',
'sphinx.ext.viewcode',
'sphinxcontrib.matlab',
]
primary_domain = 'mat'
And I have the following in the index.rst file
Welcome to BGK's documentation!
===============================
I am trying to have a diagram here...
.. inheritance-diagram:: BaseClass DerivedClass
:parts:2
.. graphviz::
digraph {
"From here" -> "To" -> "Somewhere";
"From here" -> "To" -> "Somewhere else";
}
And in the output the directive inheritance-diagram is ignored, obtaining directly the next diagram that I am using to test that I can plot diagrams.
Is there any incompatibility to plot inheritance diagrams with sphinx for matlab classes? Is there any way to go around the problem? Thanks!
Sphinx does not support this. The built-in sphinx.ext.inheritance_diagram extension is for the Python domain only. It does not work for Matlab. If it did, I'm sure it would say so in the Sphinx documentation (and a glance at the source code in sphinx/ext/inheritance_diagram.py confirms that it is only for Python).
The only way inheritance diagrams for Matlab could work is if some other extension provided the functionality. The sphinxcontrib-matlabdomain extension that you use does not.