mirror of
https://github.com/LeCoupa/awesome-cheatsheets.git
synced 2026-01-27 21:58:02 -08:00
Compare commits
4 Commits
24000cc742
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8249479622 | ||
|
|
65ad8bf5d3 | ||
|
|
dba33d6681 | ||
|
|
9d8c46566b |
@@ -95,3 +95,9 @@ arr.reduce(callback[, initialValue]) // Apply a function against
|
|||||||
arr.reduceRight(callback[, initialValue]) // Apply a function against an accumulator and each value of the array (from right-to-left) as to reduce it to a single value.
|
arr.reduceRight(callback[, initialValue]) // Apply a function against an accumulator and each value of the array (from right-to-left) as to reduce it to a single value.
|
||||||
arr.some(callback[, initialValue]) // Returns true if at least one element in this array satisfies the provided testing function.
|
arr.some(callback[, initialValue]) // Returns true if at least one element in this array satisfies the provided testing function.
|
||||||
arr.values() // Returns a new Array Iterator object that contains the values for each index in the array.
|
arr.values() // Returns a new Array Iterator object that contains the values for each index in the array.
|
||||||
|
|
||||||
|
// String methods
|
||||||
|
String.charAt(index) // Returns the character at the specified index in a string.
|
||||||
|
String.indexOf(character) // Returns the index of the first occurrence of a specified value in a string.
|
||||||
|
String.substring(starting_index, ending_index) // Returns a new string that is a subset of the original string.
|
||||||
|
String.substring(starting_index) // Returns a substring from starting index to last index of string.
|
||||||
@@ -1,86 +0,0 @@
|
|||||||
"""
|
|
||||||
Python3 Programming Language Cheatsheet
|
|
||||||
"""
|
|
||||||
|
|
||||||
# Basics: ###
|
|
||||||
|
|
||||||
# Variables -- Python uses variables to define things that are subject to change.
|
|
||||||
# Operators -- There are several type of operators available in Python.
|
|
||||||
# Arithmetic operators:
|
|
||||||
# + ----------> Addition Operator
|
|
||||||
# - ----------> Subtraction Operator
|
|
||||||
# * ----------> Multiplication Operator
|
|
||||||
# / ----------> Division Operator
|
|
||||||
# % ----------> Modulus Operator
|
|
||||||
# ** ----------> Exponent Operator
|
|
||||||
# // ----------> Floor division Operator
|
|
||||||
|
|
||||||
# Comparision Operators:
|
|
||||||
# == ----------> Equals
|
|
||||||
# != ----------> Not equal to
|
|
||||||
# > ----------> Greater than
|
|
||||||
# < ----------> Less than
|
|
||||||
# >= ----------> Greater than or equal to
|
|
||||||
# <= ----------> Less than or equal to
|
|
||||||
|
|
||||||
# Assignment Operators:
|
|
||||||
# = ----------> Assigns value
|
|
||||||
# += ----------> Shorthand for addition to itself
|
|
||||||
# -= ----------> Shorthand for subtraction to itself
|
|
||||||
# *= ----------> Shorthand for multiplication to itself
|
|
||||||
# /= ----------> Shorthand for division to itself
|
|
||||||
# %= ----------> Shorthand for modulus of itself
|
|
||||||
# **= ----------> Shorthand for exponent of itself
|
|
||||||
# //= ----------> Shorthand for floor division to itself
|
|
||||||
|
|
||||||
# Bitwise Operators:
|
|
||||||
# & ----------> Binary AND
|
|
||||||
# | ----------> Binary OR
|
|
||||||
# ^ ----------> Binary XOR
|
|
||||||
# ~ ----------> Binary NOT
|
|
||||||
# << ----------> Binary left shift
|
|
||||||
# >> ----------> Binary Right Shift
|
|
||||||
|
|
||||||
|
|
||||||
# Strings -- Strings in python are denoted by either '' or "". Some list operations are:
|
|
||||||
# ex: a = "Manoj"
|
|
||||||
# a[0] =>'M'
|
|
||||||
# a[1] => 'a'
|
|
||||||
# a[1:] => Will print rest of characters from 1 to other
|
|
||||||
# a[:3] => Will print 0 to 2nd position
|
|
||||||
# a[:] => Will print whole string
|
|
||||||
# a[:-1] => Grab everything but the last letter
|
|
||||||
# a[::2] => Grab everything but go in step sizes of 2
|
|
||||||
# a[::-1] => We can use this to print a string backwards
|
|
||||||
|
|
||||||
##### Strings have a property named immutability. It means once a string is created, the elements within it cann't be changed or replaced.
|
|
||||||
##### We can use multiplication symbol to create repetition. ex: letter = 'z', letter*10 will print 'zzzzzzzzzz'.
|
|
||||||
##### Similarly there are many methods that are applicable on strings:
|
|
||||||
# ex: a = 'Hello'
|
|
||||||
# a.upper() => converts string into upper case ==> 'HELLO'
|
|
||||||
# a.lower() => converts string into lower case ==> 'hello'
|
|
||||||
# a.title() => title case a string ==> 'Hello'
|
|
||||||
# a.rstrip() => Right trim white spaces
|
|
||||||
# a.lstrip() => Left trim white spaces
|
|
||||||
# a.strip() => completely trim the white spaces
|
|
||||||
# a.split() => split a string by blank spaces
|
|
||||||
# a.split("value") => split the string after some specific value
|
|
||||||
# a.isalnum() => True if string consists of only alphanum characters (No symbols).
|
|
||||||
# a.isalpha() => True if string consists of only alphabetic characters (No symbols).
|
|
||||||
# a.islower() => True if string's alphabetic characters are all lower case.
|
|
||||||
# a.isnumeric() => True if string consists of only numeric characters.
|
|
||||||
# a.isspace() => True if string consists of only whitespace characters.
|
|
||||||
# a.istitle() => True if string is in title case
|
|
||||||
# a.isupper() => True if string's alphabetic characters are all upper case.
|
|
||||||
|
|
||||||
##### Some other useful string methods or functions that are available in python are:
|
|
||||||
# .replace("first_string", "second_string") => first_string will be replaced by second_string
|
|
||||||
# .startswith("") => search for a particular character in the starting of a string
|
|
||||||
# .endswith("") => search for a particular character in the end of a string
|
|
||||||
# .capitalize() => capitalize the first word of the string
|
|
||||||
# .swapcase() => swap the case of caharacter in a string
|
|
||||||
|
|
||||||
|
|
||||||
# Lists -- [a1, a2, "Some String", [b1, "some other string"]], This is an example of the list.
|
|
||||||
# There are several List Operations like
|
|
||||||
# a =
|
|
||||||
@@ -21,6 +21,7 @@ cat /proc/<process_id>/maps # Show the current virtual memory usage of a Linux
|
|||||||
ip r # Display ip of the server
|
ip r # Display ip of the server
|
||||||
|
|
||||||
lsof -i :9000 # List process running on port 9000
|
lsof -i :9000 # List process running on port 9000
|
||||||
|
kill -9 $(lsof -t -i:PORT) # Kill the process running on whichever port specified
|
||||||
|
|
||||||
journalctl -u minio.service -n 100 --no-pager # List last 100 logs for specific service
|
journalctl -u minio.service -n 100 --no-pager # List last 100 logs for specific service
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user