Skip to content

Instantly share code, notes, and snippets.

for(let i = 1; i <= 100; i++){
crackle = i % 3 === 0 ? "Crackle" : "";
pop = i % 5 === 0 ? "Pop": "";
console.log(crackle+pop !== "" ? crackle+pop : i);
}
const checkIfPythagTriplet = (a, b, c) => (c * c) === (a * a) + (b * b)
const targetSum = 1000
/// slow loopy way
// I don't know exactly which big O notation this is, but its bad....
// when I check the time on this one (running it up to product of 10,000 on my local machine takes 114.67s )
let a = 1;
let b = 1;
let c = 2;
@merryt
merryt / nectarOrNo.js
Last active September 23, 2022 19:19
In the game wingspan will the next roll contain a nector or not?
diceOptions = ["nectar/wheat", "bug", "nectar/bug", "nectar/cherry", "rat", "fish"]
numberOfRolls = 50000
target = "nectar"
const rollSinge = () => {
const diceSide = Math.floor(Math.random() * 6)
return diceOptions[diceSide]
}
// generate blank array with n elements
@merryt
merryt / GameList.js
Created October 20, 2021 20:00
Trying to build some front end stuff with limited frameworks
var socket = io();
class GameList extends HTMLElement {
connectedCallback() {
this.setInnerHTML("No Active Games", []);
socket.on("list of games", (gamesStr) => {
const gamesObj = JSON.parse(gamesStr);
const games = gamesObj["games"];
this.setInnerHTML("Ongoing Games", games);
});
@merryt
merryt / Vue-TowersOfHanoi.html
Last active April 2, 2019 15:26
Towers of Hanoi in VueJs
<!doctype html>
<html lang="en">
<head>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<meta charset="UTF-8"/>
<title>Vue demo</title>
<style>
.towers{
display:flex;
justify-content: space-between;
import random
from itertools import permutations, combinations
class Card:
"""
A single card in a 52 card deck
When creating a card the format is value 1(ace) to 13 king followed by 0-4 for a suite
"""
from requests import get
from requests.exceptions import RequestException
from contextlib import closing
from bs4 import BeautifulSoup
def simple_get(url):
"""
Attempts to get the content at `url` by making an HTTP GET request.
If the content-type of response is some kind of HTML/XML, return the
text content, otherwise return None.
$.map($(".transactions-data-row"), function(i){
return {
date: $.trim($(i).find(".transactions-date")[0].innerText).replace("\n", " "),
location: $(i).find(".transactions-description")[0].innerText,
amount: $(i).find(".transactions-amount b")[0].innerText,
}
})
function GetQueueIdWhenRedirectedToTarget() {
var n = window;
return n.queueViewModel ? n.queueViewModel.getIsRedirectedToTarget ? n.queueViewModel.getIsRedirectedToTarget() ? n.queueViewModel.getQueueId() : void 0 : null : null
}
var __extends, QueueIt;
(function(n) {
var t;
(function(n) {
var t;
(function(n) {
@merryt
merryt / why.js
Last active January 5, 2018 20:01
didUnlikelyHappen = function(){
if (Math.floor(Math.random()*10) === 2){
return true;
}else{
return false;
}
}
makePrediction = function(){
if(Math.random() > 0.5 ){