Skip to content

Instantly share code, notes, and snippets.

View kolygri's full-sized avatar
💭
Levelling up!

Konstantin Grigorov kolygri

💭
Levelling up!
View GitHub Profile
def to_dict_simple(d):
"""Returns the model properties as a dict without None values."""
clean = {}
for k, v in list(six.iteritems(d)):
if isinstance(v, list):
clean[k] = list(map(lambda x: to_dict_simple(x) if isinstance(x, dict) else x, v))
elif isinstance(v, dict):
nested = to_dict_simple(v)
if len(list(six.iterkeys(nested))) > 0:
# help: Print the list of all commands
h
# help: Print help about the certain command
h break
# print: Print the value of the expression
p some_obj
pp some_obj
@kolygri
kolygri / sshfs_flow
Last active August 19, 2019 18:02
mount/unmount remote directory
For mounting the remote directory use:
sudo sshfs -o allow_other <user_name>@<machine_name>:<abs_path_to_dir>/ ~/Desktop/<local_dir>/
When unmounting:
sudo umount -f ~/Desktop/<local_dir>/
Start new named session:
tmux new -s [session name]
Detach from session:
ctrl+b d
List sessions:
tmux ls
Attach to named session:
git submodule foreach ' [ "$path" = "module_name" ] || [ "$path" = "module_name" ] || git checkout B_CI'
When working remotely:
Mount remote directory on to the local drive using sshfs.
https://www.digitalocean.com/community/tutorials/how-to-use-sshfs-to-mount-remote-file-systems-over-ssh
@kolygri
kolygri / gist:c222adba4dff710c6c53bf83c0ed5d21
Created April 4, 2019 17:21
Custom loss function, silly example
from keras.models import Sequential
from keras.layers import Dense
import keras.backend as K
import numpy as np
def penalized_loss(reward):
def custom_loss(y_true, y_pred):
return K.mean(K.square(y_pred - y_true) - K.square(y_true - reward), axis=-1)
Squashing commits before merging, to make the git history tidy.
Make sure your branch is up to date with the master branch.
Run git rebase -i master.
You should see a list of commits, each commit starting with the word "pick".
Make sure the first commit says "pick" and change the rest from "pick" to "squash". -- This will squash each commit into the previous commit, which will continue until every commit is squashed into the first commit.
Save and close the editor.
It will give you the opportunity to change the commit message.
Save and close the editor again.
Then you have to force push the final, squashed commit: git push -f.
https://www.glassdoor.co.uk/Interview/Google-Technical-Solutions-Engineer-Interview-Questions-EI_IE9079.0,6_KO7,35.htm
Question 1: How do you list all the open programs in Linux command line?
I would like to paraphrase the quesiton to:
How do you list all the running processes using the Linux command line?
According to https://techdifferences.com/difference-between-program-and-process.html
"The major difference between program and process is that program is a group of instructions
to carry out a specified task whereas the process is a program in execution."
@kolygri
kolygri / RuningKerasModelH5.ipynb
Last active October 13, 2021 01:23
Untitled1.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@kolygri
kolygri / git_cheat-sheet.md
Created April 26, 2018 11:41 — forked from davfre/git_cheat-sheet.md
git commandline cheat-sheet