Best way to specify variable in code snippet - naming-conventions

I've seen countless way to give a specific thing in code snippet.
For example : C:\Users\[YourUserName]\Documents or git clone <someUrl>.
Is there a official convention, or is it just a "put something that isn't confusing" thing ?

Related

Switch to the another language on the same page?

I am trying to add a language changer for Middleman and it's not generating the correct link. My default and root is English.
url_for("/#{current_page.path}", locale: :ja)
I would expect the equivalent for the current page in JA which is the same URL with JA prepended. Does anyone know how to fix this?
I'm a middleman beginner, but after doing a bunch of Googling it seems like this is a fairly common issue. I've tried to look through the middleman sources to see if I could find a solution, but I've been unable. I'm kinda disappointed about this, because it looks like middleman has first-class support for localizations. Being unable to easily link from one to another seems like a surprising omission.
What I've done is make a little helper that can swap localizations in paths, if needed.
def change_locale_in_path(path, locale)
locale_prefix = I18n.locale
path.gsub(/^#{locale_prefix}/, locale.to_s)
end
This isn't a great solution, though. It will need to be adjusted if you change the i18n :path, and won't work unless you mount_at_root: false. But, it worked well enough for me to move on. I really would love to see a better solution.
I found a few GitHub issues that seem to reference this problem. Here's one.
I am using the following helper to generate a URL for the current page in a different language. It was originally based on this gist, and then tweaked it a bit so that it works regardless of whether mount_at_root is used.
def current_url_for_locale(loc)
url_regex = /\A\/(?:(#{I18n.available_locales.join('|')})\/)?/
locale_root = url_for('/', locale: loc)
current_page.url.gsub(url_regex, '').blank? ?
locale_root :
current_page.url.gsub(url_regex, locale_root)
end

How do I apply the spacemacs command (setq-default...)

So I'm new to spacemacs, and am having a problem with my python tabs. I found this stackoverflow solution to the issue. The scenario he explained is exactly the problem Im having with my python layer, but I don't know how to apply the solution he gave, namely:
If that is the case, you can fix the problem by running
(setq-default python-indent-offset 4)
Where/how exactly do I run the command "(setq-default python-indent-offset 4)"? Do I put it in my spacemacs config? Or some where else?
Thanks!
I found the answer to this question as I was typing it up by way of the related questions (here).
Commands such as these go inside of your init.el config, which is accessed by typing SPC-f e i
Hope this helps all the spacemacs newbies out there. (Feel free anyone to correct me if i'm wrong or don't fully understand)
Edit 1
Just some background info for my answer for those who are curious. The command
(setq-default python-indent-offset 4)
is actually from the lisp family of programming languages. So spacemacs basically uses source code controlled configuration. It could probably have similarly went inside your spacemacs config as well (SPC f e d), although I believe init.el is the proper place for this type of setting

Aurelia quick start doesn't work

Did exactly as tutorial says. Totally copy and pasted then ran in firefox but doesn't render. One thing quick start doesn't address is where to put the html files that we create in the tutorial. DO we put them in the src folder or the main folder? Tried both doesn't work anyway . They have no file structure at the end to show. I'm sure I will get the comments of show your code but that is not what I am asking. I am asking what the file structure should look like.
They have created a cli experience which totally rocks for beginners.
Check it out. It will probably get you much further much faster.

Comments that control uncrustify behaviour

In this question (https://stackoverflow.com/questions/15097501/can-uncrustify-be-prevented-from-modifying-certain-sections-of-code) i learned that i can use *INDENT-OFF* to exclude uncrustify action on certain parts of code.
Unfortunately i was not able to find this information anywhere else.
Does anybody know where i can look this up? Are there other comments which control uncrustifiy behaviour?
The *INDENT-ON* and *INDENT-OFF* are defined in the uncrustify_types.h file in the source code
See also Ben Gardner's comment: https://sourceforge.net/p/uncrustify/bugs/343/#0394

How to create documentation for instance variable and methods in Xcode?

I'd like to be able to Alt-Click an instance variable (or a method) as part of the program i created and read what it's purpose is.
The fact that Xcode is telling me the class variable is declared at - is nice but not enough. In this case i'd like to see custom text i typed to describe what an asset really is. Additionally type of the ivar would also be useful to know.
How can this be done? In this case, i wonder what exactly did i mean by assets
I specifically wonder if this information can be viewed from inside Xcode, similar to how Eclipse shows JavaDoc content.
You would need to create a documentation set for your project and install it in Xcode. appledoc can help you with this. This is a command-line tool that can generate documentation in Apple's style from specially formatted comments in your headers. You can also integrate this into your build process with a run script build phase, so that documentation is always up-to-date.
For small projects, it's usually not worth the effort though and you're probably better off just adding comments to your header files and jumping there with Cmd-click (Ctrl+Cmd+left-arrow to go back to where you came from).
You'll probably want to take a look at Apple's documentation on Documentation Sets as well as their article on generating doc sets using Doxygen. The latter is based on Xcode 3.x, so how relevant it is is somewhat questionable, but it'd be a good idea to take a look nonetheless.
That said, if you decide to use Doxygen (alternatives like HeaderDoc can be used for documentation, but I'm not sure what's available to you as far as creating doc sets goes), it looks like the main point is you'll want to throw GENERATE_DOCSET=YES into your Doxyfile (or whatever you decide to call it). After that, you'd just throw the results into ~/Library/Developer/Shared/Documentation/DocSets (according to Doxygen's documentation). I don't know whether this works in Xcode 4.x - it's worth a shot though, and it'd be nice to hear back on it.
Note: most of this was based on this answer by Barry Wark. Figure credit is due there, since I wouldn't have bothered looking into this were it not for his answer.