Skip to content

Instantly share code, notes, and snippets.

View kakwa's full-sized avatar

Carpentier Pierre-Francois kakwa

View GitHub Profile
@ng-pe
ng-pe / postgresql_pg_stat_activity_with_tempfiles.sql
Last active January 29, 2021 13:51
postgresql "pg_stat_activity" with temporary files information
-- View pg_stat_activity with temporary files informations (file list and total file size)
-- version 0.3
SELECT
pg_stat_activity.pid AS pid,
CASE WHEN LENGTH(pg_stat_activity.datname) > 16
THEN SUBSTRING(pg_stat_activity.datname FROM 0 FOR 6)||'...'||SUBSTRING(pg_stat_activity.datname FROM '........$')
ELSE pg_stat_activity.datname
END
AS database,
@kakwa
kakwa / start.sh
Created December 7, 2015 16:45
start all vms on an esxi host
#!/bin/sh
vim-cmd vmsvc/getallvms | awk '{print $1}' | while read id; do vim-cmd vmsvc/power.on $id;done
#!/bin/sh
RCol='\33[0m' # Text Reset
# Regular Bold Underline High Intensity BoldHigh Intens
Bla='\33[0;30m'; BBla='\33[1;30m'; UBla='\33[4;30m'; IBla='\33[0;90m'; BIBla='\33[1;90m';
Red='\33[0;31m'; BRed='\33[1;31m'; URed='\33[4;31m'; IRed='\33[0;91m'; BIRed='\33[1;91m';
Gre='\33[0;32m'; BGre='\33[1;32m'; UGre='\33[4;32m'; IGre='\33[0;92m'; BIGre='\33[1;92m';
Yel='\33[0;33m'; BYel='\33[1;33m'; UYel='\33[4;33m'; IYel='\33[0;93m'; BIYel='\33[1;93m';
Blu='\33[0;34m'; BBlu='\33[1;34m'; UBlu='\33[4;34m'; IBlu='\33[0;94m'; BIBlu='\33[1;94m';
@kakwa
kakwa / ghipr.py
Last active November 21, 2015 12:51
Quick and dirty script to display the number of opened issues and PRs on a list of Github projects
#!/usr/bin/env python
import urllib2
import json
import sys
import codecs
import base64
# Quick and dirty script to display the number of opened issues and PRs on a list of Github projects
@varemenos
varemenos / 1.README.md
Last active April 21, 2024 23:21
Git log in JSON format

Get Git log in JSON format

git log --pretty=format:'{%n  "commit": "%H",%n  "abbreviated_commit": "%h",%n  "tree": "%T",%n  "abbreviated_tree": "%t",%n  "parent": "%P",%n  "abbreviated_parent": "%p",%n  "refs": "%D",%n  "encoding": "%e",%n  "subject": "%s",%n  "sanitized_subject_line": "%f",%n  "body": "%b",%n  "commit_notes": "%N",%n  "verification_flag": "%G?",%n  "signer": "%GS",%n  "signer_key": "%GK",%n  "author": {%n    "name": "%aN",%n    "email": "%aE",%n    "date": "%aD"%n  },%n  "commiter": {%n    "name": "%cN",%n    "email": "%cE",%n    "date": "%cD"%n  }%n},'

The only information that aren't fetched are:

  • %B: raw body (unwrapped subject and body)
  • %GG: raw verification message from GPG for a signed commit
@kakwa
kakwa / sparc-netboot.sh
Last active August 29, 2015 14:11
Simple rarpd wrapper that handle automatically filling the ethers and hosts file, and creating the correct symlink (ip in hexa) for the tftp boot image
#!/bin/sh
# listening interface for RARPD
IF=eth0
# Base Network (this script is limited to D class networks)
NET=192.168.100.
# TFTP/RARPD server IP
SRV_IP=192.168.100.100
# ethers file
@kakwa
kakwa / 0_pw_hash.rb
Last active August 29, 2015 14:10 — forked from pschyska/0_pw_hash.rb
patched version of pw_hash.rb working with puppetserver and jruby
require 'puppet/parser/functions'
module Puppet::Parser::Functions
newfunction(:pw_hash, :type => :rvalue, :doc => "Returns the hash of a password."
) do |args|
raise Puppet::ParseError, "pw_hash takes exactly two arguments," +
"#{args.length} provided" if args.length != 2
pwd = args[0]
slt = args[1]
@kakwa
kakwa / validate-puppet.sh
Last active August 29, 2015 14:06
script validating puppet and erb syntax
#!/bin/sh
# Released under MIT License
RCol='\33[0m' # Text Reset
# Regular Bold Underline High Intensity BoldHigh Intens Background High Intensity Backgrounds
Bla='\33[0;30m'; BBla='\33[1;30m'; UBla='\33[4;30m'; IBla='\33[0;90m'; BIBla='\33[1;90m'; On_Bla='\33[40m'; On_IBla='\33[0;100m';
Red='\33[0;31m'; BRed='\33[1;31m'; URed='\33[4;31m'; IRed='\33[0;91m'; BIRed='\33[1;91m'; On_Red='\33[41m'; On_IRed='\33[0;101m';
Gre='\33[0;32m'; BGre='\33[1;32m'; UGre='\33[4;32m'; IGre='\33[0;92m'; BIGre='\33[1;92m'; On_Gre='\33[42m'; On_IGre='\33[0;102m';
@kakwa
kakwa / progress.sh
Last active August 29, 2015 14:06
Quick and dirty progress bar function in shell
#!/bin/sh
print_progress_bar(){
percent=$1
width=$2
width=$(( ${width} - 10 ))
barlen=$(( ${width} * ${percent} / 100 ))
voidlen=$(( ${width} - ${barlen} ))
bar=`printf %${barlen}s |tr " " "="`
void=`printf %${voidlen}s`
@kakwa
kakwa / rebuild-iso.sh
Last active August 29, 2015 14:01
small script to create an iso "dd-able" to an usb key from an existing iso
#!/bin/sh
MOUNT="false"
ISOHDPFX="M+2QkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJCQkJAz7fqO1bwAfPv8ZjHbZjHJZlNmUQZXjt2O\nxVK+AHy/AAa5AAHzpepLBgAAUrRBu6pVMckw9vnNE3IWgftVqnUQg+EBdAtmxwbxBrRC6xXrAFpR\ntAjNE4PhP1tRD7bGQFD34VNSULsAfLkEAGahsAfoRAAPgoAAZkCAxwLi8maBPkB8+8B4cHUJ+rzs\ne+pEfAAA6IMAaXNvbGludXguYmluIG1pc3Npbmcgb3IgY29ycnVwdC4NCmZgZjHSZgMG+HtmExb8\ne2ZSZlAGU2oBahCJ5mb3Nuh7wOQGiOGIxZL2Nu57iMYI4UG4AQKKFvJ7zRONZBBmYcPoHgBPcGVy\nYXRpbmcgc3lzdGVtIGxvYWQgZXJyb3IuDQperLQOij5iBLMHzRA8CnXxzRj06/0AAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
help(){
echo "usage: `basename $0` -i <input iso> -o <output iso> [-m]"
echo ""
echo "Recreate a 'dd able' iso from an existing iso:"
echo ""