Skip to content

Instantly share code, notes, and snippets.

View dragolabs's full-sized avatar

Vitaly Shishlyannikov dragolabs

View GitHub Profile
@dragolabs
dragolabs / sublime settings
Created March 7, 2014 09:24
sublime settings
{
"font_size": 15,
"ignored_packages":
[
"Vintage",
"Markdown"
],
"open_files_in_new_window": false,
"soda_classic_tabs": true,
"soda_folder_icons": true,
#!/bin/bash
while getopts a:bc: flag; do
case $flag in
a)
opt_a=$OPTARG
;;
b)
opt_b=1
;;
@dragolabs
dragolabs / ssh-proxy
Created May 23, 2014 08:30
SOCKS proxy through ssh
ssh -D 9999 user@server
use socks 4\5, disable other proxy settings
@dragolabs
dragolabs / fpm-example.sh
Created July 2, 2014 15:24
Example for packaging pecl extension with fpm
fpm --force \
-s dir \
-t deb \
--vendor dragolabs \
--maintainer 'Vitaly Shishlyannikov <vitaly@dragolabs.org>' \
--deb-user root \
--deb-group root \
--url http://dragolabs.org \
--version $VERSION \
--iteration ddr`date +%y%m%d%H%M` \
@dragolabs
dragolabs / bash-header.sh
Created July 2, 2014 15:28
Example head of bash script
#!/usr/bin/env bash
set -o pipefail
set -o errexit
# set -o xtrace
__DIR__="$(cd "$(dirname "${0}")"; echo $(pwd))"
__BASE__="$(basename "${0}")"
__FILE__="${__DIR__}/${__BASE__}"
@dragolabs
dragolabs / all_ip.rb
Last active August 29, 2015 14:06
Dumb ohai7 plugin show all IP addresses of the node exclude localhost.
#
# Author:: Vitaly Shishlyannikov (<vitaly@dragolabs.org>)
# Copyright:: Copyright (c) 2014
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
@dragolabs
dragolabs / dc_location.rb
Last active August 29, 2015 14:11
Find location of server by local ip address
require 'socket'
def have_ip?(ip)
ip_arr = Socket.ip_address_list.select{|intf| intf.ipv4?}
ip_arr.to_s.scan(/(?<=: )[\d.]+(?=>)/).find{ |e| /#{ip}/ =~ e }
end
if File.exist?('/var/local/location.txt')
dc_location = File.read('/var/local/location.txt')
@dragolabs
dragolabs / GHOST-debian-fix.sh
Last active August 29, 2015 14:14
Update all installed libc packages in system
sudo aptitude safe-upgrade `dpkg -l | awk {'print $2'}| grep -e "^libc[-|6]" | paste -s`
or
sudo aptitude safe-upgrade `dpkg -l | cut -d " " -f 3 | grep -e "^libc[-|6]" | paste -s`
@dragolabs
dragolabs / knife-set-desc.sh
Last active August 29, 2015 14:19
Script for create description for chef's nodes in attribute "desc".
#!/bin/bash
echo "Set description for chef's nodes. Press ENTER to skip node."
for NODE in `knife search "! desc:*" -i | tail -n+2`;do
echo "Node: ${NODE}"
echo -n 'Description: '
read DESC
if [ ! -z "${DESC}" ];then
knife node attribute set ${NODE} desc "${DESC}"
else
@dragolabs
dragolabs / s3-grant-one-bucket
Last active September 11, 2015 16:46
Policy for access to one S3 bucket
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["s3:ListBucket"],
"Resource": ["arn:aws:s3:::my-backup"]
},
{
"Effect": "Allow",