Skip to content

Instantly share code, notes, and snippets.

View haisum's full-sized avatar

Haisum Mussawir haisum

View GitHub Profile
@haisum
haisum / script.sh
Created September 1, 2015 06:10
comment and uncomment lines in bash script via sed
sed -i '/<pattern>/s/^/#/g' file #comment
sed -i '/<pattern>/s/^#//g' file #uncomment
@haisum
haisum / postfix-dovecot-ubuntu14.04.sh
Last active February 7, 2024 08:37
Automated bash script to setup dovecot postfix mysql email server on ubuntu 14.04
#!/usr/bin/env bash
#####
# Script to install postfix
#####
DOMAIN="example.com"
EMAIL="haisum@example.com"
PASSWORD="example.com1*"
@haisum
haisum / sleepFor.js
Created September 30, 2015 07:13
Javascript sleep function
function sleepFor( sleepDuration ){
var now = new Date().getTime();
while(new Date().getTime() < now + sleepDuration){ /* do nothing */ }
}
@haisum
haisum / C.sublime-build
Created November 16, 2015 06:26
C build system for sublime text 3 on windows
{
"cmd" : ["gcc", "$file_name", "-o", "${file_base_name}.exe"],
"selector" : "source.c",
"shell": true,
"working_dir" : "$file_path",
"variants" : [
{ "name": "Run",
"cmd" : ["${file_base_name}.exe"]
}
@haisum
haisum / parsejson.sh
Created November 26, 2015 13:50
Parsing json on bash using python
response='{"buildsNumbers":[{"uri":"/7","started":"2015-11-26T04:28:24.443-0500"},{"uri":"/8","started":"2015-11-26T06:31:54.770-0500"}],"uri":"http://example.com/api"}'
python -c "import json; s=json.loads('$response');print(max(s['buildsNumbers'], key = (lambda key: int(key['uri'][1:])))['uri']);"
@haisum
haisum / mysql-innodb-bakcup-restore.sh
Created January 2, 2016 05:05
script to restore and perform incremental mysql backups
#!/bin/bash -x
#Tue Jul 2 15:32:21 CEST 2013
#Made by Edward Z.
set -e #stops execution if a variable is not set
set -u #stop execution if something goes wrong
usage() {
echo "usage: $(basename $0) [option]"
echo "option=full: do a full backup of vinnie /var/lib/mysql using innobackupex, aprox time 6 hours."

Generated private key

openssl genrsa -out server.key 2048

To generate a certificate

openssl req -new -x509 -key server.key -out server.pem -days 3650

https

@haisum
haisum / hsmpp.wsdl.xml
Created February 28, 2016 14:17
WSDL file example
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="Hsmpp Service"
targetNamespace="http://www.csoft.co.uk/dtd/sendsms5.wsdl"
xmlns:tns="http://www.csoft.co.uk/dtd/sendsms5.wsdl"
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:ns2="http://www.csoft.co.uk/dtd/sendsms5.xsd"
xmlns:SOAP="http://schemas.xmlsoap.org/wsdl/soap/"
@haisum
haisum / oracle_all_fk_references_of_table.sql
Created May 19, 2016 11:04
Find all foreign key reference to a table in oracle
select
src_cc.owner as src_owner,
src_cc.table_name as src_table,
src_cc.column_name as src_column,
dest_cc.owner as dest_owner,
dest_cc.table_name as dest_table,
dest_cc.column_name as dest_column,
c.constraint_name
from
all_constraints c
@haisum
haisum / example_receiver.sh
Last active May 26, 2016 08:44
example receiver script
#!/bin/bash
SRC=$1
DST=$2
MSG=$3
CONN=$4
GROUP=$5
# Example of saving received sms to a file as csv