Skip to content

Instantly share code, notes, and snippets.

View bmcculley's full-sized avatar

bmcculley

View GitHub Profile
@bmcculley
bmcculley / hostsb4.go
Last active December 27, 2023 02:26
CIDR to ip range
// before 1.18
package main
import (
"fmt"
"log"
"net"
)
func Hosts(cidr string) ([]string, error) {
@bmcculley
bmcculley / index.html
Created December 14, 2023 11:35
Basic html for testing purposes. Includes light and dark mode.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Hello, World!</title>
<style type="text/css">
html {
color-scheme: light dark;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>List Files</title>
<style type="text/css">
.table {
/* Remove spacing between table cells (from Normalize.css) */
border-collapse: collapse;
#include <iostream>
class Greeting {
public:
void say_hello() {
using std::cout;
using std::endl;
int hw[13] = {72, 101, 108, 108, 111, 44, 32, 87, 111, 114, 108, 100, 33};
for (int i = 0; i < 13; i++) {
cout << char(hw[i]);
@bmcculley
bmcculley / rounding.py
Last active January 12, 2023 18:07
Visualize the difference of bankers vs. half up vs. half down vs. no rounding averages.
import math
class deciamlRounding():
def __init__(self, nums = [3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11.5, 13.5, 14.5, 15.5, 16.5, 17.5, 18.5, 19.5, 20.5, 21.5, 22.5, 24.5, 25.5]):
self.nums = nums
# hold the averages
self.no_rounding_avg = float(0.0)
@bmcculley
bmcculley / webserver.go
Created January 9, 2023 20:42 — forked from alexisrobert/webserver.go
Tiny web server in Go for sharing a folder
/* Tiny web server in Golang for sharing a folder
Copyright (c) 2010 Alexis ROBERT <alexis.robert@gmail.com>
Contains some code from Golang's http.ServeFile method, and
uses lighttpd's directory listing HTML template. */
package main
import (
"compress/gzip"
@bmcculley
bmcculley / get_mx_records.php
Created October 14, 2022 02:13
An example of how to get MX records for a domain.
<?php
$records = dns_get_record("abc.xyz", DNS_MX);
foreach ($records as $rec) {
print($rec['host']."\n");
print($rec['type']."\n");
print($rec['pri']."\n");
print($rec['target']."\n");
print($rec['class']."\n");
@bmcculley
bmcculley / twosum.php
Created May 5, 2022 17:18
Quick solution to the Two Sum Problem in PHP
<?php
// https://leetcode.com/problems/two-sum/
function solution($nums, $target) {
$memo = array();
for ($i = 0; $i < count($nums); $i++) {
$key = $target - $nums[$i];
if (array_key_exists($nums[$i], $memo)) {
return array($memo[$nums[$i]], $i);
} else {
@bmcculley
bmcculley / index.js
Last active April 4, 2022 18:46
Master the Coding Interview: Data Structures + Algorithms (udemy, find nemo exercise)
// https://nodejs.org/docs/v12.22.10/api/perf_hooks.html
const {
performance
} = require('perf_hooks');
//#1 -- For loop in Javascript.
const fish = ['dory', 'bruce', 'marlin', 'nemo'];
const nemo = ['nemo'];
const everyone = ['dory', 'bruce', 'marlin', 'nemo', 'gill', 'bloat', 'nigel', 'squirt', 'darla', 'hank'];
const large = new Array(10).fill('nemo');
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/bionic64"
config.vm.define "docker-1" do |node|
node.vm.hostname = "docker-1"
config.vm.box_check_update = false
config.vm.network "public_network"
config.vm.provider "virtualbox" do |vb|
vb.name = "docker-1"
vb.memory = "2048"