Skip to content

Instantly share code, notes, and snippets.

View bearice's full-sized avatar
🐻

Bearice Ren bearice

🐻
View GitHub Profile
@bearice
bearice / gist:c9e8a437beb9c1c9d27fefc064f3f5e1
Created March 24, 2022 10:40
Loki LogQL for istio log
{app="istio-ingressgateway",namespace="istio-system"}|pattern `[<START_TIME>] "<METHOD> <PATH> <PROTOCOL>" <RESPONSE_CODE> <RESPONSE_FLAGS> <RESPONSE_CODE_DETAILS> <CONNECTION_TERMINATION_DETAILS> "<UPSTREAM_TRANSPORT_FAILURE_REASON>" <BYTES_RECEIVED> <BYTES_SENT> <DURATION> <UPSTREAM_SERVICE_TIME> "<X_FORWARDED_FOR>" "<USER_AGENT>" "<X_REQUEST_ID>" "<AUTHORITY>" "<UPSTREAM_HOST>" <UPSTREAM_CLUSTER> <UPSTREAM_LOCAL_ADDRESS> <DOWNSTREAM_LOCAL_ADDRESS> <DOWNSTREAM_REMOTE_ADDRESS> <REQUESTED_SERVER_NAME> <ROUTE_NAME>`
#include <assert.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <linux/netfilter_ipv6/ip6_tables.h>
int main(){
int sk = socket(AF_INET6,SOCK_STREAM,0);
printf("sk=%d\n",sk);
#include <stddef.h>
#include <stdio.h>
#include <time.h>
#include <sys/time.h>
struct timespec lmt1 = {0};
struct timespec lmt2 = {0};
struct timespec lmt3 = {0};
struct timeval lrt = {0};
@bearice
bearice / isis2dot.jq
Created December 25, 2019 05:57
ssh your_junos 'show isis database extensive | disp json ' | jq -f isis.jq -r | dot -Tpng | imgcat
def strip_isis_id: .|match("([-\\w]+).00").captures[0].string|gsub("-";"_") ;
def to_dot: ["\(.id) -- {",(.n|join(" ")),"}"]|join("") ;
["strict graph {",
"node [overlap=false]",
(."isis-database-information"[]|."isis-database"[]|select(.level[0].data=="2")|."isis-database-entry"[]|{
id:(."lsp-id"[0].data|strip_isis_id),
n:[."isis-neighbor"[]|."is-neighbor-id"[0].data|strip_isis_id],
p:[."isis-prefix"[]|."address-prefix"[0].data],
rid:."isis-header"[0]."router-id"[0].data
@bearice
bearice / msggrp.jq
Last active December 27, 2019 07:18
simple scripts to merge and delay sending zabbix alert emails.
def get_msg_to:.[0].to;
def get_msg_subject: "\(.[0].subject) and \(.|length) Others";
def get_msg_body: .|map("Subject: \(.subject)\n\(.msg)")|join("\n======================\n");
def to_msg: {to: .|get_msg_to, subject: .|get_msg_subject, body: .|get_msg_body};
def to_script: "aws ses send-email "+(["--region", "us-west-2", "--from", "zabbix@example.com", "--to", .to, "--subject", .subject, "--text", .body]|@sh);
group_by(.to)|.[]|to_msg|to_script
@bearice
bearice / gist:331a954d86d890d9dbeacdd7de3aabe8
Created August 8, 2019 07:09
ubuntu preseed file for EFI booted software RAID1 rootfs
### Localization
# Preseeding only locale sets language, country and locale.
d-i debian-installer/locale string en_US.UTF-8
# Keyboard selection.
# Disable automatic (interactive) keymap detection.
d-i console-setup/ask_detect boolean false
d-i keyboard-configuration/layoutcode string us
// CacheAttack.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <Windows.h>
EXTERN_C_START
void _run_attempt();
DWORD64 pointers[4096 / 2];
@bearice
bearice / apply_role_asg.yml
Created December 4, 2017 07:00
Ansible playbook to control AWS Auto-scale group members dynmically.
---
- hosts: localhost
connection: local
gather_facts: no
tasks:
- name: query instances
ec2_instance_facts:
filters:
"tag:aws:autoscaling:groupName": "{{asg_name}}"
register: instance_facts
@bearice
bearice / idrac_kvm.sh
Created August 7, 2017 06:10
run Dell idrac Remote console from shell (POC)
#/bin/bash
HOST=$1
USER=root
PASS=calvin
RET=$(curl -s https://$HOST/data/login -duser=$USER -dpassword=$PASS -c .cookie -b .cookie -k)
ST1=$(echo "$RET" | awk 'match($0, /ST1=[0-9a-f]+/){ print substr( $0, RSTART, RLENGTH )}')
echo $ST1
PARAM="$HOST@0@$HOST@0@$ST1"
curl -s "https://$HOST/viewer.jnlp($PARAM)" -c .cookie -b .cookie -k > start.jnlp
javaws start.jnlp

Keybase proof

I hereby claim:

  • I am bearice on github.
  • I am bearice (https://keybase.io/bearice) on keybase.
  • I have a public key ASCkY9k_ZsJnKp9Mq6Akak3iTxBEYHhAoHZnxeQsuejlXgo

To claim this, I am signing this object: