This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: |- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"fmt" | |
"io" | |
"log" | |
"net" | |
"time" | |
"strconv" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"fmt" | |
"io" | |
"log" | |
"net" | |
"time" | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python -u | |
import os | |
import sys | |
from datetime import datetime | |
import urllib2 | |
import time | |
def get_gh_ratelimits(token): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# envoy default log format: | |
# https://www.envoyproxy.io/docs/envoy/latest/configuration/access_log#config-access-log-default-format | |
# | |
# [%START_TIME%] "%REQ(:METHOD)% %REQ(X-ENVOY-ORIGINAL-PATH?:PATH)% %PROTOCOL%" | |
# %RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %DURATION% | |
# %RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)% "%REQ(X-FORWARDED-FOR)%" "%REQ(USER-AGENT)%" | |
# "%REQ(X-REQUEST-ID)%" "%REQ(:AUTHORITY)%" "%UPSTREAM_HOST%" | |
# | |
ENVOY \[%{TIMESTAMP_ISO8601:timestamp}\] "%{DATA:method} %{DATA:original_path} %{DATA:protocol}" %{DATA:response_code} %{DATA:response_flags} %{NUMBER:bytes_rcvd} %{NUMBER:bytes_sent} %{NUMBER:duration} %{DATA:upstream_svc_time} "%{DATA:x-forwarded-for}" "%{DATA:useragent}" "%{DATA:request_id}" "%{DATA:authority}" "%{DATA:upstream_host}" |
NewerOlder