Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
200

Charlie Moss CharlesAMoss

💭
200
View GitHub Profile
View gist:34e594bf948ac027949e48c77cf19f79
rest.service.ts
import { Injectable } from '@angular/core';
import { HttpClient, HttpHeaders, HttpErrorResponse } from '@angular/common/http';
@Injectable({
providedIn: 'root'
})
export class RestService {
XKCD_URL = 'https://xkcd.com';
View gist:6085fa1110b672effbe63a75ab6243fc
document.addEventListener( 'wpcf7submit', function( event ) {
var inputs = event.detail.inputs;
var first = '';
var second = '';
for ( var i = 0; i < inputs.length; i++ ) {
if ( 'your-email' === inputs[i].name ) {
first = inputs[i].value;
View gist:adc4d75f90237c4189d56da24ecad4dc
let hex = '#' + Math.floor(Math.random() * 0x1000000)
.toString(16)
.padStart(6, '0');
View gist:44a9a516bb248b15419fc8283de2406d
body {
background: gainsboro;
height: 400vh;
margin: 0;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
font-family: monospace;
color: #404040;
View gist:24ded870a65481c89df10c73e8198843
const entry = document.getElementById("entry");
// every journey begins with one step
const svg = document.createElement("svg");
svg.setAttribute("width", "100%");
svg.setAttribute("height", "100%");
const g = document.createElement("g");
View gist:db3eb67e88f06034d2808839d4f8b987
this.size = 31 * (alpha.indexOf(arr.map( y => y.split('id="').pop().split('.').shift())
.sort((a,b) => a.length - b.length || a.localeCompare(b)).pop()) + 1)
View gist:2357d4ad53eef4033015e0aceaee3bf8
body {
background :#fffeb3;
/* display: flex;
justify-content: center;
align-items: center;*/
}
img {
width: 100%;
max-width: 500px;
View gist:7c75ec034215a6692f8074d858ef92c3
<form>
<div>
<input type="checkbox" value="this one">
<label for="this one">This</label>
</div>
<div>
<input type="checkbox" value="that one">
<label for="that one">That</label>
View fun with primes
const isPrime = N => {
return (N > 1) && Array.apply(0, Array(1 + ~~Math.sqrt(N))).
every((x, y) => (y < 2) || (N % y !== 0));
}
const primeTime = N => ([...Array(N).keys()].filter(isPrime));
primeTime(10);
// output [2,3,5,7]
View deckOfCards.js
'use strict';
let getDeck = () => {
let deck = [];
const numVal = _.range(2, 11).map(String);
const faceVal = ['J', 'Q', 'K', 'A'];
const value = numVal.concat(faceVal);
const suits = ['♠', '♥', '♣', '♦'];
for (var suit of suits) {
const cards = value.map(val => val + suit);
deck.push(cards);
You can’t perform that action at this time.