Skip to content

Instantly share code, notes, and snippets.

@ashlynnpai
ashlynnpai / index.html
Created August 8, 2017 15:26 — forked from anonymous/index.html
Quotes
<body>
<button id="getQuote">Get a Quote
</button>
<h1 id="quote-content">
</h1>
<h2 id="quote-title">
</h2>
<button id="btnTweet">Tweet This</button>
</body>
//Mozilla documentation for geolocation
function getWeather() {
var output = document.getElementById("out");
var picture = document.getElementById("icon");
if (!navigator.geolocation){
output.innerHTML = "<p>Geolocation is not supported by your browser</p>";
return;
}
function success(position) {
@ashlynnpai
ashlynnpai / index.html
Created September 14, 2017 14:55
Wikipedia API viewer
<body>
<input id="startSearch" type="text">
<button onClick="getEntries()">Search Wikipedia</button>
<div>
<button onClick="getRandom()">Get Random Entry</button>
</div>
<div id="showResults">
</div>
</body>
@ashlynnpai
ashlynnpai / script.js
Created September 18, 2017 16:16
call to Twitch API
function getFeed() {
$.getJSON('https://wind-bow.glitch.me/twitch-api/streams/freecodecamp?callback=?', function(data) {
var isStreaming = document.getElementById("report");
if (data.stream == null) {
isStreaming.innerHTML = "Down"
}
else {
var a = document.createElement("a");
var streamStatus = document.createTextNode("Up");
a.appendChild(streamStatus);
//sum array of two numbers and all numbers in between
//positive numbers only
function sumAll(arr) {
var min = arr.reduce(function(a, b) {
return Math.min(a, b);
});
var max = arr.reduce(function(a, b) {
return Math.max(a, b);
});
if (min == max) {
@ashlynnpai
ashlynnpai / index.html
Created October 9, 2017 20:47
Calculator
<div id='main'>
<br/>
<h1 id='display'>
</h1>
<br>
<div id='buttons'>
<button class='num'>
1
</button>
<button class='num'>
@ashlynnpai
ashlynnpai / index.html
Last active October 11, 2017 14:30
Pomodoro Timer
<h1>Change Time</h1>
<input type='text' id='inputTime' name='time' />
<div><input type='submit' id='submit-button' value='Start'/>
<button id='reset'>
Reset
</button>
<button id='reset'>
Stop
</button></div>
<div id='tomato'>
@ashlynnpai
ashlynnpai / index.html
Created November 3, 2017 23:39
Leaderboard
<div id="app"></app>
#Code Wars kata solution
def damaged_or_sunk (board, attacks):
hits = []
results = { 'sunk': 0, 'damaged': 0 , 'not_touched': 0, 'points': 0}
for attack in attacks:
x = attack[0]-1
y = len(board)-attack[1]
if board[y][x] != 0:
hits.append(board[y][x])
board[y][x] = "X"
@ashlynnpai
ashlynnpai / counter.js
Last active December 8, 2017 16:32
counter in React
//reference: https://reactjs.org/docs/state-and-lifecycle.html
class Counter extends React.Component {
constructor(props) {
super(props);
this.state = {count: 0};
}
componentDidMount() {
this.timerID = setInterval(
() => this.tick(),