Skip to content

Instantly share code, notes, and snippets.

View fcoclavero's full-sized avatar

Francisco Clavero fcoclavero

View GitHub Profile
@fcoclavero
fcoclavero / NumpyArrayField.py
Last active May 2, 2018 22:11
Custom Django model field for storing Numpy 1-d arrays as JSON strings in the database. Useful for handling small amounts of arrays, keeping the relational data scheme.
class NumpyArrayField(models.TextField):
description = "A field to store numpy 1-d arrays as json strings. Requires Pandas."
def __init__(self, *args, **kwargs):
"""
Instance the field.
:param kwargs: max_length - the maximum array length
"""
super(NumpyArrayField, self).__init__(*args, **kwargs)
@fcoclavero
fcoclavero / document.md
Last active March 26, 2020 18:59
[Markdown anchors to header]
  • Just one # for all header sizes
  • No space between the # and the anchor name
  • The anchor tag names must be all lowercase
  • The anchor tag names must be delimited by dashes (-) if they are multi-word

Example

[click on this link](#multi-word-header)
@fcoclavero
fcoclavero / modify_tf_logfile.py
Last active May 13, 2020 17:38
Modify TensorBoard event tags.
# Most of the code is taken directly from [this StackOverflow answer](https://stackoverflow.com/a/60080531/4868562).
import click
import os
import shutil
import sys
import tensorflow as tf
from pathlib import Path
from tensorflow.core.util.event_pb2 import Event
act -s MY_SECRET="$(< secret.txt)"
@fcoclavero
fcoclavero / inspections.txt
Created December 10, 2021 19:57 — forked from pylover/inspections.txt
PyCharm inspections
# Extracted using: $ unzip -p lib/pycharm.jar com/jetbrains/python/PyBundle.properties | grep -B1 INSP.NAME | grep '^#' | sed 's|Inspection||g' | sed -e 's|#\s\{,1\}|# noinspection |'
# noinspection PyPep8
# noinspection PyPep8Naming
# noinspection PyTypeChecker
# noinspection PyAbstractClass
# noinspection PyArgumentEqualDefault
# noinspection PyArgumentList
# noinspection PyAssignmentToLoopOrWithParameter
# noinspection PyAttributeOutsideInit
@fcoclavero
fcoclavero / mamba_cheatsheet.sh
Created October 24, 2022 19:31
Mamba cheatsheet
# Install Poetry 1.2
mamba install -c "conda-forge/label/cleo_dev" cleo
mamba install -c "conda-forge/label/poetry_dev" poetry=1.2
@fcoclavero
fcoclavero / cheatsheet.sh
Created November 4, 2022 16:09
Poetry cheatsheet
# Clear cache
poetry cache clear _default_cache --all
poetry cache clear pypi --all
@fcoclavero
fcoclavero / cheatsheet.ps1
Last active December 20, 2022 01:35
Powershell cheatsheet
# Rename files recursively
Get-ChildItem -File -Recurse | % { Rename-Item -Path $_.PSPath -NewName $_.Name.replace(".pth",".pt")}
# Copy to clipboard
cat file.txt | clip Sort
# fish-like autosuggestions
Install-Module -Name PSReadLine -AllowPrerelease -Scope CurrentUser -Force -SkipPublisherCheck
# The next can be set in the PoSH profile: `notepad $profile`
Import-Module PSReadLine
@fcoclavero
fcoclavero / screens.sh
Last active December 20, 2022 02:22
Linux cheatsheet
# Open a screen session, create a new window, and start a shell in that window:
screen
# Start named session:
screen -S session_name
# Reattach screen:
screen -r $SCREEN_ID
# List running screens:
@fcoclavero
fcoclavero / dbx_access_denied_fix.sh
Last active December 20, 2022 02:27
Dropbox cheatsheet
# Fix Dropbox access denied Mac OS
sudo chflags -R nouchg ~/Dropbox ~/.dropbox ~/.dropbox-master
sudo chown "$USER" "$HOME"
sudo chown -R "$USER" ~/Dropbox ~/.dropbox
sudo chmod -RN ~/.dropbox ~/Dropbox
chmod -R u+rw ~/Dropbox ~/.dropbox