Skip to content

Instantly share code, notes, and snippets.

View codejake's full-sized avatar
☕

Jake Shaw codejake

☕
View GitHub Profile
@codejake
codejake / read-csv.py
Created April 24, 2024 15:15
Here you go. This Python script reads a CSV file. If you need additional learnin', get in touch.
#!/usr/bin/env python3
# Sample Python script for noobs. This script will run on just about any
# Python 3 install without additional software installation required.
import csv
# Specify the path to your CSV file
file_path = 'data.csv'

Using pipx

pipx is a tool for installing and running Python applications in isolated environments. It's especially useful for Python-based tools and scripts that are intended to be run from the command line, rather than imported into other Python code. By using pipx, you can install applications and their dependencies in isolated environments, avoiding conflicts between packages and ensuring that each application has the specific versions of libraries it requires.

Installation

macOS

Install using brew install pipx or manually, using: python -m pip install --user pipx.

Afterwards, run pipx ensurepath to ensure that pipx in is your PATH.

#!/usr/bin/env python3
# A simple script that checks the current directory for a github remote
# and if found, opens the remote repo in a browser window.
# Works on macOS, at least. Can be adapted for Windows & Linux.
import subprocess
import sys
try:
// Terrible Swift code generated by the llama LLM model.
import Foundation
let osVersion = ProcessInfo.processInfo().operatingSystemVersion as String
print("Your operating system is (osVersion)n")
let deviceSerialNumber = ProcessInfo.processInfo().deviceId as String
print("Your device identifier is (deviceSerialNumber)n")
let urlString = "https://foo.org/submit"
guard let url = URL(string: urlString), !url.isFileURL else { return }
let request = NSMutableURLRequest(url: url, cachePolicy: .reloadIgnoringCacheData)
@codejake
codejake / use-a-conf.py
Created June 24, 2022 16:07
Using a conf file with Python basic example
#!/usr/bin/env python3
# my.conf:
# [DEFAULT]
# my_user = bob@aol.com
# my_pass = s3cr3t
import configparser
config = configparser.ConfigParser()
from queue import Queue
from threading import Thread
from time import sleep
from rich.live import Live
from rich.panel import Panel
from rich.progress import Progress, SpinnerColumn, BarColumn, TextColumn
from rich.table import Table as rcTable
from rich.console import Console
from rich.spinner import Spinner, SPINNERS
from rich.status import Status
#!/bin/bash
# Store multiple lines of text in a variable.
# More info: https://linuxhint.com/bash-define-multiline-string-variable/
MYLINES=$(cat << EOF
line 1
line 2
line3 (but really line 4)
EOF
<?php
/*
* Fortigate
*
* Props to @laf
*/
/* fgWfHTTPBlocked */
if (str_contains($sensor['sensor_oid'], '.1.3.6.1.4.1.12356.101.10.1.2.1.1.1'))
mib: FORTINET-FORTIGATE-MIB
modules:
mempools:
data:
-
total: FORTINET-FORTIGATE-MIB::fgSysMemCapacity
percent_used: FORTINET-FORTIGATE-MIB::fgSysMemUsage
precision: 1024
descr: 'Main Memory'
os:
#!/bin/bash
# Usage:
# $ notes.sh something you want to jot down (appends that text to the file)
# $ xclip -o | notes.sh (appends your clipboard to the file)
# $ notes.sh
readonly NOTES_DIRECTORY="${HOME}/Documents/Obsidian/Notes/Daily"
NOTE_DATE=`date +'%Y-%m-%d'`