Skip to content

Instantly share code, notes, and snippets.

View zeckdude's full-sized avatar

Chris Seckler zeckdude

View GitHub Profile
@zeckdude
zeckdude / scrape.js
Created January 15, 2024 00:58
Puppeteer Demo update for new page structure
// This is an update to the script on the Puppeteer at https://pptr.dev/#example which is relying on an old page structure
import puppeteer from 'puppeteer';
export const runScrape = async (res) => {
// Launch the browser and open a new blank page
const browser = await puppeteer.launch({headless: true});
const page = await browser.newPage();
// Navigate the page to a URL
@zeckdude
zeckdude / ResponsiveElements.tsx
Last active July 5, 2022 23:10
ResponsiveElements component to generate div to show/hide children content with varying prop values at varying breakpoints
import { FC, cloneElement, ReactElement } from 'react';
import { css } from '@emotion/react';
import { useTheme, Breakpoint, Box } from '@mui/material';
const getNextBreakpointSize = ({
currentBreakpoint,
supportedBreakpoints,
responsivePropsBreakpoints,
}: {
@zeckdude
zeckdude / Hidden.tsx
Created July 5, 2022 22:54
Hidden component to hide contents at specified MUI breakpoints
import { FC } from 'react';
import { css } from '@emotion/react';
import { useTheme, Breakpoint, Box } from '@mui/material';
interface HiddenProps extends BoxProps {
xsDown?: boolean;
xsUp?: boolean;
smDown?: boolean;
smUp?: boolean;
@zeckdude
zeckdude / es7-async-await.js
Created October 13, 2018 07:01 — forked from msmfsd/es7-async-await.js
Javascript fetch JSON with ES7 Async Await
// Async/Await requirements: Latest Chrome/FF browser or Babel: https://babeljs.io/docs/plugins/transform-async-to-generator/
// Fetch requirements: Latest Chrome/FF browser or Github fetch polyfill: https://github.com/github/fetch
// async function
async function fetchAsync () {
// await response of fetch call
let response = await fetch('https://api.github.com');
// only proceed once promise is resolved
let data = await response.json();
// only proceed once second promise is resolved
/9j/4AAQSkZJRgABAQEASABIAAD/7QA4UGhvdG9zaG9wIDMuMAA4QklNBAQAAAAAAAA4QklNBCUAAAAAABDUHYzZjwCyBOmACZjs+EJ+/+EAQEV4aWYAAE1NACoAAAAIAAGHaQAEAAAAAQAAABoAAAAAAAKgAgAEAAAAAQAAAwygAwAEAAAAAQAAAkQAAAAA/9sAQwAEAwMEAwMEBAQEBQUEBQcLBwcGBgcOCgoICxAOEREQDhAPEhQaFhITGBMPEBYfFxgbGx0dHREWICIfHCIaHB0c/9sAQwEFBQUHBgcNBwcNHBIQEhwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwcHBwc/8AAEQgCRAMMAwEiAAIRAQMRAf/EAB0AAQACAgMBAQAAAAAAAAAAAAAGBwUIAQMEAgn/xABZEAABAwICBQYIBw0GBAYBBQEBAAIDBAUGEQcSITFBE1FhcYGRFBUiMlKhscEIQmJykpPRFhgjMzQ1Q1NVc4LS4RdUorLC0yRjg/AlRGSUo+KzJjZGdKTx/8QAHAEBAAEFAQEAAAAAAAAAAAAAAAYBAgMEBQcI/8QAPxEAAgEDAQUECQIFBAIBBQAAAAECAwQRBQYSITFRE0FhcRQiMoGRobHB0QdSFSNC4fAWM1PxNGJyJENEkqL/2gAMAwEAAhEDEQA/ANnERFJSKBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREAREQBERAEREARE
@zeckdude
zeckdude / conditionalwrap.js
Created August 7, 2018 20:30 — forked from kitze/conditionalwrap.js
one-line React component for conditionally wrapping children
import React from 'react';
const ConditionalWrap = ({condition, wrap, children}) => condition ? wrap(children) : children;
const Header = ({shouldLinkToHome}) => (
<div>
<ConditionalWrap
condition={shouldLinkToHome}
wrap={children => <a href="/">{children}</a>}
>
@zeckdude
zeckdude / help_with_backbone_views_events.js
Created December 3, 2015 22:57
Help with Backbone Views Events
// Handling events in a View
var SongView = Backbone.View.extend({
events: {
"click button": "onClick", // Run the "onClick" function when the any button is clicked
"click button.bookmark": "onClickBookmark", // Run the "onClickBookmark" function when the a button with the class "bookmark" is clicked
"click input[type=button]": "doSomething" // Shows that you can include the same types of selectors as in jQuery
},
onClick: function() {
console.log("Listen clicked");
@zeckdude
zeckdude / backbone_from_scratch_chapter_collections.js
Created December 3, 2015 06:38
Backbone from Scratch Chapter Project: Collections
// BACKBONE COLLECTIONS PROJECT
console.log("Begin - BACKBONE COLLECTIONS PROJECT");
// Create a Backbone collection for the Vehicle model you created in the last project.
var Cars = Backbone.Collection.extend({
model: Vehicle
});
// Add the following cars inside the collection:
// * car1: { registrationNumber = “XLI887”, colour = “Blue” }
@zeckdude
zeckdude / backbone_from_scratch_chapter_models.js
Last active December 3, 2015 06:36
Backbone from Scratch Chapter Project: Models
// BACKBONE MODELS PROJECT
console.log("Begin - BACKBONE MODELS PROJECT");
// Create a Backbone model for a Vehicle.
// A Vehicle is uniquely identified via one of its attributes called “registrationNumber”, which cannot be null or undefined.
// Vehicles can be retrieved from the server at “/api/vehicles”.
// A Vehicle should have a method called start(), which logs a message in the console: “Vehicle started.”
var Vehicle = Backbone.Model.extend({
idAttribute: "registrationNumber",
urlRoot: "/api/vehicles",
@zeckdude
zeckdude / Results
Last active August 29, 2015 14:15
Laravel String Helper Functions From: http://vegibit.com/custom-helper-functions-in-laravel
This says that when we visit http://you.rock/stringhelpers, we’ll initialize a basic string which will contain the text We like to program in PHP and we like to use the Laravel Framework! Then we’ll call our helper functions via static methods and var_dump the result to the screen.
string 'We like to program in PHP and we like to use the Laravel Framework!' (length=67)
string 'like to program in PHP and we like to use the Laravel Framework!' (length=64)
string 'We like to ' (length=11)
string 'like to program' (length=15)