Skip to content

Instantly share code, notes, and snippets.

View omar-yassin's full-sized avatar

Omar Yassin omar-yassin

View GitHub Profile
export PS1='\e[1;35m\u\e[m@\h:\e[1;31m\w\e[m\n\$ '
export PATH="$PATH:~/bin/"
# auto complete hostnames
_complete_ssh_hosts ()
{
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
comp_ssh_hosts=`cat ~/.ssh/known_hosts | \
cut -f 1 -d ' ' | \
@omar-yassin
omar-yassin / gist:9b2cdbf0a7aaf80f74350f2c8d9f832e
Created September 15, 2016 21:18
shell init deamon skeleton
#!/bin/bash
# chkconfig: 345 99 01
# description: ${SOME_NAME}
. /etc/rc.d/init.d/functions
RUNAS=omar
NAME='loop_test'
SCRIPT='/home/omar/while_loop.sh'
LOG_FILE="/home/omar/${NAME}.log"
node['ec2']['instance_id']
node['ec2']['local_ipv4']
node['ec2']['placement_availability_zone']
node['ec2']['ami_id']
export PS1='\e[1;32m[\t] \e[1;35m\u\e[m@\h:\e[1;31m\w\e[m\n\$ '
@omar-yassin
omar-yassin / gist:557e0a29d6bd1f2ff410f94d12061dc8
Created May 11, 2016 20:01
Logstash: replace kv with ruby (save fields as string, int or float)
ruby {
code =>
"
fieldArray = event['lb_message'].split(' ');
for field in fieldArray
name = 'prefix_' + field.split('=')[0];
value = field.split('=')[1];
if value =~ /\A\d+\Z/
event[name] = value.to_i
elsif value =~ /(^(\d+)(\.)?(\d+)?)|(^(\d+)?(\.)(\d+))/
@omar-yassin
omar-yassin / gist:7ae39da34fb6488f9d76b224a3e2593b
Created May 6, 2016 01:58
JQ: Hyphen/-/Special Chars in Keys
Does't work:
jq '.foo.dude-yes'
Works
jq '.foo["dude-yes"]'
@omar-yassin
omar-yassin / gist:0efe814cf29be33dfe1772b5e702e0be
Last active April 13, 2016 04:09
Powershell: pretty way to compare if string contains multiple strings
$failed_status_types = 'CREATE_FAILED', 'DELETE_FAILED', 'ROLLBACK_FAILED', 'UPDATE_ROLLBACK_FAILED'
if ($failed_status_types -match "some_string" ) { "si" }
#f*ck joo
$deploy_args = @(
"-verb:sync",
"-source:package=$provisioning_dir/$zip_name",
"-dest:auto",
"-setParam:name='IIS Web Application Name',value='omar'"
)
$deploy = Start-Process ${msdeploy_bin} -NoNewWindow -ArgumentList $deploy_args -PassThru -Wait
@omar-yassin
omar-yassin / gist:7a02d01b66e98612afaa
Last active December 9, 2015 20:23
Powershell AWS Get-elbtag Example
((get-elbtags -LoadBalancerName ELB-OMAR).Tags | where {$_.key -eq 'tag-name'}).Value
$instance_state = (Get-ELBInstanceHealth -LoadBalancerName $elb_name | where {$_.InstanceId -eq "$instance_id"}).State