Skip to content

Instantly share code, notes, and snippets.

@paoloyx
paoloyx / readme.md
Created March 29, 2021 14:47
Example for decoding a JWT Payload with your Shell (bash, zsh...)

Setup

Add this to your .profile, .bashrc, .zshrc...

_decode_base64_url() {
  local len=$((${#1} % 4))
  local result="$1"
  if [ $len -eq 2 ]; then result="$1"'=='
  elif [ $len -eq 3 ]; then result="$1"'=' 
  fi
 echo "$result" | tr '_-' '/+' | base64 -d
@paoloyx
paoloyx / gist:e6781783c45d90f29118d93d458e1130
Created February 16, 2021 13:37
Get an overview of all the (Cluster)RoleBindings and the ServiceAccount(s) they reference
kubectl get rolebindings,clusterrolebindings \
--all-namespaces \
-o custom-columns='KIND:kind,NAMESPACE:metadata.namespace,NAME:metadata.name,SERVICE_ACCOUNTS:subjects[?(@.kind=="ServiceAccount")].name'
apiVersion: v1
kind: Service
metadata:
name: nginx-headless
labels:
app: nginx
spec:
ports:
- port: 80
name: web
@paoloyx
paoloyx / consoleColors.js
Created February 1, 2021 14:50 — forked from abritinthebay/consoleColors.js
The various escape codes you can use to color output to StdOut from Node JS
// Colors reference
// You can use the following as so:
// console.log(colorCode, data);
// console.log(`${colorCode}some colorful text string${resetCode} rest of string in normal color`);
//
// ... and so on.
export const reset = "\x1b[0m"
export const bright = "\x1b[1m"
export const dim = "\x1b[2m"
@paoloyx
paoloyx / clickhousedump
Created January 22, 2021 16:57 — forked from inkrement/clickhousedump
dump all clickhouse databases and tables
#!/bin/bash
OUTDIR=.
while read -r db ; do
while read -r table ; do
if [ "$db" == "system" ]; then
echo "skip system db"
continue 2;
[
{
"applicationDomain" : "MIS.COACHING",
"serviceCode" : "questionnaires",
"packageName" : "it.menarini.coaching.rest",
"version" : "v1",
"api" : {
"value" : "",
"description" : ""
},
package it.menarini.coaching.dao;
import .MISCOACHINGanswersDAO; // import errato generato
import it.menarini.coaching.model.CoachAnswer;
import it.menarini.coaching.model.CoachAssessment;
import it.menarini.coaching.model.CoachQuestion;
import it.menarini.coaching.model.CoachQuestionGroup;
import it.menarini.coaching.model.CoachQuestionnaire;
import it.menarini.coaching.model.CoachQuestionnaireProduct;
import it.menarini.coaching.model.ComboBox;
@paoloyx
paoloyx / gist:2c87e332f0a9517dc4bf
Last active August 29, 2015 14:25
Json con applicationDomani gerarchico e callService
[
{
"applicationDomain" : "MIS.COACHING",
"serviceCode" : "assessments",
"packageName" : "it.menarini.coaching.rest",
"version" : "v1",
"advancedSearch" : true,
"api" : {
"value" : "",
"description" : ""
@Override@WsgOperation("Add products - Create new products.")
public List < Map > addProductsQuestionnaire(@WsgParameter("The Context ID") String contextId, @WsgParameter("The new Products object") List < CoachQuestionnaireProduct > products,
SearchRequest searchReq) {
DataSource ds = datasourceManager.getDatasource(serviceName, contextId);
DataSourceTransactionManager dstm = new DataSourceTransactionManager(ds);
TransactionStatus status = dstm.getTransaction(new DefaultTransactionDefinition());
NamedParameterJdbcTemplate jdbc = new NamedParameterJdbcTemplate(ds);
JdbcTemplate jdbcs = new JdbcTemplate(ds);
String sql = "insert into coach_questionnare_product (id, qualification, weight, description, coach_questionnaire_id) values (:products.id, :products.qualification, :products.weight, :products.description, :products.coachQuestionnaireId)";
Map parameters = new HashMap();
{
"verb": "POST",
"uri": "/add-products",
"apiOperation": { "value":"Add products","notes" : "Create new products."},
"methodName": "addProductsQuestionnaire",
"parameters": [
{"name":"products", "paramType":"RequestBody","paramClass":"it.menarini.coaching.model.CoachQuestionnaireProduct","isCollection" : true, "required" : true, "apiParam" : {"name":"productQuestionnaire","value":"The new Products object"}}
],
"preAssign" : { "products.id" : "select seq_coaching_product.nextval from dual" },
"preSqlTemplate": ["delete from coach_questionnare_product where coach_questionnaire_id = :products.coachQuestionnaireId"],