Skip to content

Instantly share code, notes, and snippets.

View passandscore's full-sized avatar

Jason Schwarz passandscore

View GitHub Profile
@passandscore
passandscore / gist:d29ec8a4a9777ce1e8f95cca208c767a
Created April 22, 2021 22:51 — forked from rxaviers/gist:7360908
Complete list of github markdown emoji markup

People

:bowtie: :bowtie: 😄 :smile: 😆 :laughing:
😊 :blush: 😃 :smiley: ☺️ :relaxed:
😏 :smirk: 😍 :heart_eyes: 😘 :kissing_heart:
😚 :kissing_closed_eyes: 😳 :flushed: 😌 :relieved:
😆 :satisfied: 😁 :grin: 😉 :wink:
😜 :stuck_out_tongue_winking_eye: 😝 :stuck_out_tongue_closed_eyes: 😀 :grinning:
😗 :kissing: 😙 :kissing_smiling_eyes: 😛 :stuck_out_tongue:
@passandscore
passandscore / fetch.js
Created April 25, 2021 00:36
Fetch API method( )
//FETCH API - DOM template
//Language: JavaScript
function loadRepos() {
const username = document.getElementById('username').value; //user input value
const repos = document.getElementById('repos'); //DOM element to display data
repos.innerHTML = '';
//construct the URL
const url = `https://api.github.com/users/${username}/repos`
@passandscore
passandscore / ajaxDomTemplate.js
Last active April 25, 2021 00:38
AJAX template for creating a basic API based HTTP request.
//AJAX - DOM template
//Language: JavaScript
document.getElementById('btn').addEventListener('click', loadData)
function loadData() {
//create an new request object
const req = new XMLHttpRequest()
@passandscore
passandscore / unit-testing.js
Created April 25, 2021 01:26
Unit Testing Template (Mocha & Chai)
//Unit testing template
//Language: JavaScript
//Packages: Mocha, Chai
//Javascript file
module.exports = subSum;
//JavaScript test file
@passandscore
passandscore / arrayToLinkedList.js
Created April 26, 2021 19:38
Convert an Array to a Linked List
function linkedList(arr) {
return arr.reduceRight((next, value) => ({ value, next }), null);
}
let l = [3, 1, 2, 3, 4, 5];
console.log(linkedList(l));
@passandscore
passandscore / linkedLists.js
Last active April 27, 2021 17:37
DataStructure - Linked List Principles
//Algorithms - Linked List Principles
//Language: JavaScript
class Node {
constructor(data, next = null) {
this.data = data;
this.next = next;
}
}
@passandscore
passandscore / httpClient.js
Created May 5, 2021 16:28
httpClient - DB fetch library
class httpClient {
// Get Request
get(url) {
return new Promise((resolve, reject) => {
fetch(url)
.then((res) => {
if (res.ok) {
return res.json();
}
}).then(data => resolve(data))
@passandscore
passandscore / kinvey.js
Last active May 5, 2021 16:33
Kinvey DB request library
//How to use it in a JS file
document.addEventListener('DOMContentLoaded', main)
const kinvey = new Kinvey('kid_BkYBymjvd', 'ed0eed3599fa4d5d9d062fae8755f43c');
const data = {
username: 'guest',
password: 'guest'
}
function get(url) {
// Return a new promise.
return new Promise(function(resolve, reject) {
// Do the usual XHR stuff
var req = new XMLHttpRequest();
req.open('GET', url);
req.onload = function() {
// This is called even on 404 etc
// so check the status
@passandscore
passandscore / htmlForm.js
Created May 6, 2021 19:07
Basic HTML Form
<form>
<h3>FORM</h3>
<label>TITLE</label>
<input type="title" id="title" placeholder="Title...">
<label>AUTHOR</label>
<input type="title" id="author" placeholder="Author...">
<label>ISBN</label>
<input type="title" id="isbn" placeholder="Isnb...">
<button>Submit</button>
</form>