Skip to content

Instantly share code, notes, and snippets.

View 4383's full-sized avatar
🏠
Working from home

Hervé Beraud 4383

🏠
Working from home
View GitHub Profile
@4383
4383 / git.sh
Last active June 16, 2020 09:37
git edit first commit
# rebase from the first commit included
git rebase -i --root
# generate a tiny changelog
git log --no-merges <tag or commit-id>.. --oneline
# search if a branch contains a specific commit
git branch --contains <commit-id>
##################
'''This script goes along the blog post
"Building powerful image classification models using very little data"
from blog.keras.io.
It uses data that can be downloaded at:
https://www.kaggle.com/c/dogs-vs-cats/data
In our setup, we:
- created a data/ folder
- created train/ and validation/ subfolders inside data/
- created cats/ and dogs/ subfolders inside train/ and validation/
- put the cat pictures index 0-999 in data/train/cats
@4383
4383 / docker.sh
Last active July 5, 2018 13:28
docker tips and tricks
# remove all container by ID
for el in $(docker ps -a --format "{{.ID}}"); do docker rm $el; done
# remove all images by ID
for el in $(docker images --format "{{.ID}}"); do docker rmi $el; done
@4383
4383 / compress-pdf.sh
Last active August 9, 2018 09:56
Bash functions to compress pdf files
## Bash functions to compress pdf files
## Usage:
## $ source compress-pdf.sh
## $ compress-pdf-medium
function compress-pdf-medium {
# Medium level compression
# Medium does mean it's the medium quality level
gs \
-sDEVICE=pdfwrite \
-dCompatibilityLevel=1.4 \
@4383
4383 / irc.md
Created September 17, 2018 07:55 — forked from xero/irc.md
irc cheat sheet

#IRC Reference

Not intended as a guide for newbies, more like a "cheat sheet" for the somewhat experienced IRC user, especially one who wields some power over a channel.

##The Basics

  • /join #channel
    • Joins the specified channel.
  • /part #channel
    • Leaves the specified channel.
@4383
4383 / example.sh
Created November 13, 2018 15:35
mastering tox debuging
# assuming that I run the unit test of oslo.service
# https://github.com/openstack/oslo.service
# if you want to do the same things you need first to clone the oslo.service project
# to initialize tox environment you need to first tox basicaly
tox -e py35
# now your environment is setup you can run individual test by using testtools like this
.tox/py35/bin/python -m testtools.run oslo_service.tests.test_service.ServiceLauncherTest.test_child_signal_sighup
@4383
4383 / debug.py
Created November 13, 2018 17:43
debug with kcachegrind
import cProfile
pr = cProfile.Profile()
pr.enable()
# execute python code to profile
print("test")
pr.disable()
pr.dump_stats("/tmp/debug.cprof")
@4383
4383 / openstack.sh
Last active January 28, 2019 17:11
Useful openstack commands
scp memcache.py hberaud@file.cdg.redhat.com:public_html/
@4383
4383 / podman.sh
Last active January 23, 2019 18:48
patch openstack stein with podman
#!/bin/bash
# remove old fix container
podman rm -f fix
# patch container with debug changes
podman run --name=fix -u root --net=host -it 192.168.122.1:5000/fedora-binary-nova-api:ospsprint bash -c "curl http://file.cdg.redhat.com/hberaud/context.py -o /tmp/context.py && mv /tmp/context.py /usr/lib/python3.6/site-packages/nova && cat /usr/lib/python3.6/site-packages/nova/context.py"
# commit changes to apply debug changes
podman commit --change CMD='kolla_start' fix 192.168.122.1:5000/fedora-binary-nova-api:ospsprint
# remove fix container generated
podman rm -f fix
# redeploy and catch debug traces
export OS_PROJECT_DOMAIN_NAME='Default'
export OS_USER_DOMAIN_NAME='Default'
export OS_PROJECT_NAME='admin'
export OS_USERNAME='admin'
export OS_AUTH_URL=http://192.168.24.2:5000/
export OS_AUTH_TYPE='password'
export OS_IDENTITY_API_VERSION='3'
export OS_PASSWORD=$(hiera -c /etc/puppet/hiera.yaml keystone::admin_password)