I'm getting all collections using [[NSFontManager sharedFontManager] collectionNames], but I see some untranslated strings (such as "com.apple.AllFonts"). There is a way to localize them? I see that Font Book does translate them successfully. Maybe I am doing something wrong.
Thanks,
—Albe
Apple prefixes all of its internal collection names with "com.apple", probably to avoid conflicts. Depending on what you're doing, you could:
Skip any collection name that begins with "com.apple" -- they're not collections created by the user.
If a collection begins with "com.apple", split it and just get the last part of the name. Something like if ([name hasPrefix:#"com.apple"]) name = [[name componentsSeparatedByString:#"."] objectAtIndex:2]; would work.
Related
I have several processes with almost same flow like "Get some parameters, extract data from database according to them and upload them to target". The parameters vary slightly across processes as well as targets but only a bit. Most of the process is the same. I would like to extract those differences to parameter-context and dynamically load them. My idea is to have parameters defined following way and then using them.
So core of question is:
How to dynamically choose which parameter group load and use?
Having several parameter contexts with same-named/different-valued parameters and dynamically switching them would be probably the best, but it is not possible as far as I know.
Also duplicating flows is out-of-the-table. Any error correction would be spread out over several places and maintenance would be a nightmare.
Moreover, I know I can do it like "In GenetrateFlowFile for process A set value1=#{A_value1} and in GenetrateFlowFile for process B set value1=#{B_value1}. But this is tedious, error-prone and scales kinda bad. Not speaking of situation when I can have dozens of parameters and several processes. Also it is a kind of hardcoding, not configuring...
I was hoping for something like defining group=A and then using it like value1=#{ ${ group:append('_value1') } } but this does not work - it is evaluated as parameter literally named ${ group:append('_value1') }.
TL;DR: Use evaluateELString().
The actual solution is to set in GenetrateFlowFile processor group=A and in next UpdateAttribute processor set the following:
value1=${ group:prepend('hash{ '):append('_value1 }'):replace('hash', '#'):evaluateELString() }
The magic being done here is "Take value of group slap around it #{ and _value1 } to make it valid NiFi Expression Language statement and then evaluate it." (Notice - the word hash and function replace is there since I didn´t manage to escape the # char right before {.)
If you would like to have your value1 at the beginning of the statement then you can use following code. The result is same, it is easier to use (often-changed value value1 is at the beginning of the statement) and is less readable "what is really going on?"-wise.
value1=${ literal('value1'):prepend('_'):prepend(${ group }):prepend('hash{ '):append(' }'):replace('hash', '#'):evaluateELString() }
I have a dropdown of vehicle makes that I want my users to start selecting as they type. First character typed should find the first character in the makes. The problem is that it searches anywhere in the make for a character and does not start at the first character like my users would like. For example... if you type an "r" you get: Alfa Romeo, Aston Martin, Chevrolet, Chrysler, etc... well before you get a Renault.
I create my list from the database. My haml looks like this:
.field-row
= render partial:'/makes/make_select', locals:{id:'make_id'}
That calls this _make_select.html.haml
= collection_select :vehicle, id, Make.all.order(:name), :id, :name, {prompt:true}, {title:'Select Make', class:'make-select', 'data-allow-empty' => 'no'}
I cant seem to find any docs on Ruby that shows me the valid options for collection_select. Maybe there is an option that allows this?
I have read that I might need to use jQuery to accomplish this. Was just trying to figure out if there might be an easier way with just a simple option in the haml.
Let me know if there is anything else you would like to see.
thanks!
You could add logic to your controller and to check using a SQL query, something like this, depends on the database you're using.
#makes = Make.where('name LIKE ?', "#{params[character]}%")
Check out the MySql docs on pattern matching
https://dev.mysql.com/doc/refman/8.0/en/pattern-matching.html
You should not add your Model query inside a view, should add it.
In your above case, I suggest you use https://github.com/argerim/select2-rails it very powerful and already have what you need.
I would like to loop over all the variables in a single partial, but I can't find away to automate this.
The example:
I have a partial named _colors.scss, it only contains colour variables.
$facebook: #305897;
$twitter: #31aae1;
$google: #da4936;
$pinterest: #c9151a;
These are already used across the site so I can't reformat them as a list.
I would like to do something like, foreach var in _colors return mixin.
But I can't find away to access them without calling each individually...
I am sure I am missing something obvious, and would appreciate someone pointing it out :)
There is no shortcut for this. You'll have to create a list out of them yourself.
$facebook: #305897;
$twitter: #31aae1;
$google: #da4936;
$pinterest: #c9151a;
$social: $facebook, $twitter, $google, $pinterest;
I have a core data entity named "Folder". Each "Folder" has a 1-to-many relationship with the entity "File", and each file contains the field "filename".
What is a succinct way of producing an array of all of the filenames for a given folder?
I expected it to be something like:
NSManagedObject* folder = [self getSomeFolder];
NSArray* files = [folder valueForKey:#"files.#unionOfSet.filename"];
... but i've been having no luck getting it to go, and Apple's set operations guide has got me stumped.
Your solution is mostly correct, but you need to use -valueForKeyPath: instead of -valueForKey:. -valueForKey: is optimized for keys that do not contain multiple elements (separated by .).
A note item in Yojimbo's Applescript dictionary is defined as:
note item n [inh. database item] : A note item.
elements
contained by application.
properties
encrypted (boolean, r/o) : Is the note is encrypted?
contents (text) : The contents of the note. syn content
If this note is encrypted, the contents property is only readable
if permitted by the current security policies.
responds to
append, prepend.
In an attempt to export my data, I've been poking around with AppleScript, learning the language, etc, and currently have this:
tell application "Yojimbo"
repeat with EachNote in (note items in library)
display dialog (content of EachNote) as string
end repeat
end tell
What's confusing me is that, though the class defines the property "contents", I have to use "content" to retrieve the contents. Using "contents" results in this error:
Can’t make «class YNot» id "A0C9E19E-3106-44F9-97A6-A1A74AD77948"
of application "Yojimbo" into type string.
I'm assuming the "syn content" means it's a synonym, thus I should be able to use "content" and "contents" interchangeably. But apparently the synonym works, but the original does not...?
Also, more simply, why do the contents have to be coerced into a string? If I look at the properties on the object (via: (properties of EachNote) as string ), "contents" is a double-quoted string, though I realize this isn't necessarily "proof" that it's a string.
I'm still starting with AppleScript, so if I'm making a n00bish mistake, feel free to slap.
For others who find a similar confusion, I found help here: http://groups.google.com/group/yojimbo-talk/browse_thread/thread/d04f42db335c77e7
So all props go to Jim for being awesome!
The basics:
contents of an object is different than contents of a variable containing an object.
contents of a variable containing an object returns the object, not the object's contents, unlike every other property. Other properties return the property of the object in the variable, as expected.
This means, to get the contents of an object inside a variable, you need to use contents of contents of variable.
As demonstrated here, on my blog, yes, this is extremely strange. While var == var and var == contents of var, var != contents of (contents of var), so Applescript does indeed violate the identity principle for "contents" in this specific case. It does not chain this effect, though, so you shouldn't need to use contents of three layers deep (it'll work the same as two)
contents of contents of var works on objects as well, so it's always safe to use.
Many dictionaries use content as a synonym of contents, which avoids this whole problem. If desired, use content of var, and it'll work like other properties, always returning the object's content instead of the object.