Skip to content

Instantly share code, notes, and snippets.

View abhinavkorpal's full-sized avatar
🎯
Focusing

Abhinav korpal abhinavkorpal

🎯
Focusing
View GitHub Profile
def print_full_name(a, b):
print "Hello {0} {1}! You just delved into python.".format(a, b)
def mutate_string(string, position, character):
l = list(string)
l[position] = c
return "".join(l)
@abhinavkorpal
abhinavkorpal / string.py
Created April 11, 2017 06:25
Find a string
def count_substring(string, sub_string):
count = 0
for i in range(len(string)-len(sub_string)+1):
if(string[i:i+len(sub_string)]==sub_string):
count += 1
return count
@abhinavkorpal
abhinavkorpal / string_validators.py
Created April 11, 2017 13:39
String Validators
if __name__ == '__main__':
s = raw_input()
print any(c.isalnum() for c in s)
print any(c.isalpha() for c in s)
print any(c.isdigit() for c in s)
print any(c.islower() for c in s)
print any(c.isupper() for c in s)
#Replace all ______ with rjust, ljust or center.
thickness = int(raw_input()) #This must be an odd number
c = 'H'
#Top Cone
for i in range(thickness):
print (c*i).rjust(thickness-1)+c+(c*i).ljust(thickness-1)
#Top Pillars
def wrap(string, max_width):
return textwrap.fill(string,max_width)
@abhinavkorpal
abhinavkorpal / gist:5eaaee2ec0e3861cf761d88ccc9cf7ec
Created April 17, 2017 10:53
Installing Jenkins on Ubuntu
wget -q -O - https://pkg.jenkins.io/debian/jenkins-ci.org.key | sudo apt-key add -
sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
sudo apt-get update
sudo apt-get install jenkins
sshpass -p 'nhGfJfU0' rsync -avu --exclude-from=/var/www/vhosts/IP ADRESSS/IP ADRESSS/dl-cpdpod/omit.txt -e ssh --chmod=Du=rwx,Dg=rx,Do=rx,Fu=rw,Fg=r,Fo=r -p --delete [email protected]:/var/www/vhostsIP ADRESSS/IP ADRESSS/xml-data/build-dir/1769473-1900545/ /var/www/vhosts/IP ADRESSS/IP ADRESSS/dl-cpdpod/
@abhinavkorpal
abhinavkorpal / Ansible For Ubuntu
Last active June 23, 2017 09:37
Ansible Commands
sudo apt-get install software-properties-common
sudo apt-add-repository ppa:ansible/ansible
sudo apt-get update
sudo apt-get install ansible
ansible --version
ansible-playbook --version
ansible-galaxy --help
ansible --list-hosts all
sudo vi /etc/ansible/hosts
ansible -i dev --list-host all
@abhinavkorpal
abhinavkorpal / videoconv.bash
Last active July 5, 2017 07:11
Script For Video Conversion
#!/bin/bash
FFMPEG=/usr/bin/ffmpeg
HD_SUFFIX='_hd'
EMBED_WIDTH='640'
EMBED_HEIGHT='360'
SD_RESOLUTION=$EMBED_WIDTH'x'$EMBED_HEIGHT