Skip to content

Instantly share code, notes, and snippets.

View lsferreira42's full-sized avatar

Leandro Ferreira lsferreira42

View GitHub Profile

Visualizar os campos disponíveis para itemtype ITILCategory

curl --request GET \
  --url https://glpi.exemplo.com.br/apirest.php/listSearchOptions/ITILCategory \
  --header 'App-Token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' \
  --header 'Content-Type: application/json' \
  --header 'Session-Token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
@lsferreira42
lsferreira42 / timeout.sh
Last active November 22, 2023 23:44
Timeout implementation using only bash + common linux tools
function timeout {
time_limit=$1
exec_process=$2 # can be a function too
# Move the parameters to the 2 position
shift 2
# create a pidfile for later reading
pid_file=$(mktemp)
@lsferreira42
lsferreira42 / imch.py
Created March 22, 2023 02:03
create a python script that rename import modules using AST
import ast
import os
def rename_import_modules(source_file, old_module_name, new_module_name):
# Parse the source code into an Abstract Syntax Tree (AST)
with open(source_file) as f:
source = f.read()
tree = ast.parse(source)
# Traverse the AST to find import statements and update the module name
@lsferreira42
lsferreira42 / stop_builds.groovy
Created May 31, 2022 11:19
Some script that i found online to stop all jenkins builds at once
import jenkins.model.Jenkins
def numCancels = 0;
Jenkins.instance.getAllItems(Job.class).each{
def job = it
for (build in job.builds) {
if (build.isBuilding()) {
build.doStop()
numCancels++
}
@lsferreira42
lsferreira42 / nuker.py
Created December 18, 2021 03:17
Threaded socket testing tool
from collections import deque
from queue import Queue
from threading import Thread
import threading
from time import sleep
from collections import Counter
import os
import socket
import sys
import argparse
import boto3
import sys
import os
session = boto3.session.Session(profile_name='legado')
s3 = session.client('s3')
def upload_to_s3(path, bucket):
for root,dirs,files in os.walk(path):
for file in files:
print(os.path.join(root,file))
@lsferreira42
lsferreira42 / yaml_file.py
Created January 22, 2019 19:29 — forked from psobot/yaml_file.py
Real-time YAML object access in Python
"""
liveyamlfile.py
Live Pythonic attribute access to properties in a yaml file.
by Peter Sobot (hi@psobot.com), August 8, 2012
"""
import os
import time
import yaml
import logging
"""Extract jinja2 tags using regexps"""
import re
def extract_tags(value):
reg_findtag = "\{\{(.*?)\}\}"
p = re.compile(reg_findtag)
return p.findall(value)
<?php
//API KEY
$new_api_key = 'NOVACHAVEDEAPI';
//Pega as variaveis necessarias e testa a conexao
include_once "wp-config.php";
$link = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
if (!$link) {
die('cant connect to the database!');
@lsferreira42
lsferreira42 / client.go
Created January 16, 2018 21:17 — forked from spikebike/client.go
TLS server and client
package main
import (
"crypto/tls"
"crypto/x509"
"fmt"
"io"
"log"
)