This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bpy | |
orig_arm = bpy.data.objects['Armature'] | |
bpy.context.view_layer.objects.active = orig_arm | |
bone_collection = orig_arm.data.collections.new('Orig') | |
bpy.ops.object.mode_set(mode='EDIT', toggle=True) | |
orig_names = [] | |
for b in list(orig_arm.data.bones): | |
orig_name = b.name | |
orig_bone = orig_arm.data.edit_bones[orig_name] | |
bone_collection.assign(orig_bone) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Download/Copy all related *.zip files in one directory. | |
Open terminal and change to that directory which has all zip files. | |
Enter command zip -s- FILE_NAME.zip -O COMBINED_FILE.zip | |
Enter unzip COMBINED_FILE.zip |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def print_stats(y_true, y_pred): | |
print(f'Total accuracy: {accuracy_score(y_true, y_pred)}') | |
print() | |
cm = pd.DataFrame(confusion_matrix(y_true, y_pred), | |
columns=pd.MultiIndex.from_arrays([['not_fit', 'fit']], names=['My fit']), | |
index=['not_fit', 'fit'], | |
) | |
cm.index.name = 'Toloka fit' | |
print('Confusion matrix') | |
print(cm) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# register file moved without svn mv | |
set -eu | |
shopt -s expand_aliases | |
. ~/.bash_aliases | |
old=$1 | |
new=$2 | |
tmp=$(mktemp svnmove.XXXXXX) | |
svn rm --keep-local "$new" | |
mv "$new" "$tmp" | |
svn revert "$old" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# After Ubuntu 16.04, Systemd becomes the default. | |
# It is simpler than https://gist.github.com/Doowon/38910829898a6624ce4ed554f082c4dd | |
[Unit] | |
Description=Jupyter Notebook | |
[Service] | |
Type=simple | |
PIDFile=/run/jupyter.pid | |
ExecStart=/home/phil/Enthought/Canopy_64bit/User/bin/jupyter-notebook --config=/home/phil/.jupyter/jupyter_notebook_config.py |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sqlalchemy.dialects import postgresql | |
def bulk_upsert(session: Session, | |
items: Sequence[Mapping[str, Any]]): | |
session.execute( | |
postgresql.insert(MyModel.__table__) | |
.values(items) | |
.on_conflict_do_update( | |
index_elements=[MyModel.id], | |
set_={MyModel.my_field.name: 'new_value'}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from scipy.sparse import csr_matrix | |
import numpy as np | |
def make_sparse(clf): | |
""" | |
Make sklearn.svm.SVC trained on dense data work on sparse features without fitting if again. | |
""" | |
clf._sparse = True | |
clf.support_vectors_ = csr_matrix(clf.support_vectors_) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import scipy as sp | |
import scipy.sparse | |
import tempfile | |
def hstack(parts): | |
with tempfile.TemporaryFile() as data_file, tempfile.TemporaryFile() as indices_file: | |
data = np.memmap(data_file, | |
dtype=parts[0].dtype, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import tkinter | |
import time | |
master = tkinter.Tk() | |
canvas = tkinter.Canvas(master, width=1000, height=1000) | |
canvas.pack() | |
def animation(): | |
def draw_point(x, y, c='black'): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo kill -9 $(ps aux | grep <name> | awk '{print $2}') |
NewerOlder