Nagios Python Plugin Check Lock File Exists

PYTHON – Script to download youtube videos for offline viewing

I was interested in viewing this video of a news conference (USENIX 2016) on my trip home on Metro North Train, NYC => CT. The trip is about an hour an 10 minutes from Manhattan’s Grand Central Terminal to Milford CT, express train that is. My concern was that I would have choppy internet service on the way since I recently updated my laptop and the built in Verizon Mobile card was not activated yet. I would need to use my ATT iPhone as a hotspot, which proved to be very shakey at times. A colleague of mine recommended a website for making youtube videos available for offline viewing. The name of this site was:

http://www.keepvid.com

Right off the rip I was concerned that this site was infested with malware and any other bullshit associated with a free video ripping service. I used the site and was able to create a download of the video I was interested in, however who knows how sick my Windows based machine just got. I could of contracted anything from this site.

I thought about this and said, there has to be a better way, or a python lib for this, and low and behold a search came up with PYTUBE:
https://github.com/nficano/pytube

This library had some interesting features and literally blew away the keepvid site in regards to flexibility. Here is some explaining of what this library can do. Please have a look at the examples below, I will do my best to narrate them.

Here I use PIP to install the PYTUBE lib, you can ignore the DEPRECATION: warning for my outdated python that blares at you for being such an idiot.

Next up you can see that I am setting a variable yt(this is the video you want to download). Using python’s Pretty Print Lib you can run the pprint(yt.get_videos() method to see what formats are available for download.

Please have a look at the comments in the code for a bit more details in regards to what is going on, in this example I am using the filename Pulp_Fiction.mp4 for my filename I want to be when downloaded.

Ok so here is what it looks like when you execute the program:

As you can see we have a new filename with the video we asked for to watch without a streaming internet connection, here is a ls to show:

As always, I am sure there are better ways to do this and I am sure there is cleaner code. Most of this code was taken right from the authors site who is a badass, here is his link:

https://github.com/nficano/pytube

Hope you liked,
J$0N

Daily Weather Email – PYTHON – CRON – API

I was interested in the weatherunderground API for getting real time weather updates via the API and python.
WeatherUnderGroundApiLink:
http://www.wunderground.com/weather/api/
I was particularly interested in learning how to use the JSON python module. So I thought I would give you people a quick and dirty write up of how I get a daily weather update with endless categories via email on linux using python.

Ok so here we go, don’t get all excited and post this on hacker news and crash my t1.micro at AWS.

Let’s have a lookie at the python script where the magic takes place. O Yeah you will need to get an API KEY from WeatherUnderground for this. Look here:
http://www.wunderground.com/weather/api/d/login.html

The API will look like this once you obtain your copy:

Here is the link for requests:
http://docs.python-requests.org/en/master/
Ok let me break down the PY code:

It’s probably important to see what we get back from the API in JSON so the below code makes sense. Here we go, this is just pretty printing the JSON using pythons PPRINT module, Showing this snippet first to help understand the code.

SCRIPT:

OUTPUT:

Ok let’s parse this JSON and send a freaking daily email with the fields we want, O Yeah.

Here is the script commenting on what we are doing.

Here is what comes out of this python script when we call the JSON variables we are attracted to:

Ok let’s wrap this biatch into a shell script and have it call mail on linux so I can get a daily updates on the weather for Milford CT whenever I call the cron.

Here is the directory structure I setup for the scripts:

Here is the bash script that I wrote to bring it all together, it calls the python script and writes a log and mails it.

Here is the cron:

Here is my morning email message:

View post on imgur.com

Hope you had fun, I did. O and let me know how bad this post is and how you can do it better.
Love you

Analytic’s – Fuckin A

Well I thought I would write up a quick post to demonstrate that even the slower kids like myself can achieve web visitors hitting their site if they put some effort behind it. I started this blog back in late 2012 and I only posted a couple of code snippets here and there. Then my coding skills developed a bit and I kept the domain alive so it started to get a bit more traffic. Anyway this really is not much traffic, but it’s neat to say that I have had my blog up and recording visits for some time now.

Google Analytics JR.org

So here it is, if you want to advertise hit me up at [email protected] 🙂

Code Highlighting Test

I just installed the crayon code highlight plugin from the link below, man you got to give credit where credit is due. This plugin was simple to install on my site and it has endless code highlighting capabilities.
Crayon Highlight
OMG: This is some pretty code highlighting if I must say so myself. Have a look:

PYTHON:

PHP:

C++:

BASH:

PERL:

JAVA:

CYGWIN – clear.exe from scratch C Program

Hello all,

TL;DR – I wrote a C program to use as clear.exe on cygwin, I know about CTRL-L but I wanted a binary for scripts, and I am used to typing clear at a terminal

I was recently enforced to use Windows as my daily computer at work for all types of compliance PCI reasons, reasons that I do not wish to dive into. However I am now on Windows, I spend most of my day in a BASH shell on a remote system, so it’s not that bad. However traversing around Windows with CMD or PS sucked. I was introduced to cygwin and I was really impressed, I was able to use a ton of tools that I was already familiar with on the Linux CLI. Native SSH,SCP were huge for me at this time, also the ability to customize the colors with the TTY settings was awesome.

One issue I ran into was I liked to use the clear command in my scripts and from the CLI when I want a fresh terminal. Well, I figured I could just re launch the cygwin installer and search for clear.exe and install it. This was not the case, unfortunately I was instructed to install ncurses and the associated libraries. I followed these recommendations and never got clear.exe to work.

So I did what any computer scientist would do, research how to write a C program on this and compile it and copy it to my $PATH and wouldn’t you know it works!!.

So Here it is in all it’s glory. clear.exe for Windows and CYGWIN:

### Clear no workie ###

Ok so we can see the clear program was not working in the above example. So I wrote the following lines of C code below and compiled them.

OK, cool, now you will need to get GCC on your Windows machine from the CYGWIN installer, so just re run the installer and search GCC, you can install it from there like so.

View post on imgur.com

Ok now for the awesome stuff, it’s time to compile this with GCC and create a new clear.exe binary for Windows and CYGWIN.

Now that we see we can use the new executable to clear out cygwin shell, let’s copy it somewhere so we can just type “clear” to get what we want.

And there you have it, have fun!!!

Jason

MD5 check via ssh to be sure data has rsynced properly then delete 5 days of data from collector

EDIT: A colleague assisted with this.

STOWE VERMONT

I was sitting here thinking about how much I miss Stowe Vermont and how bad the snow count for this season 15/16 was up north. Stowe Vermont is a very magical place in northern Vermont that has one of the most desired ski resorts in the northeast(STOWE).

I love Stowe and it has a deep spot in my heart, I have so many memories of the place. Anyway I kind of wanted to pay a tribute to the resort and post some awesome pictures I found on the web. Hope you like it……………

STOWE03
STOWE04
STOWE05
STOWE06
STOWE07
STOWE08
STOWE01
STOWE02

Coding in the dark

Night Light
So, I have this air freshener night light in my bedroom. It has a wonderful glow and I think it brings out the best in me.
It’s probably that I am in bed, laptop keys glowing, warm screen ambiance set, all my problems seem to be solved for the day. Or I am just super comfortable at home. Whatever it is:

When I am here, I seem to write software 50 times better than when I am in the office.
It’s my happy place

Night Light 2 Night Light 2

C Code Learn – Open file write user input to it

Every once in a while I will get this urge to want to learn some C, C++. I am versed in Python and know my way around bash / Shell scripting like the back of my hand. But as always I am continuing to learn and self teaching myself is how learn the “BEST IS IS”.

Anyway let’s get to it, I wanted a program that would prompt a user for a sentence and then take that sentence and write it to a file, the program would have to create the file if it did not exist. Let me show you the code and attempt to break it down.