Skip to content

Instantly share code, notes, and snippets.

View dkhabarov's full-sized avatar

Denis Khabarov dkhabarov

View GitHub Profile
@atomatt
atomatt / gist:2732574
Created May 19, 2012 22:21
Simplified/generic ini-style inventory parser for Ansible
import codecs
class Parser(object):
def __init__(self):
self.nodes = {}
def node_with_name(self, name):
node = self.nodes.get(name)
@dsadaka
dsadaka / \lib\systemd\system\sidekiq-static.service
Last active June 21, 2019 19:20
systemd unit files for sidekiq service. note backslashes in filenames are really front slashes.
# This file actually fires up multiple sidekiq services.
# to start: systemctl start sidekiq.target
#
[Unit]
Description=Fire up up to 6 sidekiqs
# If you want more than 6 processes, append sidekiq@7.service, sidekiq@8.service, etc. to the ExecStart line below
# Note that only as many as have been enabled will actually start.
# Note also that the Unit data for each sidekiq process is in /lib/systemd/system/sidekiq@.service
[Service]
@swaldman
swaldman / GethAsAService.md
Last active October 9, 2022 02:18
Setting up geth as a service under systemd (Updated for Fedora 27)

Setting up geth as a service under systemd Fedora 27

Prerequisite: dnf install golang

  1. Create user geth with useradd
  2. As user geth fast sync the blockchain, geth --fast --cache 1024
  3. Manually run geth --rpc as user geth and watch to see that the blockchain continues to sync properly
  4. Install the geth.service file (also in this gist) in /usr/lib/systemd/system/
  5. Make a symlink from /etc/systemd/system/multi-user.target.wants/geth.service to /usr/lib/systemd/system/geth.service
  6. systemctl enable geth followed by systemctl start geth
@z0mbix
z0mbix / tcpdump-es-capture
Created December 19, 2014 14:45
Capture Elasticsearch Queries
# tcpdump -A -nn -s 0 'tcp dst port 9200 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' -i lo
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on lo, link-type EN10MB (Ethernet), capture size 65535 bytes
14:32:33.525122 IP 127.0.0.1.49777 > 127.0.0.1.9200: Flags [P.], seq 313752908:313753888, ack 2465010394, win 257, options [nop,nop,TS val 2684167067 ecr 2684167066], length 980
E...^.@.@............q#...}L...............
..#...#.GET /index/_search HTTP/1.1
Host: 127.0.0.1:9200
Accept: */*
Content-Length: 845
Content-Type: application/x-www-form-urlencoded
@ceme
ceme / bash_curl_loop
Last active January 19, 2023 13:07
bash curl loop
while true; do sleep 1; curl http://www.google.com; echo -e '\n\n\n\n'$(date);done
@nickjacob
nickjacob / systemd-prblm.service
Last active March 17, 2023 16:11
execute arbitrary bash code/variable substitution in systemd units
[Unit]
Description=Demonstrate Bash
[Service]
ExecStartPre=/usr/bin/bash -c "/usr/bin/systemctl set-environment MYVAR=$(( 2 + 2 ))"
ExecStart=/usr/bin/echo "2 + 2 = ${MYVAR}"
@reyjrar
reyjrar / elasticsearch.yml
Last active May 12, 2023 11:58
ElasticSearch config for a write-heavy cluster
##################################################################
# /etc/elasticsearch/elasticsearch.yml
#
# Base configuration for a write heavy cluster
#
# Cluster / Node Basics
cluster.name: logng
# Node can have abritrary attributes we can use for routing
@sj26
sj26 / sidekiq.service
Last active July 4, 2023 19:20 — forked from dsadaka/\lib\systemd\system\sidekiq-static.service
systemd unit files for multiple sidekiq workers
[Unit]
Description=Sidekiq workers
# start as many workers as you want here
Wants=sidekiq@1.service
Wants=sidekiq@2.service
# ...
[Service]
Type=oneshot
ExecStart=/bin/true
@JProffitt71
JProffitt71 / s3cmdclearfiles
Created February 17, 2014 04:29
Uses s3cmd to manually remove files older than specified date (##d|m|y) in a specified bucket
#!/bin/bash
# Usage: ./s3cmdclearfiles "bucketname" "30d"
s3cmd ls s3://$1 | grep " DIR " -v | while read -r line;
do
createDate=`echo $line|awk {'print $1" "$2'}`
createDate=`date -j -f "%Y-%m-%d %H:%M" "$createDate" +%s`
olderThan=`date -j -v-$2 +%s`
if [[ $createDate -lt $olderThan ]]
@Neo23x0
Neo23x0 / audit.rules
Last active January 13, 2024 14:12
Linux Auditd Best Practice Configuration
# IMPORTANT!
# This gist has been transformed into a github repo
# You can find the most recent version there:
# https://github.com/Neo23x0/auditd
# ___ ___ __ __
# / | __ ______/ (_) /_____/ /
# / /| |/ / / / __ / / __/ __ /
# / ___ / /_/ / /_/ / / /_/ /_/ /
# /_/ |_\__,_/\__,_/_/\__/\__,_/