This question already has answers here:
Adding a unit to a number in Sass
(2 answers)
Closed 6 years ago.
Simple one this (hopefully with a simple solution).
Sass is compiling this....
font-size:(30/13)em;
into this....
font-size: 2.30769 em;
The space before the em makes it invalid and Chrome ignores it.
Any ideas?
(oh and before anybody asks why I'm dividing one number by another, I've simplified a formula to make the question simpler, normally there would be variables in there).
Hmm, I think you can use:
font-size:(30em/13);
to fix this. (At least, that's what compiles properly in Sass for me.) Although, if you're using variables, that could change things (if you can't have the em inside of the variable).
In which case, you could try:
font-size:$var*1em;
Which works out when Sass compiles it on my machine.
Related
This question already has answers here:
Pretty-print for shell script
(4 answers)
Closed 7 years ago.
Talking about good coding practices. My code is getting bigger and bigger and I want to check if all my "if", and "for" loops are properly written.
I think the proper word for that is indentation (thanks #tgo).
So I have this:
if(cond1 = cond2)
if(cond3=cond4)
bla
fi
fi
but I want the following:
if(cond1 = cond2)
if(cond3=cond4)
bla
fi
fi
But for instance using Sublimetext I cannot see it like this. So repeating the question, is there any tool, software or something that can help me with this?
update: Sublime text has an option for this. (Edit-> line-> Indent) I couldn't add this to the answer.
I use vim for all my code editting (and I write a lot of bash scripts) and it has smart indenting that defaults to normal, ok stuff for all the languages I use. If you have smart indenting turned on and copy and paste code from your first block into vim (properly set up with filetype=sh), it'll turn out like your second block.
This question already has an answer here:
Math with interpolated variables?
(1 answer)
Closed 8 years ago.
Here is my pen:codepen.io/JFrankParnell/pen/bNGQrQ
I'm trying to work with variables, only
#{$containwidth}px;
is working. Using #{$containwidth}%; trying to use percentages or math either will give compile errors or isnt working.
I have given the #control styles to show what I expected each of the test scss to produce.
you can use percentage.
width: percentage($othervar / $containwidth);
full pen :
http://codepen.io/bravocado/pen/XJWyYK
here is the doc :
http://sass-lang.com/documentation/Sass/Script/Functions.html#percentage-instance_method
hope it helps. :)
This question already has an answer here:
How to unhide an overriden function?
(1 answer)
Closed 9 years ago.
On my Matlab path there's a custom zeros function. I want to store a handle to the built-in zeros in a variable. How can I do that?
Thought about #(varargin)builtin('zeros',varargin{:}), but this would probably slow down the operation due to the string comparison.
Also, I've noticed that it's possible to refer to diag as #numel\diag, but this doesn't seem to work with other built-in functions (zeros in particular).
Suggestion #1
% At the beginning of your script:
rmpath('C:\the\folder\containing\the\custom\zeros');
builtInZeros = #zeros;
addpath('C:\the\folder\containing\the\custom\zeros');
% Calling the custom zeros later:
a = zeros(10, 20);
% Calling the built-in zeros:
b = builtInZeros(10, 20);
Suggestion #2
Put these three lines into your startup file:
rmpath('C:\the\folder\containing\the\custom\zeros');
builtInZeros = #zeros;
addpath('C:\the\folder\containing\the\custom\zeros');
Suggestion #3
It's definitely a dangerous idea to reuse the name of a built-in function. It ruins the readability of your scripts, making them much more difficult to maintain. So if you have control over the custom zeros function, then rename it to something else. Use a name which describes how the custom version is different from the built-in one (for example, call it fastZeros if it's faster).
Well, this doesn't give you an exact answer to your question, but it could solve the problem:
I think this seems to be a good solution:
matlabcentral: How to call a shadowed function
Withn the last post:
Just stumbled upon this problem and found the following solution: For
example, I have matlab svmtrain shadowed by libsvm toolbox:
which svmtrain -all
C:\Projects\Ichilov\Misc\MVPA\libsvm-mat-3.0-1\svmtrain.mexw64
C:\Program Files\MATLAB\R2009b\toolbox\bioinfo\biolearning\svmtrain.m
% Shadowed
But I can access the original function by using str2func:
org_svmtrain = str2func([matlabroot '\toolbox\bioinfo\biolearning\svmtrain'])
and then simply calling:
org_svmtrain(training, groupnames)
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Placement of the asterisk in Objective-C
I'm new to XCode, coming from C#. What is the difference between the two following syntax examples, specifically the location of the asterisk?
UITabBarItem* tabBarItem
and
UITabBarItem *tabBarItem
When do you use one syntax over the other?
Both mean the same. There is no difference between the two and it is a matter of preference. I personally prefer the second way because it looks cleaner when have multiple pointers.
UITabBarItem *tabBarItemOne, *tabBarItemTwo ; // Looks cleaner :)
than
UITabBarItem* tabBarItemOne, *tabBarItemTwo ;
There is no difference, just preference. Both declare a pointer to a UITabBarItem.
This question already has answers here:
Encoding Ruby on Rails code?
(5 answers)
Closed 4 years ago.
Is there a ruby obfuscator or "compiler"?
There are a few options, like RubyScript2Exe or AllInOneRuby. However, all obfuscators of interpreted languages tend to have a serious flaw: they usually don't understand more sophisticated metaprogramming techniques.
That is, they can't necessarily tell that something like foo.send(:bar, ...) is an invocation on the bar method in a completely different library, or that eval("require %w{abc def ghi}") means to require three different libraries. These are trivial examples -- things get much more complex when you throw method_missing and its ilk into the mix.
When an obfuscator encounters this sort of code, it will dutifully compile the appropriate instructions, but it may not know to also include certain libraries or other code from elsewhere. That can cause serious issues, since the dynamically included or required will not be available at runtime in a statically linked executable.
Unfortunately, many gems and libraries use sophisticated metaprogramming techniques. You'll likely get into trouble here if you try to use obfuscation and expect your program to have the same behavior. Worse still, because there are so many levels of indirection, if a bug occurs in the obfuscated version, you may never know what exactly happened or how to reproduce it.
Depending on what you are trying to do, there is a Gem that will allow you to create a C extension from a Ruby script which can then be used as a require inside your Ruby app. Its called ruby2cext. It will obfuscate all of your code into C and the you can require the .so in a separate Ruby script and it will function like a normal Ruby script.
RubyScript2Exe - http://www.erikveen.dds.nl/rubyscript2exe/