Skip to content

Instantly share code, notes, and snippets.

@bdargan
bdargan / manual_encrypt.sh
Last active December 16, 2022 07:25
Manually encrypt files with openssl.
#!/bin/bash
rm -f content
rm *.enc
rm *.pem
rm keyfile
rm *.b64
rm *.dec
echo "generate: data-key for this content transfer"
@bdargan
bdargan / debug-node-reminder.md
Created February 23, 2014 21:44
debug node with chrome tools

#--debug to node/node runner nodemon --debug server.coffee node-inspector --web-port=5859

@bdargan
bdargan / stuff.el
Last active December 28, 2015 20:29
stuff, like curl and date utils find a number, that looks like a recent number of secs since the epoch and make it human readable
(defun epoch-to-iso ()
(interactive)
(re-search-forward "\\([0-9]\\{10,13\\}\\)")
(goto-char (match-beginning 0))
(replace-match (format-time-string "%Y-%m-%d" (seconds-to-time (/ (string-to-int (match-string 1)) 1000))))
)
(defun curl-something (begin end)
(interactive "r")
(shell-command (concat "curl " (buffer-substring begin end))))
@bdargan
bdargan / gist:7310769
Created November 4, 2013 23:00
password/entropy checkers
https://www.grc.com/haystack.htm
http://rumkin.com/tools/password/passchk.php
http://readablepassphrase.codeplex.com/
@bdargan
bdargan / emacs_ref.md
Last active December 23, 2015 21:09
emacs bindings i need to learn

Movement / Navigation

forward char/word : C-f, M-f

back char/word : C-b, M-b

next logical line : C-n, M-n

previous line : C-p

  • sometimes, C-p is previous command
@bdargan
bdargan / esslow.py
Created May 27, 2013 07:17
slow search log parser for es
#!/usr/bin/env python
import sys, re, json
from collections import defaultdict, namedtuple
# with jaysw
#Slow Search Log
#[2013-05-27 07:04:44,833][WARN ][index.search.slowlog.fetch] [local1] [idx2][2] took[1s], took_millis[1043], types[property], stats[], search_type[QUERY_THEN_FETCH],
#Slow Index Log, currently not supported
#[2013-05-27 08:32:23,397][TRACE][index.indexing.slowlog.index] [local1] [idx2][0] took[607.8ms], took_millis[607], type[offer], id[2b13a5e5d5029f7b3609c9ddb89a7419]
@bdargan
bdargan / geoquery.json
Created February 15, 2013 01:40
elasticsearch geo queries
{
"query" : {
"match_all" : {}
},
"filter" : {
"geo_distance" : {
"distance" : "50km",
"location" : [-33.9, 151.175]
}
},
@bdargan
bdargan / geocitylite_to_es.py
Last active April 11, 2017 11:30
load maxmind geocitylite db into elasticsearch
#! /usr/bin/env python
import json
import datetime
import httplib2
import re
import csv
import sys
http = httplib2.Http()
@bdargan
bdargan / update_asset.py
Last active December 13, 2015 16:39
selenium webdriver for automating some qradar tasks, like updating assets or autoatically extracting report data.
#! /usr/bin/env python
from selenium import webdriver
import selenium
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0
from selenium.webdriver.support import expected_conditions as EC # available since 2.26.0
from selenium.webdriver.common.by import By
import collections
from time import sleep
import getpass
@bdargan
bdargan / mob_log_parser
Created January 25, 2013 01:25
python log parser, to pull out device type and versions
#!/usr/bin/env python
import sys,re
from collections import defaultdict, namedtuple
# cat wip/mobile_log |./apl | sed -e's/_/\./'
mobile_pat = re.compile(
r'^(?P<app>\S*?)\s"'