EzDevInfo.com

alias interview questions

Top alias frequently asked interview questions

Can you define aliases for imported modules in Python?

In Python, is it possible to define an alias for an imported module?

For instance:

import a_ridiculously_long_module_name

...so that is has an alias of 'short_name'.


Source: (StackOverflow)

SQL - using alias in Group By

Just curious about SQL syntax. So if I have

SELECT 
 itemName as ItemName,
 substring(itemName, 1,1) as FirstLetter,
 Count(itemName)
FROM table1
GROUP BY itemName, FirstLetter

This would be incorrect because

GROUP BY itemName, FirstLetter 

really should be

GROUP BY itemName, substring(itemName, 1,1)

But why can't we simply use the former for convenience?


Source: (StackOverflow)

Advertisements

Quit and restart a clean R session from within R?

Is there a way I can make an alias within R that will execute q() and the restart a clean R session?

And yes, I am too lazy to type q() and then the letter R :)


Source: (StackOverflow)

How do I assign an alias to a function name in C++?

It's easy to create a new name for a type, a variable or a namespace. But how do I assign a new name to a function? For example, I want to use the name holler for printf. #define is obvious... any other way?

Solutions:

  1. #define holler printf
  2. void (*p)() = fn; //function pointer
  3. void (&r)() = fn; //function reference
  4. inline void g(){ f(); }

Source: (StackOverflow)

Make bash alias that takes parameter?

I used to use CShell (), which let you make an alias that takes a parameter. The notation was something like

alias junk="mv \\!* ~/.Trash"

In Bash this does not seem to work. Given that Bash has a multitude of useful features, I would assume that this one has been implemented but I am wondering how.


Source: (StackOverflow)

How can I write a Powershell alias with arguments in the middle?

I'm trying to set up a Windows PowerShell alias to run MinGW's g++ executable with certain parameters. However, these parameters need to come after the file name and other arguments. I don't want to go through the hassle of trying to set up a function and all of that. Is there a way to simply say something like:

alias mybuild="g++ {args} -lib1 -lib2 ..."

or something along those lines? I am not all that familiar with PowerShell and I'm having a difficult time finding a solution. Anyone?


Source: (StackOverflow)

Git alias with positional parameters

Basically I'm trying to alias:

git files 9fa3

...to execute the command:

git diff --name-status 9fa3^ 9fa3

but git doesn't appear to pass positional parameters to the alias command. I have tried:

[alias]
    files = "!git diff --name-status $1^ $1"
    files = "!git diff --name-status {1}^ {1}"

...and a few others but those didn't work.

The degenerate case would be:

$ git echo_reverse_these_params a b c d e
e d c b a

...how can I make this work?


Source: (StackOverflow)

Should I use alias or alias_method?

I found a blog post on alias vs. alias_method. As shown in the example given in that blog post, I simply want to alias a method to another within the same class. Which should I use? I always see alias used, but someone told me alias_method is better.

Blog post link here


Source: (StackOverflow)

List Git aliases

How do I print a list of my git aliases, i.e., something analogous to the bash alias command?


Source: (StackOverflow)

Fixing 403 Forbidden on alias directory with Apache

I am trying to setup an alias to point to some directory on my filesystem not in DocumentRoot. Now I get a 403 Forbidden response. These are the steps taken: 1. edit http.conf, adding:

Alias /example "/Users/user/Documents/example"

then...

<Directory "/Users/user/Documents/example">
   Options Indexes FollowSymLinks MultiViews
   AllowOverride None
   Order allow,deny
   Allow from all</Directory>

2. setting permissions with chmod in terminal:

chmod 755 /Users/user/Documents/example

Now it should work? instead I get the access forbidden. This is the output from error_log:

[Sun Jul 24 06:57:57 2011] [error] [client xx.xx.xx.xx] (13)Permission denied: access to /example denied

Source: (StackOverflow)

Class alias in Ruby

I am developing a new Rails app based on a similar existing one. In my old app, I have Coupon class, which is very similar to Ticket in my new app. I want to reuse all code in Coupon, but with a new class name.

Since refactoring is cumbersome in Rails, I wonder if there is a way to create alias for a class in Ruby (similar to alias for attributes and methods).


Source: (StackOverflow)

How to alias 'git checkout' to 'git co'?

I'd like the command git co to be the same as typing git checkout.

A normal bash alias (alias co='checkout') doesn't work.


Source: (StackOverflow)

In C#, why is "int" an alias for System.Int32?

Since C# supports Int8, Int16, Int32 and Int64, why did the designers of the language choose to define int as an alias for Int32 instead of allowing it to vary depending on what the native architecture considers to be a word?

I have not had any specific need for int to behave differently than the way it does, I am only asking out of pure encyclopedic interest.

I would think that a 64-bit RISC architecture could conceivably exist which would most efficiently support only 64-bit quantities, and in which manipulations of 32-bit quantities would require extra operations. Such an architecture would be at a disadvantage in a world in which programs insist on using 32-bit integers, which is another way of saying that C#, becoming the language of the future and all, essentially prevents hardware designers from ever coming up with such an architecture in the future.

StackOverflow does not encourage speculating answers, so please answer only if your information comes from a dependable source. I have noticed that some members of SO are Microsoft insiders, so I was hoping that they might be able to enlighten us on this subject.

Note 1: I did in fact read all answers and all comments of SO: Is it safe to assume an int will always be 32 bits in C#? but did not find any hint as to the why that I am asking in this question.

Note 2: the viability of this question on SO is (inconclusively) discussed here: Meta: Can I ask a “why did they do it this way” type of question?


Source: (StackOverflow)

SQL Table Aliases - Good or Bad? [closed]

What are the pros and cons of using table aliases in SQL? I personally try to avoid them, as I think they make the code less readable (especially when reading through large where/and statements), but I'd be interested in hearing any counter-points to this. When is it generally a good idea to use table aliases, and do you have any preferred formats?


Source: (StackOverflow)

Can we alias a function in php?

is it possible to alias a function with a different name in PHP? if yes how ?

suppose we have this function sleep();

is there any quick way to make an alias called wait();

without writing this code

function wait ($seconds)  {
    sleep($seconds);
}

Source: (StackOverflow)