equivalent

Does .NET have an equivalent of **kwargs in Python?

孤街醉人 提交于 2019-12-10 20:45:54
问题 I haven't been able to find the answer to this question through the typical channels. In Python I could have the following function definition def do_the_needful(**kwargs): # Kwargs is now a dictionary # i.e. do_the_needful(spam=42, snake='like eggs', spanish='inquisition') # would produce {'spam': 42, 'snake': 'like eggs', 'spanish': 'inquisition' } I know .NET has the ParamArray , which produces a sequence of unnamed arguments, similar to the *args syntax in Python... Does .NET have an

Equivalent lsof -i in Solaris

回眸只為那壹抹淺笑 提交于 2019-12-10 18:43:54
问题 I have a fast question. I want to know what is the losf -i equivalent command in a Solaris system. I only want to show the files with network connection. Thank you!! 回答1: Here is a shell script that list all processes having open TCP or UDP ports on Solaris, you can limit it to a given port number by passing it as an argument: pfiles /proc/* 2>/dev/null | nawk -v port=$1 ' /^[0-9]/ { cmd=$2; type="unknown"; continue } $1 == "SOCK_STREAM" { type="tcp" } $1 == "SOCK_DGRAM" { type="udp" } $2 ~

Swift equivalent of Ruby's “each_cons”

江枫思渺然 提交于 2019-12-10 14:43:59
问题 Ruby Ruby has each_cons that can be used like this class Pair def initialize(left, right) @left = left @right = right end end votes = ["a", "b", "c", "d"] pairs = votes.each_cons(2).map { |vote| Pair.new(*vote) } p pairs # [#<Pair @left="a", @right="b">, #<Pair @left="b", @right="c">, #<Pair @left="c", @right="d">] Swift The same code in swift, but without the each_cons function struct Pair { let left: String let right: String } let votes = ["a", "b", "c", "d"] var pairs = [Pair]() for i in 1

Java equivalent of Python's “construct” library

a 夏天 提交于 2019-12-10 10:09:04
问题 Is there a Java equivalent of Python's "construct" library? I want to write "structs" like so: message = Struct("message", UBInt8("protocol"), UBInt16("length"), MetaField("data", lambda ctx: ctx["length"]) ) It doesn't have to specifically be a library with some sort of abstraction using the Java language. I mean, it could be a "portable" format, with an API for parsing the documents. I guess this could work out with XML, but it would be be a lot more ugly. I realize I could just inter

Proving equivalence of sequence definitions from Applicative and Monad

六眼飞鱼酱① 提交于 2019-12-08 17:43:30
问题 How can I properly prove that sequenceA :: (Traversable t, Applicative f) => t (f a) -> f (t a) sequenceA [] = pure [] sequenceA (x:xs) = pure (:) <*> x <*> sequenceA xs is essentially the same to monad inputs as sequenceA' :: Monad m => [m a] -> m [a] sequenceA' [] = return [] sequenceA' (x:xs) = do x' <- x xs' <- sequenceA' xs return (x':xs') In spite of the constraint Applicative and Monad of course. 回答1: Here's a proof sketch: Show that do x' <- x xs' <- sequenceA' xs return (x' : xs') is

mysql FIND_IN_SET equivalent to postgresql

人盡茶涼 提交于 2019-12-08 08:21:31
问题 select * from folder f,uploads u where u.id=f.folderId and FIND_IN_SET('8', '15,9,13,27') Please tell to me equivalent to predefind or userdefined postgresql function 回答1: You shouldn't be storing comma separated values in the first place, but you can do something like this: select * from folder f join uploads u ON u.id = f.folderId where '8' = ANY (string_to_array(some_column,',')) string_to_array() converts a string into a real array based on the passed delimiter 回答2: select * from folder f

What is a equivalent of Delphi “shl” in C#?

狂风中的少年 提交于 2019-12-08 03:38:01
问题 I'm making an application in C#, based on Delphi (converting code), but I found a command that I do not recognize (shl), and i want to know if there is any equivalent to C#. Thanks in advance. 回答1: Shl is left shift. Use << C# operator for the same effect. Example: uint value = 15; // 00001111 uint doubled = value << 1; // Result = 00011110 = 30 uint shiftFour = value << 4; // Result = 11110000 = 240 回答2: From Shl Keyword this is a bitwise shift left which from C# Bitwise Shift Operators

Is there any equivalent of JVisualVM on DotNET?

僤鯓⒐⒋嵵緔 提交于 2019-12-07 13:44:56
问题 I would like to know if there is an equivalent of the excellent Java JVisualVM (included with JDK, the command is "jvisualvm") on the DotNet platform ? JVisualVM is a great tool that allows developers and admins to have really useful monitoring on any running Java application, here is some features that it has : Graphical view of the threads status Memory/CPU graphs Live heap dump CPU/Memory profiling Garbage Collector / JIT utilization graphs JMX calls Is there any equivalent on DotNet ?

String.Format (.NET) equivalent in Java?

≯℡__Kan透↙ 提交于 2019-12-07 02:20:08
问题 The String.Format in .NET (maybe just VB.NET) convert {0}, {1}, ... into determined String, for example: Dim St As String = "Test: {0}, {1}" Console.WriteLine(String.Format(St, "Text1", "Text2")) I've tried to search in both Google and StackOverflows, but they all return number-string format. 回答1: The other suggestions are certainly good, but are more in the style of printf and its lineage which are more recent additions to Java. The code you posted looks to be inspired by MessageFormat.

mysql FIND_IN_SET equivalent to postgresql

白昼怎懂夜的黑 提交于 2019-12-06 16:28:00
select * from folder f,uploads u where u.id=f.folderId and FIND_IN_SET('8', '15,9,13,27') Please tell to me equivalent to predefind or userdefined postgresql function You shouldn't be storing comma separated values in the first place, but you can do something like this: select * from folder f join uploads u ON u.id = f.folderId where '8' = ANY (string_to_array(some_column,',')) string_to_array() converts a string into a real array based on the passed delimiter Mesbah Gueffaf select * from folder f,uploads u where u.id=f.folderId and '8' in('15','9','13','27') The FIND_IN_SET() function in