alias

How to create an extern alias for System.Core?

柔情痞子 提交于 2019-12-12 09:45:33
问题 I absolutely need an extern alias for System.Core in my project. Unfortunately, in a .Net 4.0 project, you cannot even add a reference to System.Core because, apparently, the build system includes it by default. Does anyone have any idea on how I can coerce the system to let me specify an extern alias for this lib? Thanks! 回答1: This question is old but I ran into the same problem. As far as I understood, this is due to Visual Studio implicitly adding a reference to System.Core. You can

Avoid object aliasing in python?

假装没事ソ 提交于 2019-12-12 09:39:04
问题 I am trying to write a function to check whether a list is sorted (returning True or False ). How can I avoid multiple variables pointing to the same thing? def is_sorted(t): a = t a.sort() When I do that, it sorts both a and t . How can I avoid this? 回答1: Here is the O(n) way to do it >>> from itertools import islice, izip >>> def is_sorted(L): ... return all(i<=j for i,j in izip(L, islice(L,1,None))) ... >>> is_sorted(range(50)) True >>> is_sorted(range(50)+[20]) False It shortcircuits, so

Use SQL keyword as alias name of a column

此生再无相见时 提交于 2019-12-12 09:05:09
问题 I'm executing the following query but it is giving syntax error. Because the keyword key is registered in SQL SELECT `id` AS key, `country_name` AS value FROM countries I also tried using brackets like this but it's not working: SELECT `id` AS [key], `country_name` AS value FROM countries How to deal with it? 回答1: Use backtick(`) or Single Quote(') to give alias name of column in MySQL. Try this: SELECT `id` AS 'key', `country_name` AS value FROM countries; OR SELECT `id` AS `key`, `country

bash_aliases and awk escaping of quotes

别等时光非礼了梦想. 提交于 2019-12-12 08:46:52
问题 I'm trying to create an alias for a command to see the memory use, ps -u user -o rss,command | grep -v peruser | awk '{sum+=$1} END {print sum/1024}' but, the naive, #.bash_aliases alias totalmem='ps -u user -o rss,command | grep -v peruser | awk '{sum+=$1} END {print sum/1024}'' gives errors: -bash: alias: END: not found -bash: alias: {print: not found -bash: alias: sum/1024}: not found I've tried with double quotes, totalmem ="ps ... |awk '{sum+=$1} END {print sum/1024}'" , or totalmem ='ps

What is “template<class T> using owner = T;”?

我只是一个虾纸丫 提交于 2019-12-12 08:11:58
问题 Below is excerpted from gsl.h of Microsoft's gsl library (https://github.com/microsoft/gsl): namespace gsl { // // GSL.owner: ownership pointers // using std::unique_ptr; using std::shared_ptr; template<class T> using owner = T; ... }; I cannot understand what the following alias template means: template<class T> using owner = T; Any explanations? 回答1: It means that for every T , owner<T> is an alias for T . 回答2: It can be used as annotation to show which pointers are 'owner' ie: Example of

Is it possible to declare an alias with .net type?

£可爱£侵袭症+ 提交于 2019-12-12 07:25:08
问题 Is it possible to declare an alias with .net type ? in c# and if so how ? 回答1: For example: using MatchBuilderFactoryFunc = System.Func< IndexerBase.RequestMatching.RequestFreeTextAnalyzeParameter, System.Collections.Generic.IEnumerable< IndexerBase.RequestMatching.IMatchBuilder>>; And after all use it as simple type: MatchBuilderFactoryFunc f = ... 回答2: As others have said, use the "using alias=type;" form of the using directive. Couple things about that: 1) It's got to be the first thing in

How do I expand commands within a bash alias?

血红的双手。 提交于 2019-12-12 07:22:44
问题 I'd like to create an alias that runs git pull origin <current branch name> I can get the current branch name with git rev-parse --abbrev-ref HEAD . But how do I put that 2nd command within the first in a bash alias? I've tried alias gup="git pull origin `git rev-parse --abbrev-ref HEAD`" and alias gup="git pull origin $(git rev-parse --abbrev-ref HEAD)" but both result in the initial branch name in the alias, not the branch name at the time the command is run. 回答1: The immediate problem is

How can I “add aliases” to enum values when I don't control the source?

こ雲淡風輕ζ 提交于 2019-12-12 06:47:19
问题 (Followup question to this one) I'm writing a program that uses a library, whose header file defines enum foo : unsigned { first_foo, second_foo }; Now, I want to add some aliases to foo values. If I were in control of the library's source, I would write: enum foo : unsigned { first_foo, second_foo, best_foo = first_foo, worst_foo = second_foo, oldest_foo = first_foo, newest_foo = second_foo; }; ... but I don't control the source. So, I would have liked to write: enum bar : foo { best_foo =

Using Rewrite in .htaccess instead of Alias in httpd.conf

亡梦爱人 提交于 2019-12-12 06:16:41
问题 Trying to setup up my own Weave server on shared host, obviously I cannot modify httpd.conf file so I try to find a work-around using Rewrite module and .htaccess. Based on documentation here https://wiki.mozilla.org/Labs/Weave/Sync/1.1/Setup and https://wiki.mozilla.org/Labs/Weave/User/1.0/Setup I created .htaccess RewriteEngine on RewriteRule ^1.1(.*) server-sync/1.1/index.php/$1 [L] RewriteRule ^1.0(.*) server-sync/1.0/index.php/$1 [L] RewriteRule ^user/1.0(.*) weaveserver-registration/1.0

Is there a way to create aliases for object methods in powershell?

只愿长相守 提交于 2019-12-12 04:55:55
问题 I'm finding that I am repeating myself in powershell scripts in some cases where execution context matters. Delayed string expansion is one such case: $MyString = 'The $animal says $sound.' function MakeNoise{ param($animal, $sound) $ExecutionContext.InvokeCommand.ExpandString($MyString) } PS> MakeNoise pig oink The pig says oink. That long ExpandString() line gets repeated frequently. I'd prefer that line to be terse like this: xs($MyString) xs $MyString $MyString | xs Any of these would be