Skip to content

Instantly share code, notes, and snippets.

View dustinmyers's full-sized avatar
🐧
Chillin

Dustin Myers dustinmyers

🐧
Chillin
View GitHub Profile
@dustinmyers
dustinmyers / todo.controller.ts
Created April 26, 2022 14:58
Todo App example in NestJS - a Node framework inspired heavily by Angular
import {
Body,
Controller,
Delete,
Get,
Param,
Post,
Put,
} from '@nestjs/common';
import { toPromise } from 'src/shared/utils';
@dustinmyers
dustinmyers / [pid].jsx
Last active April 26, 2022 05:36
Example of how to use serverless functions to fetch data from a CMS for a blog site
// Blog page that fetches data using serverless function
import { useEffect, useState } from "react";
import { useRouter } from "next/router";
import ReactMarkdown from "react-markdown";
import Loader from "../../components/Loader";
export default function BlogPost() {
const router = useRouter();
@dustinmyers
dustinmyers / ThemeContext.jsx
Last active April 26, 2022 15:12
Initial function and context object for dark mode in a NextJS SSR App - To avoid the SSR dark mode "flicker", set styles on the root before the site is rendered. CSS variables are key here.
import React from "react";
import {
COLORS,
COLOR_MODE_KEY,
INITIAL_COLOR_MODE_CSS_PROP,
BREAKPOINTS,
FONTS,
} from "../themes/cssVariables";
export const UserThemeContext = React.createContext()
@dustinmyers
dustinmyers / README.md
Last active May 24, 2018 16:05
Node II

Review

Work through node-express-mini

  • CRUD
    • Create
    • Read
    • Update
    • Delete
  • REST
    • GET
  • PUT
var teamAvengers = [
{
"id": 1009368,
"name": "Iron Man",
"description": "Wounded, captured and forced to build a weapon by his enemies, billionaire industrialist Tony Stark instead created an advanced suit of armor to save his life and escape captivity. Now with a new outlook on life, Tony uses his money and intelligence to make the world a safer, better place as Iron Man.",
"modified": "2013-11-07T10:55:38-0500",
"thumbnail": {
"path": "http://i.annihil.us/u/prod/marvel/i/mg/c/60/55b6a28ef24fa",
"extension": "jpg"
}
@import url(http://fonts.googleapis.com/css?family=Roboto+Slab:700|Exo+2:300,600);
/* Eric Meyer's Reset CSS v2.0 - http://cssreset.com */
html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{border:0;font-size:100%;font:inherit;vertical-align:baseline;margin:0;padding:0}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:none}table{border-collapse:collapse;border-spacing:0}
/* Solarized Palette - http://ethanschoonover.com/solarized ---------
lightgray : #819090;
gray : #70
// Create a function called MakePerson which takes in name, birthday, ssn as its parameters and returns a new object with all of the information that you passed in.
function MakePerson(name, bday, ssn) {
var person = {};
person.name = name;
person.bday = bday;
person.ssn = ssn;
return person;
};
/////// FIREBASE OBJECTS ///////////
var ref = new Firebase(URL);
var obj = $firebaseObj(ref);
console.log("obj: ", obj);
console.log("obj.numbers before $loaded: ", obj.numbers);
obj.$loaded().then(function() {
console.log("obj.numbers after $loaded: ", object.numbers);
$scope.numbers = obj.numbers;
app.controller('MainCtrl', function($scope, URL, $firebaseObj) {
// Normally we would handle data inside a service or factory... but for the
// example, we keep it short and simple, and hard code it into the controller.
$scope.data = [
{name: "Dustin", from:"Idaho", hobbies: ["Snowboarding", "Coding"]},
{name: "Brendan", from:"Utah", hobbies: ["Airsoft", "Writing"]},
{name: "Adriana", from:"Mexico", hobbies: ["Sleeping", "Bird Watching"]},
{name: "Andy", from:"Ogden", hobbies: ["Skiing", "Dirt Scootering"]}
];
<html>
<head>
<script src="http://code.jquery.com/jquery.js"></script>
<script>
$(function() {
$.get('http://localhost:3000')
});
</script>
</head>
</html>