Skip to content

Instantly share code, notes, and snippets.

View p1nesap's full-sized avatar

Paul Mollomo p1nesap

View GitHub Profile
@p1nesap
p1nesap / Bash Shell Regex Most Common Words from Web Page, Sorted to File
Last active January 6, 2016 01:06
Bash Shell Regex Most Common Words from Web Page, Sorted to File
#Process most common words from web page, and output to file, using wget, sed, awk, sort command line utilities.
Using both sed #and awk methods provides greatest accuracy. Example is for YouTube video comments.
#sed stream editor method:
wget -O - https://gdata.youtube.com/feeds/api/videos/ffVbnPjl86A/comments?orderby=published \
| sed -e 's/<[^>]*>//g' | tr -cs A-Za-z\' '\n' \ #clean up HTML tags; convert all to lowercase
| tr A-Z a-z | sort | uniq -c | sort -k1,1nr -k2 | sed ${1:-200}q > conan.txt
@p1nesap
p1nesap / bash-fun1.sh
Created December 14, 2014 00:35
Fun with operators, conditionals and exported functions.
#!/bin/bash
#Fun with operators, conditionals and exported functions. Notes below.
y=$(date +%Y)
d=$(date +%d)
m=$(date +%m)
u=`whoami`
s=`pwd`
if [ $d -lt 25 ] && [ $m == 12 ] && [[ "$s" == *"home/phoebe/shell"* ]]
then
@p1nesap
p1nesap / DHT11_LCD_I2C_Messages.ino
Last active September 28, 2018 18:32
DHT 11 temperature/humidity sensor, 16-character 2-line LCD screen with message relating to weather conditions, processed by Uno R3 microcontroller.
/* DHT 11 temperature/humidity sensor, 16-character 2-line LCD screen with message relating to weather conditions,
processed by Uno R3 microcontroller.
Watch related video on my YouTube channel, and post comment. Thanks!
http://youtube.com/user/p1nesap
Sensor out to pin 2. SCL to A5, SDA to A4.
1st i2c_scan, put address # in LiquidCrystal_I2C below.
*/
#include <Wire.h> // communicate with sensors
@p1nesap
p1nesap / analog-rf.ino
Created January 9, 2016 00:20
Arduino Analog RF Receiver Voltage Data LCD 315 433MHz
/*
Code by Tom Igoe with voltage/LCD sections by p1nesap. Watch on YouTube:
https://www.youtube.com/watch?v=MlS9Arac9jM
*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
@p1nesap
p1nesap / YouTubeAPI.gs
Last active February 21, 2016 20:14
Google YouTube API display real-time channel subscribers, view count
function createDoc() {
var doc = DocumentApp.getActiveDocument();
var body = doc.getBody();
//Put your unique API key in UNIQUE_KEY section below
var url = "https://www.googleapis.com/youtube/v3/channels?id=UNIQUE_KEY&part=statistics&fields=items(statistics(viewCount, subscriberCount))";
var response = UrlFetchApp.fetch(url);
var astext = response.getContentText();
//var nobrak = astext.replace(/[\])}[{(]/g, '');
//var strip = astext.replace(/[\(\)\[\]{},'"]/g,"").replace("items:", "").replace("statistics:", "").replace("viewCount", "Total Views").replace("subscriberCount", "Subscribers");
@p1nesap
p1nesap / triggerYouTubeAPI.gs
Last active February 21, 2016 20:13
Time trigger function for YouTube API
//calls createDoc function from YouTubeAPI.gs and updates every 6 hours.
function createTimeDrivenTriggers() {
ScriptApp.newTrigger('createDoc')
.timeBased()
.everyHours(6)
.create();
}
@p1nesap
p1nesap / MoodApp.py
Last active February 21, 2016 20:12
Python form with conditionals.
#!/usr/bin/env python
import cgi
import time
import datetime
import re
import cgitb; #cgitb.enable()
print "Content-type: text/html"
print
today = datetime.date.today()
@p1nesap
p1nesap / JSLocalStorage.html
Created February 21, 2016 20:10
Fun with JavaScript LocalStorage, Form and Images
<head>
<style>
body {
background-color: #fffafa;
color: #162252;
font-family: arial;
font-size: 16px;
margin: 15px 15px 25px 25px;
}
</style>
@p1nesap
p1nesap / transmit.ino
Created April 8, 2016 14:47
VirtualWire 433 mhZ RF Transmit Message to LCD
//Code by Mike McCauley ([email protected]) Copyright (C) 2008 Mike McCauley
//with LCD sections by P1nesap on YouTube: https://youtu.be/Q2iECOsfCqA
#include <VirtualWire.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
void setup()
{
Serial.begin(9600); // Debugging only
Serial.println("setup");
@p1nesap
p1nesap / receive.ino
Created April 8, 2016 14:50
VirtualWire 433 mhZ Receive LCD Message
// Copyright (C) 2008 Mike McCauley
//with additional sections for LCD by P1nesap on Youtube: https://youtu.be/Q2iECOsfCqA
#include <VirtualWire.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address