Skip to content

Instantly share code, notes, and snippets.

View unicolet's full-sized avatar

Umberto Nicoletti unicolet

View GitHub Profile
from langchain_core.prompts import ChatPromptTemplate
from langchain_anthropic import ChatAnthropic # or langchain_openai.ChatOpenAI
from langchain_core.tools import tool
from langchain_core.pydantic_v1 import BaseModel
# Define a tool using the @tool decorator
@tool
def multiply(x: int, y: int) -> int:
"""Multiply two integers."""
return x * y
rules:
- id: curl-reset-without-lowspeed-time
languages:
- c
- cpp
severity: ERROR
message: curl_easy_reset() called without setting CURLOPT_LOW_SPEED_TIME
patterns:
- pattern: curl_easy_reset($CURLHANDLE);
- pattern-not-inside: |-
package main
import (
"bufio"
"fmt"
"io"
"log"
"net"
"time"
"strconv"
import socket
import time
import statistics
import argparse
from typing import List, Tuple
def measure_tcp_latency(host: str, port: int, num_samples: int = 10, timeout: float = 2.0) -> List[float]:
"""
Measure TCP connection latency to a host:port.
@unicolet
unicolet / echo.go
Last active October 29, 2024 12:42
package main
import (
"bufio"
"fmt"
"io"
"log"
"net"
"time"
)
@unicolet
unicolet / rd-clean.sh
Created April 8, 2015 10:40
Shell script to purge Rundeck execution history
#!/bin/sh
# setup ~/.pgpass to allow passwordless connection to postgres
# keep last 30 executions for each job
KEEP=30
cd /var/lib/rundeck/logs/rundeck
JOBS=`find . -maxdepth 3 -path "*/job/*" -type d`
@unicolet
unicolet / idrac.py
Created September 1, 2020 11:00
Parse idrac logs and show the most relevant fields
import xml.etree.ElementTree as ET
import iso8601
tree = ET.parse('310TKQ2-log.xml')
root = tree.getroot()
for child in root:
timestamp = iso8601.parse_date(child.attrib["Timestamp"])
print("%s %s %s %s" % (timestamp, child.attrib["AgentID"], child.attrib["Severity"], child[0].text))
#!/usr/bin/python -u
import os
import sys
from datetime import datetime
import urllib2
import time
def get_gh_ratelimits(token):
def load_our_config(all=false)
files = Dir['conf.d/*.conf']
@@configuration = String.new
files.sort.each do |file|
if all
@@configuration << File.read(file)
elsif file !~ /output/ and file !~ /input/
@@configuration << File.read(file)
end
end
# encoding: utf-8
require "logstash/devutils/rspec/spec_helper"
describe "filebeat-forwarded plain text log" do
files = Dir['conf.d/*.conf']
@@configuration = String.new
files.sort.each do |file|
@@configuration << File.read(file)
end