-
Notifications
You must be signed in to change notification settings - Fork 7
/
everything.txt
132 lines (70 loc) · 2.2 KB
/
everything.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
everything
------------
module
===================
python -m http.server
python -m json.tools
python -m idlelib.idle
String manipulation
=====================
left pad
convert repeated spaces to one space
.. code-block:: python
import re; re.sub(r"[ ]+", ' ', 'this sentence has non-uniform spaces')
The above snippet clears out the repeated spaces in a text and replaces it with single space.
re is a regular expression module to find more than one occurrences of space with '[ ]+'.
password
===================
.. code-block:: python
import random, string; "".join([random.choice(string.ascii_letters + string.digits) for i in range(8)])
xkcd password
.. code-block:: python
import random;words=open('/usr/share/dict/words').read().split(); "-".join([random.choice(words) for _ in range(4)])
pronouncable passwords
import random, string, itertools;
"".join(itertools.chain(*zip([random.choice(string.ascii_lowercase) for _ in range(6)], [random.choice('aeiou') for _ in range(6)])))
file conversions
===================
csv to json
json to csv
csv to sqlite
base64 encoding
base64 decoding
zip all .txt files in directory
batch rename files in directory
prettify json
file manipulation
===================
oxford comma
count words in file
count lines in file
add spaces after punctuation
add line numbers to text file
add line numbers to text file, don't number empty lines
delete trailing spaces
delete multiple newlines between paragraphs to keep only one line
first ten lines of file
last ten lines of file
games
=======
guess the number (binary search)
ascii art
================
asterisk triangle
banners (cowsay)
Mathematic
==============
pascal's triangle
unit convertor
ester eggs
============
import this
networking
==============
get local hostname
os.uname().nodename
or
import socket; print(socket.gethostname())
Get IP Address
import socket; s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM);s.connect(("8.8.8.8", 80));print(s.getsockname()[0])
(Or use urllib with json, read remote API.)