This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* fizzbuzz in javascript | |
* @return {string} - output of fizzbuzz coding challenge | |
*/ | |
function fizzbuzz() { | |
let output = ''; // initialize return string | |
for (tmp=1; tmp<=100; tmp++) { // iterate from 1 to 100 | |
if ((tmp % 15) === 0) { // if divisible by 3 and 5 | |
output += 'fizzbuzz'; // add 'fizzbuzz' | |
} else if ((tmp % 3) === 0) { // if divisible by just 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> out_files = [] | |
>>> for dirpath, subidrs, files in os.walk('/home/kolby/Desktop'): | |
... for item in files: | |
... print dirpath + item | |
... | |
/home/kolby/Desktoplabsim1.3_kolby_heacock.pdf | |
/home/kolby/Desktopsteam.desktop | |
/home/kolby/Desktoplabsim1.2_kolby_heacock.pdf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# padding output using printf | |
# reference: https://stackoverflow.com/questions/4409399/padding-characters-in-printf#4410103 | |
pad=$(printf '%0.1s' "-"{1..60}) | |
padlength=40 | |
string2='bbbbbbb' | |
for string1 in a aa aaaa aaaaaaaa; do | |
printf '%s' "$string1" | |
printf '%*.*s' 0 $((padlength - ${#string1} - ${#string2} )) "$pad" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Database Creds | |
$DB_NAME = "<database goes here>"; | |
$DB_USER = "<username goes here>"; | |
$DB_PASS = "<password goes here>"; | |
$DB_HOST = "localhost"; | |
// Get list of tables | |
$get_tables = "mysql " |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# tail_logs.sh | |
tail_logs() { | |
# arguments: IP addresses to search for in logs. | |
files='/usr/local/apache/access_log | |
/usr/local/apache/error_log | |
/var/log/nginx/access.log | |
/var/log/nginx/error.log' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# list primary domains of all | |
# cPanel backups in the current directory. | |
for file in $(\ls backup-*); do | |
tar --occurrence=1 \ | |
--to-stdout \ | |
--extract \ | |
--verbose \ | |
--gzip \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Large numbers example using built-in data types | |
* | |
* Author: | |
* Kolby H. <kolby@fasterdevops.com> | |
* | |
* Published: | |
* November 24, 2017 | |
* | |
* Usage: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
next feature: | |
- import statement | |
- store and retrieve hashmaps | |
- variable handling (list of dictionaries) | |
technical features: | |
- function statement | |
- argument parsing | |
- commands: | |
- print statement |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
''' | |
Inspired by https://xkcd.com/1930/ | |
''' | |
from random import randint | |
class CalendarFact: | |
def __init__(self): | |
self.date = ['The Fall Equinox', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
def main(): | |
''' | |
This is the Python equivalent to the following C code: | |
int n; | |
printf("Enter a Number"); | |
scanf("&d",n); | |
if(n==1) | |
printf("true"); |