Skip to content

Instantly share code, notes, and snippets.

View nevadajames's full-sized avatar
🏠
Working from home

nj nevadajames

🏠
Working from home
View GitHub Profile
@nevadajames
nevadajames / release.sh
Created November 12, 2018 12:02 — forked from bclinkinbeard/release.sh
Bash script to automate the Git Flow tag/release process
#!/bin/bash
# current Git branch
branch=$(git symbolic-ref HEAD | sed -e 's,.*/\(.*\),\1,')
# v1.0.0, v1.5.2, etc.
versionLabel=v$1
# establish branch and tag name variables
devBranch=develop
@nevadajames
nevadajames / read_pins.py
Last active March 4, 2019 09:26
A few handy python scripts for raspberry pi
from time import sleep
import RPi.GPIO as GPIO
from pygame import mixer
mixer.init()
alert = mixer.Sound('bell.wav')
GPIO.setmode(GPIO.BOARD)
button1 = 16
@nevadajames
nevadajames / video_data.py
Created March 21, 2019 14:19
Check video length python script
#!/usr/bin/env python
from ffprobe import FFProbe
import glob, os
os.chdir("/downloads")
for file in glob.glob("*.avi"):
metadata=FFProbe(file)
for stream in metadata.streams:
if stream.isVideo():
@nevadajames
nevadajames / USAGE
Last active March 27, 2019 11:01
Test generator for after_party tasks
Description:
Generates a basic rspec test template for rake after_party task
Example:
rails generate after_party_test 2019112233_your_task_name
This will create:
spec/lib/task/deploy/your_task_name_spec.rb
@nevadajames
nevadajames / csv_mapper.py
Last active May 24, 2019 12:54
Connect and run basic query on postgres database
import csv
class CsvMapper():
"""export database queries to csv"""
def __init__(self, data):
self.data = data
self.headers = data['headers']
self.records = data['records']
def write_csv(self, destination):
@nevadajames
nevadajames / pv_install.sh
Last active June 11, 2019 13:28
install pv if absent
#!/usr/bin/env bash
if [[ "$OSTYPE" == "darwin"* ]] ; then
if ! brew ls --versions pv &> /dev/null ; then
echo "Pipe Viewer is NOT installed!"
brew install pv
fi
else
distro=$(source /etc/os-release && echo "$NAME");
@nevadajames
nevadajames / power.c
Created July 27, 2019 06:32
C program to calculate exponent from command line
#include <stdio.h>
#include <stdlib.h>
int power(int base, int n){
int p;
for(p = 1; n > 0; n-- ){
p = p * base;
}