Skip to content

Instantly share code, notes, and snippets.

View jmcabandara's full-sized avatar
🎯
Focusing

Chaminda Bandara jmcabandara

🎯
Focusing
View GitHub Profile

Fizz Buzz Test

Write a program that prints the numbers from 1 to 100. But for multiples of three print “Fizz” instead of the number and for the multiples of five print “Buzz”. For numbers which are multiples of both three and five print “FizzBuzz”.

Answer & Refinement process

Don't look until you want to see how I thought through it:

Final Shortest Answer

@jmcabandara
jmcabandara / FizzBuzz.py
Created July 23, 2018 07:12 — forked from jaysonrowe/FizzBuzz.py
FizzBuzz Python Solution
def fizzbuzz(n):
if n % 3 == 0 and n % 5 == 0:
return 'FizzBuzz'
elif n % 3 == 0:
return 'Fizz'
elif n % 5 == 0:
return 'Buzz'
else:
return str(n)
@jmcabandara
jmcabandara / gist:bb7e61ed054ac7b53c1fde8c1d1d7c36
Created July 19, 2018 12:15 — forked from adamstac/gist:7462202
Install and configure Sendmail on Ubuntu

Install and configure Sendmail on Ubuntu

This should help you get Sendmail installed with basic configuration on Ubuntu.

  1. If sendmail isn't installed, install it: sudo apt-get install sendmail
  2. Configure /etc/hosts file: nano /etc/hosts
  3. Make sure the line looks like this: 127.0.0.1 localhost yourhostname
  4. Run Sendmail's config and answer 'Y' to everything: sudo sendmailconfig
  5. Restart apache sudo service apache2 restart
@jmcabandara
jmcabandara / dbserver.yml
Created July 11, 2018 16:32 — forked from ihassin/dbserver.yml
Ansible script to install mySQL
- hosts: webservers
user: vagrant
sudo: true
vars_files:
- vars.yml
tasks:
- name: Install MySQL
action: apt pkg=$item state=installed
with_items:
Ansible playbook to setup HTTPS using Let's encrypt on nginx.
The Ansible playbook installs everything needed to serve static files from a nginx server over HTTPS.
The server pass A rating on [SSL Labs](https://www.ssllabs.com/).
To use:
1. Install [Ansible](https://www.ansible.com/)
2. Setup an Ubuntu 16.04 server accessible over ssh
3. Create `/etc/ansible/hosts` according to template below and change example.com to your domain
4. Copy the rest of the files to an empty directory (`playbook.yml` in the root of that folder and the rest in the `templates` subfolder)
@jmcabandara
jmcabandara / Linux Static IP
Created July 5, 2018 07:18 — forked from fernandoaleman/Linux Static IP
How To Configure Static IP On CentOS 6
## Configure eth0
#
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=A4:BA:DB:37:F1:04
TYPE=Ethernet
BOOTPROTO=static

#Nginx Basics for Ubuntu

Please see http://wiki.nginx.org/Main for more information. See http://arstechnica.com/gadgets/2012/11/how-to-set-up-a-safe-and-secure-web-server/ for a tutorial on how to install Nginx.

##Installation To install, you can install the version which is in the standard Ubuntu repositories but it is normally quite old and will not have the latest security patches. The best way is to update the repositories first:

apt-get update
apt-get install python-software-properties

apt-get upgrade

@jmcabandara
jmcabandara / ansible_nginx.yml
Created June 25, 2018 09:33 — forked from uorat/ansible_nginx.yml
Ansible Playbook for installing Nginx
---
########################################
## Ansible Playbook for installing Nginx
########################################
- name: check registered the repository of nginx-release
shell: rpm -qa | grep nginx-release
register: result
ignore_errors: True

Keybase proof

I hereby claim:

  • I am jmcabandara on github.
  • I am jmcabandara (https://keybase.io/jmcabandara) on keybase.
  • I have a public key ASD_M_oO9YIz4-6EdOLdz6Y0PI5QO6xyqVwxd79p3PcOBQo

To claim this, I am signing this object:

@jmcabandara
jmcabandara / install.sh
Created January 5, 2018 09:14 — forked from Justasic/install.sh
This was a simple shell script I made to install EPEL and REMI yum repos. I have installed so many CentOS machines that I get tired of running the same commands over and over so I made this a script. Run `curl https://gist.githubusercontent.com/Justasic/9855295/raw/install.sh | sh` to install.
#!/bin/sh
# Install yum priorities to make sure we aren't going to try and install fedora on centos :s
yum install yum-priorities -y
# Import the GPG keys for package verification signatures
rpm --import https://fedoraproject.org/static/0608B895.txt
rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
# Install epel and remi repos