I'm trying to set up a Vue.js project and I'm wanting to brush up on my Sass, I can't seem to get the variables in my "_variables.scss" file to be recognized. Everything appears to be compiling correctly, I have a "_header.scss" partial as well as the variables one, they are both accessed with a "#use" statement in "main.scss" which then compiles to "index.css".
I can access in variables if I make a class within the variables partial, but not if I make a class using a variable within the header partial, I'm struggling to see what I've done wrong.
Related
I know this question has been asked before, but I am struggling to find an answer that fits my needs, or is for the most up to date version of Laravel.
Basically, I have a load of variables that will be created using data from the Route and the database. For example, I need to use the Route to set a variable called "current_page" which extracts details from the "pages" table using the unique url column. ($current_page = Page::where('url', <url-taken-from-route>)->first();)
$current_page will need to contain several relationships. There are also other global variables such as $current_site (this is a kind of multi-site environment with one home page and nested microsites) etc.
I feel the configuration files are not the right place to create these variables as a) the value of the variables can be nested and complicated and b) they are not constants but data retrieved from a database.
View Composers obviously only work with views, and a Helper class just feels too generic considering we are dealing with pages, sites, and possibly other global variables.
I gather global variables are frowned upon, but these truly are global. The values will always be the same (albeit dynamic) on every occasion, and will be required by most views and controllers.
I have also thought about putting methods in my already existing Page and Site controllers so I can call Page::current(), but am not sure putting static methods in a mostly non-static controller is the right thing to do. Also, this would make a database call every time I called Page::current() rather than having the current page stored in memory somewhere.
For now, I have created a BaseController which all other controllers extend from. I have put these variables in the constructor and manually passed them to the view in each method. (I know that is messy and doesn't work for models).
So what is the best solution here? Where to declare a global variable that can be used anywhere, but doesn't feel hacky?
Thanks
We had Forify scan for our website code and fortify reported few issues. We are using CodeIgniter 3.1.9 framework. One of the issue they mentioned as
Possible Variable Overwrite' for function 'extract()' in file mysqli_utility.php.
As this is core file of CI framework, I'm not using this function directly and also I do not know where this function getting used by CI.
Will you please help to resolve the issue reported by Fortify? What could be the solution?
extract() imports variables from an array into the current symbol table. The phrase "current symbol table" basically means into the current scope of the code. For the usage in question, extract() is called inside a class method. So the current scope for the extracted vars will be in that method and that method only for that instance of the class.
CodeIgniter's core code does not define or use global variables. Unless code developed for the application uses globals (which it should not as "globals" are more of a "procedural programming" thing) the possibility of overwriting is exceedingly low.
I'm curious as to why the scan didn't pick up all the other times extract is used by CodeIgniter.
I am having a tough time with the following custom fact; details below.
The custom fact needs to look for a certain json file in the following folder. This displays the information when used within a manifest. But, when I add it to the custom fact, it does not work.
"/opt/${::hostname}/${::custom_variable}_${::fqdn}.json"
However, if I hard code the values as shown below, it works fine.
"/opt/host1.domain.com/mycompany_host1.json"
Note that the custom variable is defined on the Puppet console against "classification."
If you need to use facts within a custom fact, then you have to access them using Facter's .value method. Their values are accessible when the facts are referenced as symbol arguments to that method (e.g. Facter.value(:hostname)). To be able to use the Facter class, you have to require it in your Ruby file for the custom fact with:
require 'facter'
Then, you can use the variables in your above example in the normal way with string interpolation:
"/opt/#{Facter.value(:hostname)}/#{Facter.value(:custom_variable)}_#{Facter.value(:fqdn)}.json"
Note that the custom_variable fact needs to be assigned on a system during pluginsync before use in this custom fact. Also, you switched hostname and fqdn in your example above, so be sure those align correctly for you when you implement this.
https://docs.puppet.com/facter/3.6/custom_facts.html#using-other-facts
I've got a small problem (maybe it isnt even a problem)
I am making an application in Ruby, and the folder/file structure goes something like this:
OrderSet/
..item.rb
..file.rb
..order_object.rb
OrderGet/
..item.rb
..files.rb
..order.rb
As you can see I got two item.rb files, they are both different in class structure. Now I need to create an OrderSet/item.rb object, how do I specify it needs to look in OrderSet and does not get the OrderGet one?
I have to make clear, all files are required in the main rb file.
I have tried doing OrderSet.Item (the class is called Item inside the item.rb) but it complains about an ininitialized constant OrderSet
Thanks in advance!
[edit]
I have also tried to make modules out of it, maybe I don't understand the concept correctly, but I have tried it with OrderSet.Item.new (OrderSet as module name)
You could use a module to create a namespace - that way each set of classes would be encapsulated to what they do (the folder name from your example). So classes in OrderSet would be wrapped in a module for example OrderSet/item.rb would become:
module OrderSet
class Item
# methods and properties
end
end
Then you could use it like
new_order_set = OrderSet::Item.new
RubyMonk has a lesson called Modules As Namespaces which has more details and examples you can run in your browser.
I've made my own library in codeigniter and I have multiple functions with in the library.
Now these functions refer to a group of global variables.
Now what I've done inside the class is declare variables by saying protected $myvar; but when I refer to these variables within my functions,
I get errors saying $myvar is undefined... Please help...
In OOP context, you have to use $this->myvar, not just $myvar.