Skip to content

Instantly share code, notes, and snippets.

View gchristofferson's full-sized avatar
👍
Working on something great

Gregg Christofferson gchristofferson

👍
Working on something great
  • Windsor California
View GitHub Profile
@gchristofferson
gchristofferson / gist:cec60bb566d9e5d6a7bcffd1946f0d19
Created February 11, 2019 20:23
Generate ssl cert for vagrant homestead sites. After the first 'vagrant up' command, ssh into the VM and run command. Then upload the cert into your browser. More info at: https://www.geekypeak.com/valid-ssl-certificate-vagrant-homestead-improved
cp /etc/nginx/ssl/homestead_root_ca.crt /home/vagrant/Code

1. Clone your fork:

git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git

2. Add remote from original repository in your forked repository:

cd into/cloned/fork-repo
git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
git fetch upstream
@gchristofferson
gchristofferson / user-search-input-action.js
Last active February 6, 2019 18:37
Get users search input and add it to form action
// Get users search input and add it to form action
$('#js-search-input').keypress(function (e) {
let key = e.which;
// if the key is the enter key code
if(key === 13) {
const userInput = $('#js-search-input').val();
console.log("user input: " + userInput);
let actionStr = "/inquiries/search/" + userInput;
console.log("actionStr = " + actionStr);
actionStr = actionStr.replace('?', '');
@gchristofferson
gchristofferson / file_count.sh
Last active January 2, 2019 21:14
This bash script takes two command line arguments which is the name of the directory and number of files to keep. It will count the number of files and delete any extra. Ideal for tracking and deleting extra backup files made automatically in a directory
#!/bin/sh
# this script takes two command line arguments which is the name of the directory to count files in and number of files to keep in directory
# must use full path to directory (i.e. /home/path_to_directory) as first argument
# the script counts the number of files in the directory and if more than number to keep, extra files will be deleted
# it will delete the oldest database files over the number to keep
# ideal for deleting old copies of backup files.
dir="$1"
num_to_keep="$2"
cd $dir
shopt -s nullglob
@gchristofferson
gchristofferson / push_once.sh
Created December 21, 2018 00:57
This script will push one time any changes to remote repository
#!/bin/sh
# this script takes one command line argument which is the name of the directory to push changes from to git
push() {
dir="$1"
cd $dir
echo "pushing any changes to git once"
git status
git add .
git commit -m "committing changes made on live server"
git push origin master
@gchristofferson
gchristofferson / db_backup.sh
Created December 21, 2018 00:41
This script will make a backup of the database in the backup directory
#!/bin/sh
# This script will make a backup of the databases
username="<username>"
password="<password>"
host="<hostname>"
dbname="<database name>"
current_date=`date +"%Y-%m-%d-%T"`
file_name="$dbname""_""$current_date"
@gchristofferson
gchristofferson / onchange.sh
Last active December 21, 2018 00:47
This script takes one command line argument [directory]. It watches the directory for any changes and executes git commands on change.
#!/bin/sh
# the script takes one command line argument which is the name of the directory to watch for changes
check() {
dir="$1"
chsum1=`find $dir -type f -mtime -5 -exec md5sum {} \;`
chsum2=$chsum1
changed=false
pushed=false
declare -i waited
waited=0
@gchristofferson
gchristofferson / Makefile
Created October 22, 2018 22:32
Implements a dictionary's functionality
# compiler to use
CC = clang
# flags to pass compiler
CFLAGS = -fsanitize=signed-integer-overflow -fsanitize=undefined -ggdb3 -O0 -Qunused-arguments -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wshadow
@gchristofferson
gchristofferson / recover.c
Created October 22, 2018 22:24
This C program written for course work recovers deleted images from an image card file.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
@gchristofferson
gchristofferson / resize.c
Created October 22, 2018 22:12
C program for course work that resizes a BMP file
// Resizes a BMP file
#include <stdio.h>
#include <stdlib.h>
#include <string.h>