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 / CMailGunLogRoute.php
Created January 7, 2014 20:12
Extending Yii CEmailLogRoute class using Mailgun
<?php
// components/CMailGunLogRoute.php
class CMailGunLogRoute extends CEmailLogRoute {
protected function sendEmail($email, $subject, $message) {
$mail = Yii::app()->mailgun->newMessage();
$mail->setFrom($this->getSentFrom());
$mail->addTo($email);
$mail->setSubject($subject);
$mail->setText($message);
@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",