Server Bug Fix: Setting Apache SSL path dynamically based on domain

Original Source Link

Trying to replace SSL path with the current domain.

<IfModule mod_ssl.c>
                <VirtualHost *:443>
                        ServerAlias *
                        UseCanonicalName Off
                        DocumentRoot /var/www/html

                        SSLEngine on
                        SSLCertificateFile /etc/apache2/ssl/%0/server.crt
                        SSLCertificateKeyFile /etc/apache2/ssl/%0/server.key
                </VirtualHost>
</IfModule>

But this throws error on save.

SSLCertificateFile: file '/etc/apache2/ssl/%0/server.crt' does not exist or is empty

I come to know %0 only works for

VirtualDocumentRoot
VirtualDocumentRootIP
VirtualScriptAlias
VirtualScriptAliasIP

Any suggestions to achieve this in SSL path? TIA.

Tagged : / / / /

Code Bug Fix: I want to add vue js components during runtime to my webapp. How do I do this the best?

Original Source Link

I want to have a vue js web application where users can add new components. I want these components to be compiled during runtime and added to the dist folder, so the system can be lightweight. Then users can see the changes they made without having to restart the system. A refresh is possible but not optimal.
I’m not that experienced with vue.js so I don’t know where to start, what I should use…

If you have any idea please feel free to answer
Thanks in advance

This can be done with NPM run watch to your web app and you can start from Below URL’s

https://vuejs.org/v2/guide/installation.html

https://vuejs.org/v2/guide/components-registration.html

Thanks,
Mallik

Tagged : / / /

Code Bug Fix: Add localized and dynamic elements into Accordion

Original Source Link

I have some localized strings lets say:

no:
spørmål 1.
svar 1.
spørsmål 2.
svar 2

en:
question 1.
answer 1.
question 2.
answer 2.

At the same time, i need this accordion to be dynamic cause its not always the same strings thats going into the accordion.

I am keeping this question really open, cause i am not sure how to approach this at all.

Right now i have hardcoded the text in just to reference how i want it to look like in the end.
enter image description here

Tagged : / / /

Code Bug Fix: Python Class dynamic attribute access

Original Source Link

I want to access a class attribute by a string with its name.

Something like:

class a:
    b=[]

c='b'
eval('a.'+c+'=1')

But that doesn’t work in Python.
How can I do this?

Use setattr:

In [1]: class a:
   ...:     b = []
   ...:     

In [2]: setattr(a, 'b', 1)

In [3]: a.b
Out[3]: 1

Use getattr for the reverse:

In [4]: getattr(a, 'b')
Out[4]: 1

In [5]: getattr(a, 'x', 'default')
Out[5]: 'default'

I very much suspect, though, that there is a better way to achieve whatever your goal is. Have you tried using a dictionary instead of a class?

eval is for evaluation, use exec to ‘execute’ statements:

exec('a.'+c+'=1')

Yet, consider the risk of using both. And you can check out this answer for the difference between expressions and statements.

Since you are looking to set attribute by name, setattr explained in hop’s answer is a better practice, and safer than using exec.

Tagged : / / /

Code Bug Fix: How can you use CsvHelper Map to bind two objects dynamically?

Original Source Link

for CsvHelper i have used Map function for simple use for object

 MemberInfo dMember = new Contact().GetType().GetProperty("FirstName"));
 Map(typeof(Contact), dMember).Name("fname"); //works simple conversion

Here FirstName and fname both comes from configuration which is in Json file

Now next object which is a List of another class i cannot do.Name i need use .ConvertUsing and do some merging of fields
from CSV file i will have 3 fields Email1,Email2,Email3 which has to map to List where Email is a class and has property of an email address.

I was successful to find a way to use dynamic lambda function because Map(x=>x.Email) has to be custom and it should be able to do conversion for any object

    string field = "EmailAddresses"; //field name of a class
    string exp = $"c.{field}";
    var p = Expression.Parameter(typeof(Contact), "c");
    var e = DynamicExpressionParser.ParseLambda(new[] { p }, null, exp);

   // now here e.ReturnType is List<Email> but i cannot use List<Email> instead of dynamic because this 
    //function will also be called for other types so it has resolve at runtime. This maping fails with cannot convert Type Email to Type Object
 Map((Expression<Func<Contact, List<dynamic>>>)e).ConvertUsing(row =>
    {
        dynamic list = new List<ExpandoObject>();
        dynamic email = new ExpandoObject();
        var emailAddress = row.GetField("email_address");
        email.EmailAddress = (emailAddress != null) ? emailAddress:"[email protected]";
        list.Add(email);
        return list;
    }

Tagged : / / / /

Code Bug Fix: React native, dynamically position text

Original Source Link

I am trying to get the text to change position on the screen dynamically when I click a button.

I have my Text view like so:

<Text style={position: 'absolute', top: positionY, left: positionX,}></Text>

I have declared those variables at the top:

var positionX = 20,
var positionY = 20

When I press a button I run a function and change those values. I have used console.log to see if the values are changing and they are, however, the <Text> element does not change position.

Any ideas?

try to make the positionX and poitionY as state
to re render again when they change

const [positionX,setPositionX]=useState(20)
// same for y

and in the function

setPositionX(100)

If you want to animate anything within your app you need to do do with Animated Builtin Library .

make an Animated.Value then change it , whenever you change it if you have an
Animated.Text with the styles of Animated value, they will be changed.
go through Docs for more info https://reactnative.dev/docs/animated

If you dont want to use Animated you can easily use the LayoutAnimation before changing your state and it will handle it automatically https://reactnative.dev/docs/layoutanimation

Tagged : / /

Code Bug Fix: Dynamic inspection of table element on Blue Prism

Original Source Link

I inspected an element and this is the path
“/HTML/BODY(1)/DIV(1)/DIV(1)/DIV(2)/DIV(1)/DIV(1)/DIV(1)/TABLE(1)/TBODY(1)/TR(2)/TD(2)”

I want to make a loop, and the only dynamic part is TR(2)
“/HTML/BODY(1)/DIV(1)/DIV(1)/DIV(2)/DIV(1)/DIV(1)/DIV(1)/TABLE(1)/TBODY(1)/TR(2)/TD(2)”

I created a data item with a name of [Row] that has an initial value of 2 and created the path on the application modeler as dynamic.

I placed on these on “params”
/HTML/BODY(1)/DIV(1)/DIV(1)/DIV(2)/DIV(1)/DIV(1)/DIV(1)/TABLE(1)/TBODY(1)/TR(“&[Row]&”)/TD(2)

The error is
“Internal : Data items must be between [ and ]. Text must be between ” and “. Functions should be in the form FunctionName()”

When passing a Dynamic parameter, the parameter itself must be a valid Text string. As such, enclose the entire Path string in quotes:

"/HTML/BODY(1)/DIV(1)/DIV(1)/DIV(2)/DIV(1)/DIV(1)/DIV(1)/TABLE(1)/TBODY(1)/TR("&[Row]&")/TD(2)"

Tagged : / /