Skip to content

Instantly share code, notes, and snippets.

View edavis25's full-sized avatar

Eric Davis edavis25

View GitHub Profile
@edavis25
edavis25 / mouse_sensitivity.sh
Created June 27, 2018 19:27
Shell script for setting mouse sensitivity
#!/bin/bash
flag=true
while [ "$flag" == true ]; do
xinput --list
echo "##################################################"
echo "Select the ID of your input device:"
read input_device
@edavis25
edavis25 / laravel_pagination.scss
Created February 2, 2018 08:09
Bootstrap-inspired styles for use with Laravel's generated pagination links
// Bootstrap-inspired styles for the pagination links that
// Laravel dynamically generates in views.
// @author: Eric Davis
.pagination {
li {
display: inline-block;
float: left;
font-size: 1.1rem;
color: #2196f3;
@edavis25
edavis25 / create_site.sh
Created December 28, 2017 23:27
Shell script to enable a site in Apache.
#!/bin/bash
# This shell script automates the process of creating virtual host config files and enabling sites in Apache
# for a localhost. The script requires super user permissions as it creates a config file in the Apache
# directory and edits the /etc/hosts file.
#
# Function: The script will first prompt user to enter a name that will be used for the site and then prompt
# for a filepath pointing to the location of the website files (aka DocumentRoot in Apache config). It will
# then use these variables to create a config file, enable the site using a2ensite, and then restart Apache.
# The script will also append a line to hosts file (ex: 127.0.0.1 site-name.local) to allow access through localhost.
@edavis25
edavis25 / server.js
Last active November 30, 2017 00:32
Simple Express server to serve static files
/*
| Super simple Express server for serving files
| Note: Don't forget to npm install express!
*/
const express = require('express');
const app = express();
const path = require('path');
/*
| Send index file on root visit.
@edavis25
edavis25 / util.php
Last active May 17, 2017 21:39
A small collection of helpful PHP functions
<?php
/**
* PHP utility functions, parameter processing functions, and the renderTemplate functions
* Taken from Franklin's WEBD-236 course
* Authors: Todd Whittaker & Scott Sharkey
*/
function markdown($str) {
$str = htmlspecialchars(ltrim($str),ENT_QUOTES);
$str = preg_replace('/\*\*(.+)\*\*/u', '<b>$1</b>', $str);
@edavis25
edavis25 / ajax-util.js
Last active March 30, 2017 05:21
A couple functions for creating AJAX requests.
/**
* The postAjaxRequest and getAjaxRequst take arguments for a callback function, url, and param string.
* Both requests return the response text using "this" inside of the callback function.
*/
// POST request
function postAjaxRequest(callback, url, args) {
var contentType = 'application/x-www-form-urlencoded';
var ajax = new createAjaxObject(callback);
if (!ajax) {
@edavis25
edavis25 / table-to-csv.js
Last active March 8, 2017 03:25
Get HTML table data as a CSV formatted string
function tableAsCsv(id) {
// Make sure table exists and contains at least 1 row
if (document.getElementById(id) == null || document.getElementById(id).rows[0] == null) {
return;
}
// Get reference to table & number of rows
var tbl = document.getElementById(id);
var numRows = tbl.rows.length;
@edavis25
edavis25 / util.js
Created December 29, 2016 16:54
JavaScript utility functions.
"use strict";
/**
* @author Hei Wah Chan
*
*
* Gist Uploader's Note: This file was created and provided by one of my professors at Franklin University.
* These functions provide simple ways to interact with HTML elements (mainly forms) via plain JavaScript.
*/
@edavis25
edavis25 / scrollable-overlay.html
Last active October 29, 2023 13:48
Scrollable full-screen HTML overlay
<!DOCTYPE html>
<!-- SCROLLABLE OVERLAY -->
<html>
<head>
<style>
.overlay {
height: 0%;
width: 100%;
position: fixed;
z-index: 1;
@edavis25
edavis25 / json-to-array.php
Last active November 4, 2016 00:47
Parse JSON string as PHP array.
<?php
/*
* Create a simple javascript array and call the JSON "stringify" method upon it.
* Pass the stringified array variable via the URL & GET method and use this line to turn it into a standard PHP array.
*/
$array = json_decode(str_replace('\\', '', $_REQUEST['URL-PARAM-NAME']));
// URL-PARAM-NAME = whatever name the JSON string was given when passed via URL (keep single quotes)
?>