Search By Label
# Ensure the value is one or more [value, 1].min # Ensure the value is 100 or less [value, 100].max
docker system prune
//example const double = (x) => x * 2; const square = (x) => x * x; var output1 = double(2); var output2 = square(output1); console.log(output2); var output_final = square(double(2)); console.log(output_final);
# Syntax lambda arguments: expression # Example of use add = lambda x, y: x + y # Defines a lambda function that adds two numbers result = add(5, 3) # Calls the lambda function with arguments 5 and 3 print(result) # Output: 8
# define a command class class AuthenticateUser prepend SimpleCommand # optional, initialize the command with some arguments def initialize(email, password) @email = email @password = password end # mandatory: define a #call method. its return value will be available # through #result def call if user = User.find_by(email: @email)&.authenticate(@password) ... end
AuthenticateUser.call(session_params[:email], session_params[:password])
def my_method(value:, second_value:) puts "value #{value}, second_value #{second_value}" end my_method(value: 'value one', second_value: 'value two')
module SimpleCommand def self.included(klass) klass.class_eval do def self.call(*args, **kwargs) puts "args #{args}" new(*args, **kwargs).call end end end end
module SimpleCommand def self.included(klass) klass.extend(ClassMethods) end module ClassMethods def call(*args, **kwargs) new(*args, **kwargs).call end end end
class NamedArguments include SimpleCommand def initialize(value: , second:) @value = value @second = second end def call puts "the method in myClass @value: #{@value}, @second #{@second}" end end
NamedArguments.call(value: 'the value', second: 'from second')
class SimpleArguments include SimpleCommand def initialize(valueOne, valueTwo) @valueOne = valueOne @valueTwo = valueTwo end def call puts "the method in myClass @value: #{@valueOne}, @second #{@valueTwo}" end end
SimpleArguments.call('arg one', 'arg two')
from functools import lru_cache
@lru_cache(maxsize= 128) #cache can save up to 128 entries and optimize execution
def fib_with_cache(n):
if n < 2:
return n
return fib_with_cache(n-1)+ fib_with_cache(n-2)
lambda = lambda {|value| value ** value }
lambda.(10)
lambda.call(10)
lambda === 10
lambda[10]
proc = Proc.new {|value| value ** value }
proc.(10)
proc.call(10)
proc === 10
proc[10]
(1..10).to_a.each.with_index do |element, index|
puts "element #{element}, index: #{index}"
break if index == 3
end
catch :label do
(1..10).to_a.each.with_index do |e, index|
throw :label if condition
end
end
def my_method result = [] catch :completed do (1..10).to_a.each.with_index do |element, index| result << element throw :completed if index == 3 end end result end my_method => [1, 2, 3, 4]
def return_example values = [] (1..10).to_a.each_with_index do |element, index| values << element return values if index == 3 end end
return_example => [1, 2, 3, 4]
class Example: def __init__(self): self.public_var = "public" self._protected_var = "protected" self.__private_var = "private" def public_method(self): print("This is a public method") def _protected_method(self): print("This is a protected method") def __private_method(self): print("This is a private method") # Creating an instance of the class example_instance = Example() # Accessing public method and variable example_instance.public_method() print(example_instance.public_var) # Accessing protected method and variable example_instance._protected_method() print(example_instance._protected_var) # Trying to access private method and variable (will raise AttributeError) # example_instance.__private_method() # print(example_instance.__private_var)
Example
has three types of methods and variables:_
prefix and are typically considered non-public, although Python does not enforce this.__
prefix and are only accessible within the class itself.public_var
, public_method()
, _protected_var
, and _protected_method()
are respectively public and protected variables and methods._protected_var
and _protected_method()
can be accessed from outside the class but are typically considered non-public.__private_var
and __private_method()
are private variables and methods and can only be accessed within the class itself. Trying to access them from outside the class will raise an AttributeError
. first-letter
property for that..your_class_name::first-letter{ text-transform: capitalize; }
type()
to know the type of a variable for example:type(123) # <class 'int'>
123_145_877
view
s and which are table
s:SELECT * FROM information_schema.tables
{ "orderID":3, "productID":2, "quantity":4, "orderValue":16.60, "links":[ { "rel":"customer", "href":"https://adventure-works.com/customers/3", "action":"GET", "types":["text/xml","application/json"] }, { "rel":"customer", "href":"https://adventure-works.com/customers/3", "action":"PUT", "types":["application/x-www-form-urlencoded"] }, { "rel":"customer", "href":"https://adventure-works.com/customers/3", "action":"DELETE", "types":[] }, { "rel":"self", "href":"https://adventure-works.com/orders/3", "action":"GET", "types":["text/xml","application/json"] }, { "rel":"self", "href":"https://adventure-works.com/orders/3", "action":"PUT", "types":["application/x-www-form-urlencoded"] }, { "rel":"self", "href":"https://adventure-works.com/orders/3", "action":"DELETE", "types":[] }] }