Skip to content

Instantly share code, notes, and snippets.

View Kernix13's full-sized avatar
💭
Still looking for a job - but losing hope

Jim Kernicky Kernix13

💭
Still looking for a job - but losing hope
View GitHub Profile
@Kernix13
Kernix13 / hamburgerMenu.css
Last active May 7, 2025 07:52
Mobile first responsive hamburger menu
*, *::before, *::after {
box-sizing: border-box;
}
body {
padding: 0;
margin: 0;
}
header {
@Kernix13
Kernix13 / faq.css
Last active March 11, 2025 12:11
Animated FAQ accordion
details {
border: 1px solid #ccc;
border-radius: 5px;
margin-bottom: 10px;
padding: 10px;
transition: border 300ms ease-in-out, padding 300ms ease-in-out;
}
details:focus {
outline: 1px solid #CDCDE4;
@Kernix13
Kernix13 / index.html
Last active April 6, 2024 16:18
Back To Top Button
<!-- Simpler version on my portfolio site:
https://jameskernicky.netlify.app/
https://github.com/Kernix13/personal-portfolio
-->
<button id="back-to-top-btn"><i class="fa-solid fa-angle-up"></i></button>
<!-- Bootstrap icon instead of font awesome -->
<svg
xmlns="http://www.w3.org/2000/svg"
@Kernix13
Kernix13 / NetlifyFunctions.md
Created March 31, 2024 15:35
Netlify function example

Structure of a Netlify Function

  1. Create a /netlify folder and inside create /functions folder, and inside create a .js file for your function
  2. OPTIONAL: require MongoClient if you are using MongoDB
  3. Create an async function named handler
  4. OPTIONAL: Connect to the database, get your data, then close DB connection
  5. Return an object with statusCode, headers (optional), and body properties
@Kernix13
Kernix13 / app.js
Created March 31, 2024 15:07
Full-stack EJS, Node & Express app.js example
if (process.env.NODE_ENV !== 'production') {
require('dotenv').config();
}
const express = require('express');
const path = require('path');
const mongoose = require('mongoose');
const ejsMate = require('ejs-mate');
const methodOverride = require('method-override');
@Kernix13
Kernix13 / retreat.js
Created March 31, 2024 15:01
Mongoose model and schema
// npm i express mongoose
// create a /models folder, inside create retreat.js,
// model name = 'Retreat', the schema = RetreatSchema
const mongoose = require('mongoose');
const { Schema } = mongoose;
const RetreatSchema = new mongoose.Schema({
title: String,
image: String,
price: Number,
@Kernix13
Kernix13 / app.js
Created March 31, 2024 14:54
EJS views and first basic route (Node and Express.js)
// add to app.js
const path = require('path');
/* Set EJS as the view engine */
app.set('view engine', 'ejs');
app.set('views', path.join(__dirname, 'views'));
// change res.send to res.render
app.get('/', (req, res) => {
res.render('home');
@Kernix13
Kernix13 / app.js
Created March 31, 2024 14:53
Basic Node and Express.js Server
// npm i express mongoose ejs
// in app.js
const express = require('express');
const app = express();
app.get('/', (req, res) => {
res.send('Home Route');
});
app.listen(3000, () => {
@Kernix13
Kernix13 / loginAttempt.js
Created March 30, 2024 18:14
Set server cookie
// npm install cookie
const cookie = require('cookie');
const handler = async (event) => {
const body = JSON.parse(event.body);
// pick a generic username and password for now
if (body.username == "some_name" && body.password == "some_password") {
@Kernix13
Kernix13 / isAdmin.js
Last active March 30, 2024 18:12
Check for server cookie
// Setting cookie for logged in admin
// run npm install cookie then:
// petadoption is the name of the cookie for this example
const cookie = require('cookie');
function isAdmin(event) {
const incomingCookie = cookie.parse(event.headers.cookie || '');
if (incomingCookie?.petadoption == 'apsodifugyhtjrkelwqzmxncbv0918273645') {
return true;