Skip to content

Instantly share code, notes, and snippets.

View y56's full-sized avatar
🌏
(* ̄▽ ̄)/‧☆*"`'*-.,_,.-*'`"*-.,_☆

Eugene y56

🌏
(* ̄▽ ̄)/‧☆*"`'*-.,_,.-*'`"*-.,_☆
View GitHub Profile
@y56
y56 / How to Install Wine 5.0 Stable in Ubuntu 18.04, 19.10
Created February 5, 2020 21:30
How to Install Wine 5.0 Stable in Ubuntu 18.04, 19.10
http://ubuntuhandbook.org/index.php/2020/01/install-wine-5-0-stable-ubuntu-18-04-19-10/
==========
How to Install Wine 5.0 Stable in Ubuntu 18.04, 19.10How to Install Wine 5.0 Stable in Ubuntu 18.04, 19.10
5.0 Stable in Ubuntu 18.04, 19.10
How to Install Wine 5.0 Stable in Ubuntu 18.04, 19.10
January 23, 2020 — 19 Comments
@y56
y56 / 'aaaaaa'.count('a') Out[1]: 6
Created February 2, 2020 23:01
'aaaaaa'.count('a')
'aaaaaa'.count('a')
6
@y56
y56 / List of all unique characters in a string
Created February 2, 2020 22:54
List of all unique characters in a string?
https://stackoverflow.com/questions/13902805/list-of-all-unique-characters-in-a-string
```
In [10]: ''.join(set('aaabcabccd'))
Out[10]: 'acbd'
```
```
In [1]: list(set('aaabcabccd'))
Out[1]: ['a', 'c', 'b', 'd']
@y56
y56 / Convert string to ASCII value python
Created February 2, 2020 20:01
Convert string to ASCII value python
https://stackoverflow.com/questions/8452961/convert-string-to-ascii-value-python
>>> s = 'hi'
>>> [ord(c) for c in s]
[104, 105]
>>> s = "hello world"
>>> ''.join(str(ord(c)) for c in s)
'10410110810811132119111114108100'
@y56
y56 / python format
Created February 2, 2020 19:54
python format()
>>> "You get {product} when you multiply {1} with {0}".format(5.5, 3, product=16.5)
'You get 16.5 when you multiply 3 with 5.5'
@y56
y56 / unpacking operator
Created February 2, 2020 19:50
unpacking operator
Unpacking With the Asterisk Operators: * & **
https://realpython.com/python-kwargs-and-args/#unpacking-with-the-asterisk-operators
@y56
y56 / How to change critically low battery value
Created February 1, 2020 23:18
How to change critically low battery value?
https://askubuntu.com/questions/92794/how-to-change-critically-low-battery-value
I would like my laptop to hibernate itself when the battery level is 10% to be sure it has enough power to complete the operation properly. Actually if I don't pay attention my laptop informs me it will hibernate when it's too late, so instead it brutally shuts down. This kills lithium batteries and is not acceptable.
Start dconf-editor
Browse to org -> gnome -> settings-daemon -> plugins -> power
Change the values of percentage-critical and percentage-action to the level you require
@y56
y56 / learn new python stuff
Created January 27, 2020 09:55
learn new python stuff
def ran_check1(num, low, high):
return int(num in range(low, high))
def ran_check2(num,low,high):
if num in range(low,high):
print('{num} is not in the range of {low} and {high}')
else:
print('{num} is not in the range of {low} and {high}')
ran_check1(1,2,3)
@y56
y56 / Python inverse function of id(…) built-in function
Created January 27, 2020 08:14
Python inverse function of id(…) built-in function
https://stackoverflow.com/questions/24815771/python-inverse-function-of-id-built-in-function
================================
Is there a reverse or inverse of the id built-in function?
I was thinking of using it to encode and decode string without taking too much time or having a lot of overhead like the PyCrypto library.
The need for me is quite simple so I don't want to use PyCrypto for a simple encode and decode.
Something like:
@y56
y56 / = =
Created January 27, 2020 07:56
= =
= =
https://robertheaton.com/2014/02/09/pythons-pass-by-object-reference-as-explained-by-philip-k-dick/
This article makes things complicated.
Forget about the box metaphore in it.
Variablea are copied to functions by address.
Inside a function, while some operations (like .append()) are applied through dereferencing ,
others like reassignment are done by assigning a new address.