Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View jebeaudet's full-sized avatar

Jacques-Etienne Beaudet jebeaudet

  • Coveo
  • Quebec, Canada
View GitHub Profile
@jebeaudet
jebeaudet / messageTray.js
Last active August 19, 2020 19:36
dismiss notification on right click linux mint
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const Clutter = imports.gi.Clutter;
const GLib = imports.gi.GLib;
const Gio = imports.gi.Gio;
const Gtk = imports.gi.Gtk;
const Atk = imports.gi.Atk;
const Lang = imports.lang;
from PIL import Image
import sys
import requests
from bs4 import BeautifulSoup
if len(sys.argv) <= 3:
print "Please provide the filename of the picture as first argument and the cookie of slack as second argument and the prefix"
exit(1)
max_width_or_height = 3840
@jebeaudet
jebeaudet / non-server.py
Created January 14, 2020 19:04
Form resubmission bug in chrome part 2
import http.server
import socketserver
PORT = 8000
auto_submit_html = """
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
</head>
<body onload="document.forms[0].submit()">
@jebeaudet
jebeaudet / server.py
Created January 14, 2020 19:00
Form resubmission bug in chrome
import http.server
import socketserver
PORT = 8000
auto_submit_html = """
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
</head>
<body onload="document.forms[0].submit()">
@jebeaudet
jebeaudet / gist:f2fbd78e8b771f1d3c3924c9ccd73fbb
Created December 11, 2019 18:27
Map PID from Host to docker container
PID from the threads/process will be different from the host that from inside the container.
This makes reading thread dump tricky as the thread dump will show the nid of inside the container however you might be checking CPU usage from the host!
To find the mapping of the two, it's easy. Find the PID of the thread/process on the host.
After this, run `cat /proc/{PID}/status |grep NSpid`. Example :
```
NSpid: 31144 83
```
@jebeaudet
jebeaudet / gist:03d4c33acadb7b89ad9b119fe6db6ab9
Last active July 6, 2021 15:22
Decrypt jenkins encrypted value
Go to https://jenkinsurl.com/script and run :
println(hudson.util.Secret.decrypt("{encrypted_value}"))
To get the encrypted_value, go to the credential page, click on update and after do inspect element on the password field. Take the "value" property of the field. It should be between curly braces.
To get ALL the credentials :
def creds = com.cloudbees.plugins.credentials.CredentialsProvider.lookupCredentials(
com.cloudbees.plugins.credentials.common.StandardUsernameCredentials.class,
Jenkins.instance,
null,
@jebeaudet
jebeaudet / gist:25bddb4e36653cbba3f0c83b34eff414
Last active February 1, 2019 20:29
Dump java docker heap
# install openjdk in the container
docker exec -it --user=root container_name sh
apk add openjdk8
docker exec -it <container_name> jmap -dump:format=b,file=/tmp/cheap.bin 1
# Also works
docker exec <container_name> jcmd 1 GC.heap_dump /tmp/docker.hprof
@jebeaudet
jebeaudet / gist:15b874372d8d7b70be9a8a4ce7fd3a98
Created October 31, 2017 18:49
How to trace live requests coming to a server using ngrep
ngrep -l -q -d eth0 -W byline -i "^GET|^POST|^HEAD|^DELETE|^PUT" tcp
@jebeaudet
jebeaudet / gist:b05c8b096e3fc28170e06fa1f5dbf60a
Created August 30, 2017 18:25
Change docker environment variables on an existing container
stop docker service (`sudo service docker stop`)
edit the file located at `/var/lib/docker/containers/:containerId/config.v2.json`
restart docker service
profit!
@jebeaudet
jebeaudet / gist:d764cbb1df7e966120d10b20270b0981
Created August 17, 2017 17:06
Clean docker containers, images and volumes
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
docker rmi $(docker images -a -q)
docker volume rm $(docker volume ls -f dangling=true -q)