Skip to content

Instantly share code, notes, and snippets.

@obazoud
obazoud / clean-docker.sh
Last active September 27, 2022 04:56
Remove docker image without tag
#!/bin/bash
sudo docker stop $(docker ps -a -q)
sudo docker rm $(docker ps -a -q)
sudo docker ps -a | grep 'months ago' | awk '{print $1}' | xargs sudo docker rm
sudo docker images | grep "\<none\>" | awk '{ print $3 }' | xargs sudo docker rmi
@obazoud
obazoud / node_debian_init.sh
Last active July 18, 2022 07:56 — forked from peterhost/node_debian_init.sh
Daemon init script for node.js based app/server (DEBIAN/UBUNTU)
#! /bin/sh
# ------------------------------------------------------------------------------
# SOME INFOS : fairly standard (debian) init script.
# Note that node doesn't create a PID file (hence --make-pidfile)
# has to be run in the background (hence --background)
# and NOT as root (hence --chuid)
#
# MORE INFOS : INIT SCRIPT http://www.debian.org/doc/debian-policy/ch-opersys.html#s-sysvinit
# INIT-INFO RULES http://wiki.debian.org/LSBInitScripts
# INSTALL/REMOVE http://www.debian-administration.org/articles/28
@obazoud
obazoud / Graphite - Relay - Collectd
Last active March 16, 2017 20:04
Install Graphite / Collectd in Ubuntu 12.04 (precise 64)
ssh -p 2222 -R 2204:192.168.7.176:2204 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=ERROR -o IdentitiesOnly=yes -i ~/.vagrant.d/insecure_private_key vagrant@127.0.0.1
@obazoud
obazoud / attack-dyn-free.md
Created October 21, 2016 19:33 — forked from bortzmeyer/attack-dyn-free.md
Attack against Dyn from Free (France)
% check-soa -i twitter.com
ns1.p34.dynect.net.
	208.78.70.34: OK: 2007130853 (22 ms)
	2001:500:90:1::34: ERROR: read udp [2001:500:90:1::34]:53: i/o timeout
ns2.p34.dynect.net.
	204.13.250.34: ERROR: read udp 204.13.250.34:53: i/o timeout
ns3.p34.dynect.net.
	208.78.71.34: OK: 2007130853 (28 ms)
	2001:500:94:1::34: ERROR: read udp [2001:500:94:1::34]:53: i/o timeout
@obazoud
obazoud / puppet-agent.sh
Created September 11, 2013 06:47
Append hostname and current timestamp in puppet logs
cd /etc/puppet/ && puppet agent --test --environment=$1 --verbose --debug 2>&1 | awk -v hostname=$(hostname) '{print hostname" - " strftime("%Y-%m-%d %H:%M:%S") " - " $0}'
@obazoud
obazoud / aws-s3-get-bucket-lifecycles.sh
Created May 17, 2016 14:11 — forked from Dunedan/aws-s3-get-bucket-lifecycles.sh
Small bash script to get the lifecycle transitions of all buckets in an AWS account.
#!/bin/bash
AWS_PROFILE="default"
BUCKETS=$(aws --profile $AWS_PROFILE s3api list-buckets --query 'Buckets[*].Name' --output text)
echo -e "bucket name\tstatus of the transition\tprefix the transition applies to\tdays after which the transition applies\tto storage class\tdelete after days\tdescription"
for bucket in $BUCKETS; do
TRANSITION=$(aws --profile $AWS_PROFILE s3api get-bucket-lifecycle --bucket $bucket --query 'Rules[*][Status, Prefix, Transition.Days, Transition.StorageClass, Expiration.Days ID]' --output text 2> /dev/null)
if [ "$?" = "255" ]; then
@obazoud
obazoud / create_table.sql
Created April 8, 2016 15:26 — forked from marcocitus/create_table.sql
Scripts for loading Github events into Citus
CREATE TABLE github_events
(
event_id bigint,
event_type text,
event_public boolean,
repo_id bigint,
payload jsonb,
repo jsonb,
actor jsonb,
org jsonb,
@obazoud
obazoud / myformat_spec.rb
Created January 20, 2014 20:41
Logstash RSpec
require "test_utils"
files = Dir['./etc/*_filters_*.conf']
@@configuration = String.new
files.sort.each do |file|
@@configuration << File.read(file)
end
describe "my format" do
extend LogStash::RSpec
var net = require('net');
net.createServer(httpsSshSwitch).listen(443);
// if the first byte is 22, it is a https handshake,
// so redirect it to the actual https server (running on port 8443)
// else redirect it to the ssh instance.
//
// some ssh clients wait for the server to send the first welcome message
// so if we have not seen any data for 2 seconds, assume it is a ssh connection
# -*- mode: ruby -*-
# vi: set ft=ruby :
# David Lutz's Multi VM Vagrantfile
# inspired from Mark Barger's https://gist.github.com/2404910
boxes = [
{ :name => :web, :role => 'web_dev', :ip => '192.168.33.1', :ssh_port => 2201, :http_fwd => 9980, :cpus =>4, :shares => true },
{ :name => :data, :role => 'data_dev', :ip => '192.168.33.2', :ssh_port => 2202, :mysql_fwd => 9936, :cpus =>4 },
{ :name => :railsapp, :role => 'railsapp_dev', :ip => '192.168.33.3', :ssh_port => 2203, :http_fwd => 9990, :cpus =>1}
]