K-charreo
A blog of (mostly) linux-related tricks I've found in my way
Thursday, March 8, 2018
Wednesday, April 26, 2017
Monkey patch an instance method in Python3
import types
class SomeClass(object):
def __init__(self, x):
self.x = x
def some_method(self, y):
print("Original method", self.x + y)
# creates instance
instance = SomeClass(1)
# test instance's method
instance.some_method(1)
>>> Original method 2
# The method to patch
def new_method(self, y):
print("New method", self.x * y)
# monkeypatch using types.MethodType()
instance.some_method = types.MethodType(new_method, instance)
# test patched method
instance.some_method(10)
>>> New method 10
Wednesday, February 22, 2017
Change theme for the embedded terminal in gedit
The embedded terminal in gedit fetchs its theme from gnome-terminal. So that program must be first installed, then when it is configurated with a given profile theme, the same settings are used by gedit.
Wednesday, January 18, 2017
Update flash plugin for Opera
Worked for Opera version 42.0.2393.137
- Download plugin from http://get.adobe.com/flashplayer/. Get the .tar.gz version
- Unpack the contents in /usr/lib/adobe-flashplugin
- Restart Opera
Monday, December 12, 2016
Source .bashrc upon ssh connection
Trick source
Add this to you .bash_profile file:
# .profile
if [ -n "$BASH" ] && [ -r ~/.bashrc ]; then
. ~/.bashrc
fi
Friday, June 10, 2016
Anaconda2 jupyter notebook fix to export to pdf
Under Linux Mint, the problem arises when issuing:
$ ~/anaconda2/bin/jupyter nbconvert my_notebook.ipynb --to pdf
During the conversion, LaTeX fails with the error:
! LaTeX Error: File `ulem.sty' not found.
This is solved by installing the texlive-generic-recommended package:
$ sudo apt-get install texlive-generic-recommended
Get mathjax equations rendered under wkhtmltopdf
Trick source
Try using --javascript-delay [ms]. [ms] is the time in milliseconds wkhtmltopdf waits for complex scripts to finish. --javascript-delay 25000 is a good value to get the job done
Subscribe to:
Posts (Atom)