Skip to content

Instantly share code, notes, and snippets.

#
# Always install local overrides first
#
/app/docker/docker-bootstrap.sh
STEP_CNT=4
echo_step() {
cat <<EOF
# import html
import html
s = '<html><head></head><body><h1>GeeksForGeeks</h1></body></html>'
# Using html.escape() method
gfg = html.escape(s)
print(gfg)
#Вывод:
>>> import phonenumbers
>>> x = phonenumbers.parse("+442083661177", None)
>>> print(x)
Country Code: 44 National Number: 2083661177 Leading Zero: False
>>> type(x)
<class 'phonenumbers.phonenumber.PhoneNumber'>
>>> y = phonenumbers.parse("020 8366 1177", "GB")
>>> print(y)
Country Code: 44 National Number: 2083661177 Leading Zero: False
>>> x == y
import time
def slow(seconds):
def decorator_slow(func):
def wrapper( * args, ** kwargs):
print(f '{func.__name__} sleeping {seconds} second')
time.sleep(seconds)
result_value = func( * args, ** kwargs)
return result_value
return wrapper
return decorator_slow
# This is a sample config file that you can use as a reference for building your own.
# The "features" section describes how to map your input events into ML features that Metarank understands.
# See doc/feature_extractors.md for a general overview of possible things you can do, and doc/features
# for detailed per-extractor configuration options.
# These features can be shared between multiple models, so if you have a model A using features 1-2-3 and
# a model B using features 1-2, then all three features will be computed only once.
# You need to explicitely include a feture in the model configuration for Metarank to use it.
features:
Math.fround(0); // 0
Math.fround(1); // 1
Math.fround(1.337); // 1.3370000123977661
Math.fround(1.5); // 1.5
Math.fround(NaN); // NaN
list_ = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
print(list_)
# lambda function
lambda_list = list(map(lambda x: x * 2, list_))
# Map basically iterates every element
# in the list_ and returns the lambda
# function result
print(lambda_list)
from datetime import date
class Person:
def __init__(self, name, age):
self.name = name
self.age = age
# a class method to create a Person object by birth year.
@classmethod
def fromBirthYear(cls, name, year):
var numObj = 5.123456;
console.log(numObj.toPrecision()); // выведет '5.123456'
console.log(numObj.toPrecision(5)); // выведет '5.1235'
console.log(numObj.toPrecision(2)); // выведет '5.1'
console.log(numObj.toPrecision(1)); // выведет '5'
numObj = 0.000123;
console.log(numObj.toPrecision()); // выведет '0.000123'
howdoi print stack trace python
> import traceback
>
> try:
> 1/0
> except:
> print '>>> traceback <<<'
> traceback.print_exc()
> print '>>> end of traceback <<<'
> traceback.print_exc()