Skip to content

Instantly share code, notes, and snippets.

View robertsheacole's full-sized avatar

Shea Cole robertsheacole

  • Randall Reilly
  • Tuscaloosa, AL
View GitHub Profile
@robertsheacole
robertsheacole / index.html
Last active August 16, 2019 13:26
Russian Flag
<div class="flag">
<div class="stripe white"></div>
<div class="stripe blue"></div>
<div class="stripe red"></div>
</div>
@robertsheacole
robertsheacole / Reactive.js
Created August 7, 2018 20:50
A very simple function that syncs up two objects without a bulky framework.
function reactive(origin, destination) {
return new Proxy(origin, {
set(target, key, value) {
Reflect.set(target, key, value);
destination[key] = value
}
});
}
### Keybase proof
I hereby claim:
* I am robertsheacole on github.
* I am sheacole (https://keybase.io/sheacole) on keybase.
* I have a public key ASC_l8vt-kwZVVnoiZmW9EESAf-xKp-xlcJxZOtLi9WVHQo
To claim this, I am signing this object:
@robertsheacole
robertsheacole / location-information.js
Last active July 16, 2018 18:33
Get location information with Javascript
(function () {
fetch('https://ipapi.co/json')
.then(promise => promise.json())
.then(response => {
// Here is an example of using the client's location to run certain logic.
(response.country === "United States") ? console.log(response) : console.warn("not in US!"))
//Remove the line above this and add your code here...!
}
.catch(err => console.warn(err))
})()
@robertsheacole
robertsheacole / bind.js
Last active December 9, 2017 18:08
2 Way Binding with Vanilla JavaScript
function bind(items, event) {
items.forEach(item => {
item.addEventListener(event, e => {
items.forEach(otherItem => {
otherItem.value = e.target.value;
otherItem.innerHTML = e.target.value;
});
});
});
}
// Bonfire: Where do I belong
// Author: @robertsheacole
// Challenge: http://www.freecodecamp.com/challenges/bonfire-where-do-i-belong#
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function where(arr, num) {
//Push num into the arr array.
arr.push(num);
//Reorder arr from lowest to highest number.
arr.sort(function(a, b){
// Bonfire: Seek and Destroy
// Author: @robertsheacole
// Challenge: http://www.freecodecamp.com/challenges/bonfire-seek-and-destroy#
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function destroyer(arr) {
var args = arr.slice.call(arguments);
args.splice(0, 1);
var newArray = [];
for(var i = 0; i < arr.length; i++){
// Bonfire: Falsy Bouncer
// Author: @robertsheacole
// Challenge: http://www.freecodecamp.com/challenges/bonfire-falsy-bouncer#
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function bouncer(arr) {
function deleteFalsey(arr){
return Boolean(arr);
}
// Bonfire: Mutations
// Author: @robertsheacole
// Challenge: http://www.freecodecamp.com/challenges/bonfire-mutations#
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function mutation(arr) {
var first = arr[0].toLowerCase().split('');
var query = arr[1].toLowerCase().split('');
for (var i = 0; i < query.length; i++){
// Bonfire: Slasher Flick
// Author: @robertsheacole
// Challenge: http://www.freecodecamp.com/challenges/bonfire-slasher-flick#
// Learn to Code at Free Code Camp (www.freecodecamp.com)
function slasher(arr, howMany) {
return arr.splice(howMany);
}
slasher([1, 2, 3], 2);