Skip to content

Instantly share code, notes, and snippets.

View mosajjal's full-sized avatar
🏖️
Holiday

Ali mosajjal

🏖️
Holiday
  • Spark New Zealand
  • Auckland, Aotearoa
  • 05:41 (UTC +12:00)
  • X @_n0p_
View GitHub Profile
@mosajjal
mosajjal / buildinfo.go
Created January 6, 2024 23:01
get build info of a go binary
package main
import (
"debug/buildinfo"
"encoding/json"
"flag"
"fmt"
"log"
)
@mosajjal
mosajjal / flatten.go
Created January 6, 2024 23:00
flatten nested json strings
// use:
// cat nested.json | go run . > flattenned.json
package main
import (
"bytes"
"compress/gzip"
"encoding/base64"
"fmt"
"io"
@mosajjal
mosajjal / ub64.py
Created January 6, 2024 22:52
recursively replace base64-encoded strings in a JSON file with the decoded string
# recursively replace base64-encoded strings in a JSON file with the decoded string
# usage: python main.py <input_file> <output_file>
import sys
import json
import base64
def decode_json(data):
if isinstance(data, dict):
return {decode_json(key): decode_json(value) for key, value in data.items()}
@mosajjal
mosajjal / falconfeeds2rss.py
Created December 28, 2023 04:59
Converts the incoming webhook from falconfeeds to an RSS feed that you can ingest. please consider T&C of Falconfeeds before making the RSS public
#!/bin/env python3
from bottle import Bottle, request, response, static_file
import json
import xml.etree.ElementTree as ET
from datetime import datetime
import pytz
import os
app = Bottle()
@mosajjal
mosajjal / dnsUnmarshaller.go
Created January 5, 2023 00:00
miekg DNS unmarshaller
package main
import (
"fmt"
"log"
"testing"
json "github.com/bytedance/sonic"
"github.com/miekg/dns"
@mosajjal
mosajjal / email_parser.go
Last active November 6, 2022 21:49
Parse a directory containing .tgz mailbox imports into one JSONL doc + a folder of attachments.
// email parser built to process large amounts of .tgz exports containing one or more .eml files inside
package main
import (
"archive/tar"
"bytes"
"compress/gzip"
"crypto/sha256"
"encoding/json"
"fmt"
package main
import (
"context"
"fmt"
"log"
"net"
"os"
"strconv"
"syscall"
@mosajjal
mosajjal / cloudflare_tailscale_sync.py
Created August 22, 2021 11:04
Automated Script to Use Cloudflare as a DNS server for Tailscale. Global alternative to Magic DNS
"""
This script trys to add and delete records from cloudflare based on the current status of the account in tailscale, and eliminate the need for TailScale's magic DNS.
Each domain will be created under a subdomain "SUBDOMAIN", that way it'll be easier to find and detele records.
IMPORTANT: this script is not very well tested and it tries to DELETE some DNS records. Use it at your own risk, especially if your SUBDOMAIN value is generic and it's also used elsewhere in your domain.
"""
import os
import requests
def flatten_dict(in_, joiner="."):
out = dict()
retry = 0
for item in in_:
if type(in_[item]) == list:
retry = 1
for i,list_item in enumerate(in_[item]):
out[f"{item}{joiner}{i}"] = in_[item][i]
elif type(in_[item]) == dict:
retry = 1
@mosajjal
mosajjal / tmux.conf
Last active June 2, 2020 00:12
my Tmux conf
set -s escape-time 0
setw -g aggressive-resize on
# First remove *all* keybindings
# unbind-key -a
# List keys
bind-key ? list-keys
# Copy mode