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 / 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;
}
@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 / 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 / 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 / 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 / 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 / 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 / groove.rb
Last active November 9, 2018 15:10
sonic pi simple song
live_loop :effects do
with_fx :reverb, mix: 0.7, room: 0.5 do
play 20, pan: -1
sleep 0.5
play 22, pan: 1
end
end
live_loop :prog do
sample :bd_haus, rate: 2
@nevadajames
nevadajames / axios-catch-error.js
Created August 18, 2018 18:07 — forked from fgilio/axios-catch-error.js
Catch request errors with Axios
axios.put(this.apiBaseEndpoint + '/' + id, input)
.then((response) => {
// Success
})
.catch((error) => {
// Error
if (error.response) {
// The request was made and the server responded with a status code
// that falls out of the range of 2xx
// console.log(error.response.data);
@nevadajames
nevadajames / csv_reader.py
Last active June 1, 2018 11:28
Script to get data from csv
import csv
import sys
f = open('filename.csv', "rt")
reader = csv.reader(f)
row_count = 0
for row in reader:
if #do something with row get columns with row[index]: