Skip to content

Instantly share code, notes, and snippets.

View discarn8's full-sized avatar

discarn8 discarn8

View GitHub Profile
@discarn8
discarn8 / stocks_to_png.py
Last active February 4, 2019 06:27
Python2.7 script to pull your favorite stock and graph it (currently - 5 day trend)
#!/usr/bin/env python2
#Squelch matplotlib / seaborne error
import warnings
warnings.filterwarnings("ignore")
import matplotlib
import matplotlib.pyplot as plt
import pandas
import MySQLdb
@discarn8
discarn8 / ping.vba
Last active May 9, 2023 04:45
ping.vba
#Taken from: http://scriptorium.serve-it.nl/view.php?sid=68
#and
#https://www.mrexcel.com/forum/excel-questions/391426-ping-list-servers-excel.html
Option Explicit
'Requires references to Microsoft Scripting Runtime and Windows Script Host Object Model.
'Set these in Tools - References in VB Editor.
Public Function PingResult(sHost As String) As String
@discarn8
discarn8 / nslookup.vba
Created January 30, 2019 22:15
nslookup.vba
#Copied from https://www.geekality.net/2016/03/07/excel-function-for-nslookup-in-worksheet/
#Usage: Given an IP in cell A1, to get the hostname: =NSLookup(A1; 2)
Public Function NSLookup(lookupVal As String, Optional addressOpt As Integer) As String
Const ADDRESS_LOOKUP = 1
Const NAME_LOOKUP = 2
Const AUTO_DETECT = 0
'Skip everything if the field is blank
If lookupVal <> "" Then
Dim oFSO As Object, oShell As Object, oTempFile As Object
@discarn8
discarn8 / FreeBsd_Nagios_CPU_Temp_Wrapper.sh
Last active January 21, 2019 10:01
FreeBsd_Nagios_CPU_Temp_Wrapper
#1
: sysctl -a | egrep -i 'hw.machine|hw.model|hw.ncpu'
hw.machine: amd64
hw.model: Intel(R) Celeron(R) CPU 1037U @ 1.80GHz
hw.ncpu: 2
hw.machine_arch: amd64
#2 Test for temp
:/sbin/sysctl hw.acpi.thermal.tz0.temperature
:/sbin/sysctl -a | grep "^dev.*0.temperature"
@discarn8
discarn8 / Brute_Find.sh
Last active February 4, 2019 05:36
Brute_Find.sh
Brute Find
#Use:
#sudo ./brutefind.sh > /dev/null 2>&1
#find /sys/ -type f | while read f; do
#find /proc/ -type f | grep -v '/proc/^[0-9]\{5\}$' | while read f; do
find /proc/ -type f | while read f; do
#Grep quietly on the results (read f) of files. Count the numbers, contained within.
@discarn8
discarn8 / view_images.php
Created January 18, 2019 05:08
PHP View images in a Directory
View Images - basic - numbered
---------------------------------------------------------
<?php
$files = glob("*.jpg");
/* for ($i=1; $i<count($files); $i++) */
for ($i=1; $i<=10; $i++)
{
$num = $files[$i];
list($width, $height, $type, $attr) = getimagesize("'.$num.'");
$fn = getimagesize("'.$num.'");
@discarn8
discarn8 / Raspberry_PI_Email_TEMP.sh
Created January 14, 2019 07:27
Raspberry_Pi_Hourly_Temp_email
#!/bin/bash
#Pre-requisites: file named hourly_temp, smtp client
#touch hourtemp_email
cat /dev/null>/home/pi/hourtemp_email
hourlytemp=$(awk '{print $1/1000 * 1.8 + 32}' /sys/class/thermal/thermal_zone0/temp | awk '{printf("%d\n",$1 + 0.5)}')
export [email protected]
export [email protected]
export sensorsubject=TEMP:$hourlytemp
@discarn8
discarn8 / Python_graph_csv_files_in_directory_with_total_and_count.py
Last active July 30, 2018 21:54
Python_graph_csv_files_in_directory_with_total_and_count
%matplotlib inline
import time
import os
import glob
import seaborn as sns
import numpy as np
import pandas as pd
import matplotlib.pylab as plt
from matplotlib import rcParams
rcParams.update({'figure.autolayout': False})
@discarn8
discarn8 / Python_list_specific_filetypes_with_mod-date_in_directory.py
Created July 30, 2018 20:45
Python_list_specific_filetypes_with_mod-date_in_directory
import os
#import glob
#import time
path = "C:/path/to?files/*.csv"
for fname in glob.glob(path):
temp1=os.path.basename(os.path.normpath(fname))
filename=temp1.split('.')[0]
dt=time.strftime('%Y%m%d', time.gmtime(os.path.getmtime(fname)))
print(filename+","+dt)
@discarn8
discarn8 / Python_list_specific_filetypes_in_directory.py
Created July 30, 2018 20:41
Python_list_specific_filetypes_in_directory
import os
#Change csv to match the file extension you are searching for
path = "C:/path/to/files/*.csv"
for fname in glob.glob(path):
temp1=os.path.basename(os.path.normpath(fname))
filename=temp1.split('.')[0]
print(filename)