Skip to content

Instantly share code, notes, and snippets.

View bebosudo's full-sized avatar
💾

Alberto Chiusole bebosudo

💾
View GitHub Profile
@bebosudo
bebosudo / ior-ceph-lazy-dirty.patch
Last active April 11, 2019 13:22
dirty patch for ior
diff -Naur -x '*.o' -x '*.mod' -x '*.a' -x 'config.*' -x configure -x 'aclocal*' -x depcomp -x external -x .deps -x myabort__genmod.f90 -x missing -x '*Proc' -x libtool -x '*sh' -x 'stamp*' -x 'Makefile*' -x 'autom4te*' -x test-driver ior-3.2.0/src/aiori-POSIX.c ior-3.2.0-lazy/src/aiori-POSIX.c
--- ior-3.2.0/src/aiori-POSIX.c 2018-12-23 05:28:03.000000000 +0100
+++ ior-3.2.0-lazy/src/aiori-POSIX.c 2019-04-11 13:24:57.500951794 +0200
@@ -369,6 +369,11 @@
gpfs_free_all_locks(*fd);
}
#endif
+
+#define CEPH_IOCTL_MAGIC 0x97
+#define CEPH_IOC_LAZYIO _IO(CEPH_IOCTL_MAGIC, 4)
#!/usr/bin/env bash
#SBATCH -p be-short
#SBATCH -J bescratch_test
#SBATCH -t 24:00:00
#SBATCH --hint=nomultithread
#SBATCH -d singleton
#SBATCH --ntasks-per-node=20
#SBATCH -n 640
# PBS at C3HPC submit info:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html><!--
Page saved with SingleFile
url: file:///tmp/lu8213od5iqt.tmp/lu8213od5iqz.tmp/plots_timings_ceph_cern.htm
saved date: Mon Mar 25 2019 14:43:19 GMT+0100 (Central European Standard Time)
--><meta charset=utf-8>
<title></title>
<meta name=generator content="LibreOffice 6.1.5.2 (Linux)">
<meta name=created content=2019-03-25T11:33:56.264232791>
<meta name=changed content=2019-03-25T14:04:22.127248758>
<style>body,table,tbody,tr,td,p{font-family:"Liberation Sans";font-size:x-small}</style>
@bebosudo
bebosudo / RegCM-SVN6916_more-io-debug.patch
Last active March 27, 2019 16:10
Patch for more verbose debug on RegCM SVN 6916.
diff -Naur -x '*.o' -x '*.mod' -x '*.a' -x 'config.*' -x configure -x 'aclocal*' -x depcomp -x external -x .deps -x myabort__genmod.f90 -x missing -x '*Proc' -x libtool -x '*sh' -x 'stamp*' -x 'Makefile*' RegCM-SVN6916_orig/Main/mod_ncio.F90 RegCM-SVN6916_patch/Main/mod_ncio.F90
--- RegCM-SVN6916_orig/Main/mod_ncio.F90 2017-11-28 12:11:10.000000000 +0100
+++ RegCM-SVN6916_patch/Main/mod_ncio.F90 2019-03-27 17:07:56.704690606 +0100
@@ -28,6 +28,7 @@
use mod_memutil
use mod_nchelper
use mod_domain
+ use mod_service
implicit none
@bebosudo
bebosudo / search_free_port.py
Created March 6, 2019 14:44
Search for a free TCP port in python 3 (not completely safe, since between the check and the usage, there could be a race-condition)
#!/usr/bin/env python3
import socket
def search_free_port():
port = 5000
while True:
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
if s.connect_ex(('localhost', port)) != 0:
return port
@bebosudo
bebosudo / Dockerfile
Created February 15, 2019 12:54
rnaseq-nf + awscli to execute RNA sequencing inside AWS Batch + S3
# bebosudo/rnaseq-nf is just a fork of nextflow/rnaseq-nf
FROM bebosudo/rnaseq-nf
MAINTAINER Alberto Chiusole <[email protected]>
RUN pip install --no-cache awscli
@bebosudo
bebosudo / zhang_calibration_method.ipynb
Last active January 26, 2019 16:38
Project on Zhang calibration method, undistortion and super-imposition of an object, for CVPR @ units.it
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1. (serial) 2. (smpar) 3. (dmpar) 4. (dm+sm) PGI (pgf90/gcc)
5. (serial) 6. (smpar) 7. (dmpar) 8. (dm+sm) PGI (pgf90/pgcc): SGI MPT
9. (serial) 10. (smpar) 11. (dmpar) 12. (dm+sm) PGI (pgf90/gcc): PGI accelerator
13. (serial) 14. (smpar) 15. (dmpar) 16. (dm+sm) INTEL (ifort/icc)
17. (dm+sm) INTEL (ifort/icc): Xeon Phi (MIC architecture)
18. (serial) 19. (smpar) 20. (dmpar) 21. (dm+sm) INTEL (ifort/icc): Xeon (SNB with AVX mods)
22. (serial) 23. (smpar) 24. (dmpar) 25. (dm+sm) INTEL (ifort/icc): SGI MPT
26. (serial) 27. (smpar) 28. (dmpar) 29. (dm+sm) INTEL (ifort/icc): IBM POE
30. (serial) 31. (dmpar) PATHSCALE (pathf90/pathcc)
32. (serial) 33. (smpar) 34. (dmpar) 35. (dm+sm) GNU (gfortran/gcc)
24046 /usr/bin/ld: /opt/cluster/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/boost-1.68.0-xkyf5icz7yn62yjvduwrs3mfru4merj4/lib/libboost_serialization-mt.a(archive_exception.o): re
location R_X86_64_32S against symbol `_ZTVN5boost7archive17archive_exceptionE' can not be used when making a shared object; recompile with -fPIC
24047 /usr/bin/ld: /opt/cluster/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/boost-1.68.0-xkyf5icz7yn62yjvduwrs3mfru4merj4/lib/libboost_serialization-mt.a(basic_archive.o): reloca
tion R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC
24048 /usr/bin/ld: /opt/cluster/spack/opt/spack/linux-centos7-x86_64/gcc-8.2.0/boost-1.68.0-xkyf5icz7yn62yjvduwrs3mfru4merj4/lib/libboost_filesystem-mt.a(operations.o): relocation R
_X86_64_32 against `.rodata.str1.8' can not be used when making a shared object; recompile with -fPIC
24049 /usr/bin/ld: /opt/cluster/spack/opt/spack/l

If we have a model with some fields that have default values (e.g. a cost = DecimalField(default=0, null=false)), and we receive a form with that field set as None, django will complain with a NOT NULL constraint failed. We can manually set the fields of interest in the save() method of the models, or simply add this class to all the django Models, which will automatically discover and set the null fields having a default value.

from django.db.models.fields import NOT_PROVIDED

class SetModelDefaultsOnSave:
    def save(self):
        for field in self._meta.get_fields():
 if (not field.auto_created and getattr(self, field.name) is None and