Skip to content

Instantly share code, notes, and snippets.

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

Eugene y56

🌏
(* ̄▽ ̄)/‧☆*"`'*-.,_,.-*'`"*-.,_☆
View GitHub Profile
@y56
y56 / how-to-set-up-jupyter-notebook-with-python-3-on-ubuntu-18-04
Created January 4, 2020 11:25
how-to-set-up-jupyter-notebook-with-python-3-on-ubuntu-18-04
https://www.digitalocean.com/community/tutorials/how-to-set-up-jupyter-notebook-with-python-3-on-ubuntu-18-04
@y56
y56 / spyder color schem monokai yorked
Created January 6, 2020 00:25
spyder color schem monokai yorked
https://imgur.com/UN2Cjwj
https://imgur.com/a/UzOz3u5
<blockquote class="imgur-embed-pub" lang="en" data-id="a/UzOz3u5" data-context="false" ><a href="//imgur.com/a/UzOz3u5"></a></blockquote><script async src="//s.imgur.com/min/embed.js" charset="utf-8"></script>
@y56
y56 / xdg-open filename
Created January 18, 2020 04:33
xdg-open filename
It can also be done by using xdg-open filename.
Command will open the file with it's default application and it also used to open the urls .
@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.
@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 / 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 / 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 / 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 / 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 / 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'