Metalsmith: How to use run()? - metalsmith

The docs show a method run(files, fn):
Run all of the middleware functions on a dictionary of files and callback with fn(err, files), where files is the altered dictionary.
https://www.npmjs.com/package/metalsmith#runfiles-fn
How / When should it be used? I cannot find any more detailed information or examples.
Thanks for any hints :)

Related

PHPExcel_Settings::setCacheStorageMethod alternative in PhpSpreadsheet

I have this lines in my previous code
$cacheMethod = PHPExcel_CachedObjectStorageFactory:: cache_to_phpTemp;
$cacheSettings = array( 'memoryCacheSize' => '32MB');
PHPExcel_Settings::setCacheStorageMethod($cacheMethod, $cacheSettings);
Now I am trying to migrate to PhpSpreadsheet.
I am able to find class \PhpOffice\PhpSpreadsheet\Settings and methods setCache() and getCache(). But still not able find this options what i have.
Can anyone provide a way or an example to do what i am doing in PHPExcel into PhpSpreadsheet.
Caching was rewritten in PhpSpreadsheet (see documentation). If you need other caching options, you have to write your own PSR-16 cache or use one of the libraries mentioned in the documentation.

MacRuby: How to read a plist file?

I bet this is super simple and easy but can't find a basic example online. How can I read data from a plist file in my project using MacRuby?
Solution:
Turns out there's a few different ways to do it, but the cleanest I've found (so far) is to use the MacRuby helper method load_plist (which turns a plist file's contents into a hash). Also, if you're using XCode, you will need to get the file path relative to your app bundle:
# there's an AppConfig.plist file in my app bundle
config_path = NSBundle.mainBundle.pathForResource('AppConfig', ofType: 'plist')
#config = load_plist File.read(config_path)
This slide deck about MacRuby has some example code for accessing plist files (slides 77-80), the gist of which is that you open the file with NSDictionary.dictionaryWithContentsOfFile and then manipulate it as you would a Ruby Hash, then write it again with writeToFile_atomically. The NSDictionary documentation might be useful to you; you can find it here.

How to start working on as3yaml?

I am a newbie in yaml but I have to work on as3yaml which I don't have any knowledge on it.
I already downloaded as3yaml and attached to my project which is Flex project and I already read about yaml syntax.
But I don't have any ideas how can I start to work on it. I don't know how to new .yaml file with eclipse. I can't find any .yaml new file.
For now I understand that I have to create .yaml file and have to write the function on Actionscript Class to encode/decode the .yaml file.
And I also need some get started websites which I can learn myself.
Pls help!
I've never used Yaml as well, however it seems pretty straightforward:
var yaml:YAML = new YAML();
var data:Object = YAML.decode(yourYamlString);
You should really try reading the docs. Also, I wouldn't recommend using YAML unless you really have to. If you can, use AMF (native, faster, parses directly into model) but if you want something a little more 'web standardized' you can use JSON with the as3core library to parse it.

How to work with hook_nodeapi after image thumbnail creation with ImageCache

A bit of a followup from a previous question.
As I mentioned in that question, my overall goal is to call a Ruby script after ImageCache does its magic with generating thumbnails and whatnot.
Sebi's suggestion from this question involved using hook_nodeapi.
Sadly, my Drupal knowledge of creating modules and/or hacking into existing modules is pretty limited.
So, for this question:
Should I create my own module or attempt to modify the ImageCache module?
How do I go about getting the generated thumbnail path (from ImageCache) to pass into my Ruby script?
edit
I found this question searching through SO...
Is it possible to do something similar in the _imagecache_cache function that would do what I want?
ie
function _imagecache_cache($presetname, $path) {
...
...
// check if deriv exists... (file was created between apaches request handler and reaching this code)
// otherwise try to create the derivative.
if (file_exists($dst) || imagecache_build_derivative($preset['actions'], $src, $dst)) {
imagecache_transfer($dst);
// call ruby script here
call('MY RUBY SCRIPT');
}
Don't hack into imagecache, remember every time you hack core/contrib modules god kills a kitten ;)
You should create a module that invokes hook_nodeapi, look at the api documentation to find the correct entry point for your script, nodeapi works on various different levels of the node process so you have to pick the correct one for you (it should become clear when you check the link out) http://api.drupal.org/api/function/hook_nodeapi
You won't be able to call the function you've shown because it is private so you'll have to find another route.
You could try and build the path up manually, you should be able to pull out the filename of the uploaded file and then append it to the directory structure, ugly but it should work. e.g.
If the uploaded file is called test123.jpg then it should be in /files/imagecache/thumbnails/test123/jpg (or something similar).
Hope it helps.

System::IO::Directory::GetFiles in c++

I am having trouble in storing the files in a string array from a directory in c++, using System::IO::Directory::GetFiles in c++
Also would like to know if we could copy an entire folder to a new destination/ in c++ like given in http://www.codeproject.com/KB/files/xdirectorycopy.aspx for c#
You can store the file names from a directory in a managed array like this:
System::String ^path = "c:\\";
cli::array<System::String ^>^ a = System::IO::Directory::GetFiles(path);
Console::WriteLine(a[0]);
Console::ReadKey();
As for how would you copy an entire folder... Simply recurse from a given root directory creating each directory and copying the files to the new location. If you are asking for code for this, then please say so, but at least try to figure it out for yourself first (i.e. show me what you have so far).
Check out the file listing program in Boost::FileSystem: http://www.boost.org/doc/libs/1_41_0/libs/filesystem/example/simple_ls.cpp. They iterate over all files, printing the paths, but it's trivial to store them instead.
Assuming you're on Win32, you're looking for the FindFirstFile and FindNextFile APIs.
C/C++ does not define a standard way to do this, though Boost::Filesystem provides a method if you need cross platform support.

Resources