Skip to content

Instantly share code, notes, and snippets.

View pbzona's full-sized avatar
🤠
having fun on the computer

Phil Z pbzona

🤠
having fun on the computer
View GitHub Profile
@pbzona
pbzona / us-east-1-ip-ranges.py
Created December 19, 2023 22:30
Get all IP ranges for us-east-1
import requests
import json
# URL of the Amazon IP ranges JSON file
url = "https://ip-ranges.amazonaws.com/ip-ranges.json"
# Send a request to get the file
response = requests.get(url)
# Load the JSON data from the response
@pbzona
pbzona / lissajous.go
Created May 13, 2021 13:36
Weird wave band animation
package main
import (
"image"
"image/color"
"image/gif"
"io"
"math"
"math/rand"
"os"
@pbzona
pbzona / clone.js
Created March 24, 2021 20:12
horrible
clone() {
return Object.assign(Object.create(Object.getPrototypeOf(this)), this)
}
@pbzona
pbzona / example.js
Created September 22, 2020 20:06
Wrapping around an array
const magicNumber = 3;
const dataArray = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
let index = 0;
while (true) {
// This is where you get the current item
// I'm just printing it but you can do anything
console.log(dataArray[index]);
@pbzona
pbzona / .zshrc
Created September 21, 2020 16:40
.zshrc
# If you come from bash you might have to change your $PATH.
# export PATH=$HOME/bin:/usr/local/bin:$PATH
export TERM="xterm-256color"
# Path to your oh-my-zsh installation.
export ZSH=/Users/phil/.oh-my-zsh
# Set name of the theme to load. Optionally, if you set this to "random"
# it'll load a random theme each time that oh-my-zsh is loaded.
// Change the value of `array` to see how it behaves with defferent sets
const array = [0, 1, 2, 3, 4, 5];
// Increase the value of `numberOfLoops` to see more examples
const numberOfLoops = 20
console.log("MODULO EXAMPLES");
for (let i = 0; i < numberOfLoops; i++) {
let res = array[(i % array.length)];
console.log(`${i} % ${array.length} = ${res}`);
@pbzona
pbzona / application.scss
Created June 19, 2019 19:30
hello rails 0
@tailwind base;
@tailwind components;
@tailwind utilities;
@pbzona
pbzona / host_modify.py
Last active March 20, 2019 20:36
self.discipline()
#!/usr/bin/env python3
import sys
number_of_args = len(sys.argv)
f = open("/etc/hosts", "a+")
for i in range(number_of_args - 1):
f.write("127.0.0.1 %s\n" % sys.argv[i + 1])
# To use:
@pbzona
pbzona / cors.js
Created January 7, 2019 16:12
fixing CORS in the browser
var response = {
statusCode: 200,
headers: {
"Access-Control-Allow-Origin": "your-domain.com"
}
};
@pbzona
pbzona / organize.js
Created August 14, 2018 21:15
Organize list of resources in cfn template
const fs = require('fs');
// Change this line to your template
const templateFile = './example-template.json';
const cfn = JSON.parse(fs.readFileSync(templateFile));
const resources = cfn.Resources;
const keys = Object.keys(resources);
let obj = {};