Skip to content

Instantly share code, notes, and snippets.

View Shivabeach's full-sized avatar

Brad Shivabeach

  • Oak Ridge Tn
View GitHub Profile
@Shivabeach
Shivabeach / gist:dee8e3e62a268f8473c43e8e68bf9d10
Created July 12, 2021 15:31
Named colors converted to sass variables
$aliceblue : #f0f8ff
$antiquewhite : #faebd7
$aqua : #00ffff
$aquamarine : #7fffd4
$azure : #f0ffff
$bisque : #ffe4c4
$black : #000000
$blanchedalmond: #ffebcd
$blue : #0000ff
$blueviolet : #8a2be2
@Shivabeach
Shivabeach / JSColors.js
Last active June 17, 2021 22:56
Create random colors with Javascript
let backg = document.getElementById('content3');//any place you want to display the color
const colors = document.querySelector('.colors'); //just a P to show the color HEX code
function createColor() {
const randl = Math.random().toString(16).substr(2, 6);
let color = `#${randl}`;
colors.innerHTML = color;
backg.style.backgroundColor = color;
}
createColor();
$perano: #a5b4ed
$morning-glory: #a7e0da
$gum-leaf: #B5D6C1
$kidnapper: #E0E7CD
$french-lilac: #F0DAF5
$moon-raker: #D7BCEF
$jordy-blue: #9AB3F7
$prim: #F6EEF3
$shadow-green: #A3CEC6
$thatch: #B7A096
@Shivabeach
Shivabeach / #OpenWeathermap wind direction
Last active July 27, 2021 15:29
Open #weathermap conversion from degrees to direction. #degrees #direction #javascript
$.getJSON("https://api.openweathermap.org/data/2.5/weather?id=4614214&units=imperial&APPID=openweathermap api code", function(data) {
var icon = "http://openweathermap.org/img/w/" + data.weather[0].icon + ".png";
var temp = Math.floor(data.main.temp);
var weather = data.weather[0].description;
var humid = data.main.humidity;
var windspeed = data.wind.speed + " mph";
var deg = Math.floor(data.wind.deg);
switch (true) {
case deg >= 360 && deg <= 21:
deg = "N";
@Shivabeach
Shivabeach / Get Element Text
Created September 4, 2013 16:37
Grab value or text from one element and put it in another
$(function () {
$('li.inliner').on('click', function () { //click on the li
var content = $(this).text();//content is the text that you clicked on
//PLACE THE TEXT INSIDE THE INPUT FIELD, YOU CAN CHANGE YOUR SELECTOR TO TARGET THE RIGHT INPUT
$('input[name="art"]').val(content);
});
});
@Shivabeach
Shivabeach / PDO Select
Created September 4, 2013 16:34
PDO select with foreach inline
<?php
foreach(->query('SELECT * FROM table') as $row) {
echo $row['field1'].' '.$row['field2']; //etc...
}
@Shivabeach
Shivabeach / admin.js
Last active November 30, 2019 20:40
ajax form one size fits all
#ajax can be any form ID or class name. I just use ajax
$('form#ajax').on('submit', function(){
var that = $(this),
url = that.attr('action'),
type = that.attr('method'),
data = {};
that.find('[name]').each(function(index, value){
var that = $(this),
name = that.attr('name'),
$months = [
'January',
'February',
'March',
'April',
'May',
'June',
'July',
'August',
'September',