I'm beginning a website using the Kohana Framework, and I couldn't find how to include external libraries "the proper way".
I want to use the phpFlickr library to allow my website to interact with Flickr.
If there was a better way to include the files than:
require_once("path/to/phpFlickr.php");
// Fire up the main phpFlickr class
$f = new phpFlickr($key);
It's OK to do it that way I guess, but if I could say to Kohana, "the phpFlickr files are there, go get them on your own when you need it", it would be better.
Anyone can help me with that?
Thanks.
We use it in the same way as detailed here.
So, like the following:
$path = Kohana::find_file('vendors', 'flickr/phpFlickr');
if($path) {
ini_set('include_path',
ini_get('include_path') . PATH_SEPARATOR . dirname(dirname($path)));
require_once 'flickr/phpFlickr.php';
}
You can make a flickr folder in modules, create an init.php file in there and do something like this;
require_once Kohana::find_file('folder','phpFlickr');
Of course, you'll first have to enable "flickr" module in your bootstrap.
The better way would be to define a custom autoload method for flickr classes only so it's loaded only when it's actually needed.
Related
I would like to specify my own custom breakpints. The documentation as https://styled-system.com/responsive-styles/#using-objects only refers to theme.js.
But I don't understand where do I place theme.js? or find it? and how do I import it into the project? and how do I define breakpoints with aliases and use plain objects as values.?
Can someone please guide me? I am using styled-system in Gatsby.js
You simply need to export a key called breakpoints. In my project we use a js file to define our theme, it looks like this
export const breakpoints = ['769px', '1367px'];
Since you are using Gatbsy, you need to install gatsby-plugin-theme-ui. Your theme file will be src/gatsby-plugin-theme-ui/index.js.
I have a CPP project, and i need to use some bluez's API(According to the example bluez/tools/btgatt-server.c). In the Makefile.tools I found that:
tools_btgatt_server_SOURCES = tools/btgatt-server.c src/uuid-helper.c
tools_btgatt_server_LDADD = src/libshared-mainloop.la \
lib/libbluetooth-internal.la
So, if I want to use those API i need the three files uuid-helper.c libshared-mainloop.la libbluetooth-internal.la. I know .la file is only a text file, but i don't know how to "add/use" them to my project makefile. In other words, i want to know how to use the existing .la files in my project(a simple Makefile example will be great). Or is there any other way to call bluez's API?
Any advise would be appreciated.
I had resigned myself to the fact that every require statement in Typescript had to be relative to the file you were typing in, but I recently discovered an application that does this differently and it confuses me. I was hoping someone with enough skill could explain how this is working to me.
The application in question is the new Raven DB HTML5 Studio, which uses typescript, you can find the whole application here:
RavenDB HTML5 Studio
When browsing its source code, I came across something interesting... if you go and look at many of the files; In specific the one I am looking at... app/viewmodels/deleteItems.ts, it has a reference at the top that reads..
import document = require("models/document");
but models/document isn't a path relative to deleteItems.ts, but this works. Can someone explain how this is happening? I'm linking you RIGHT to the exact files I'm talking about. This kind of behavior is littered all over this application.
app/viewmodels/deleteItem.ts
app/models/document.ts
This is exactly the kind of behavior I really wanted to try and emulate in my own code, since trying to keep all of the paths relative to the file I'm working in is a headache, but this program seems to be completely free of that requirement.
This doesn't necessarily involve RavenDB, but I am tagging it anyway, because perhaps someone who has read over the Raven repository will understand it and be able to answer.
Update
I am trying to mimic this behavior in my own code, and not finding any success. I am sorry if I seem outright stupid, but this is all really confusing me. Here is what my structure looks like; My repository is private, so I cannot really just link to it.
app_content
scripts
home
controls
models
editors
utils
UserControls.ts
UserMapping.ts
UserElements.ts
ui
lib
jquery
jquery.js
jquery.validate.js
jquery.ui.js
kendo
kendo.all.js
kendo.aspnetmvc.js
// other libraries
Alright, that's a general feel for my folder layout. All typescript files are under the /home folder so that I can prevent github from saving their compiled javascript and locking that.
So then, in the file UserControls.ts, it looks like this right now...
import userElements = require('./UserElements');
import userMapping = require('./UserMapping');
export class UserControls {
// code
}
No matter what combinations I have tried, this is the only format/syntax that doesn't throw errors in Visual Studio. But from what I see in the RavenDB project, I should very much be able to declare it like ...
import userElements = require('utils/UserElements');
import userMapping = require('utils/UserMapping');
export class UserControls {
// some code
}
No matter what combinations I have tried, this is the only format/syntax that doesn't throw errors in Visual Studio. But from what I see in the RavenDB project, I should very much be able to declare it like ...
That is because they are using a drandalJS configuration to tell it how to resolve the file path. (see https://github.com/ayende/ravendb/blob/New3/Raven.Studio.Html5/App/main.js)
There isn't a similar configuration (basePath) for TypeScript at the moment. Your best option is to use relative paths as you've already noticed.
PS: an old but still relevant video that shows you how requirejs config works and relevance when using TypeScript https://www.youtube.com/watch?v=4AGQpv0MKsA&hd=1
The TypeScript compiler's module resolution algorithm is essentially undocumented, unfortunately. It tries to "split the difference" between AMD and CommonJS's module resolution rules, so it's somewhat hard to reason about.
What you're seeing here is an attempt to mimic CommonJS's "walk up the tree" resolution rule. When in the path C:\a\b\c\d resolving x, first C:\a\b\c\d\x is tried, then C:\a\b\c\x, then C:\a\b\x, and so on until it hits the root folder and gives up.
Can anyone explain to me how to use ReaderWriterOBJ in OpenSceneGraph? I want to load an obj file along with the mtl file. I have already built the solution for readerWriterObj code and created a dll file.
The ReaderWriter's are just file loaders. You have to use them in context of an application, like osgviewer, one of the examples included in OSG. If you've gone through the process of building OSG, you might have already built osgviewer, which will use the appropriate DLL's to load files.
eg
osgviewer FILE.obj
will open FILE.obj, with its associated material file[s].
after searching a lot, i am still unable to find one thing that whether can i use a lib***.a in my .java file or not.
i.e:
static {
// Library
System.loadLibrary("***");
}
i got this doubt when i read the line You must provide a native shared library that contains the implementation of these methods in the overview.html.
so can any one tell me whether can i use lib***.a in .java file or not.
If yes then how?
since you should not use the 'lib' prefix and '.so' suffix here. is written in the overview.html.
It seems that you can't. As far as I know, the Java native interface uses dynamic libraries to load code runtime; I'm sure that cannot be done with archive libraries (.a).