Skip to content

Instantly share code, notes, and snippets.

View JeffreyWay's full-sized avatar

Jeffrey Way JeffreyWay

View GitHub Profile
@JeffreyWay
JeffreyWay / homework-solution.php
Last active March 21, 2025 06:46
PHP For Beginners, Episode 6 - Arrays
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Demo</title>
</head>
<body>
<?php
$usernames = [
@JeffreyWay
JeffreyWay / reflection.php
Created March 19, 2013 15:31
Test PHP protected/private methods with ease using Reflection.
<?php
// ...
public function testProtected()
{
$dateFormatter = new DateFormatter;
$class = new \ReflectionClass('DateFormatter');
var gulp = require('gulp');
var browserify = require('browserify');
var babelify = require('babelify');
var source = require('vinyl-source-stream');
gulp.task('browserify', function() {
return browserify('./js/app.js')
.transform(babelify, { stage: 0 })
.bundle()
.on('error', function(e){
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Demo</title>
</head>
<body>
<?php
$books = [
<?php
// Connect to the MySQL database.
$dsn = "mysql:host=localhost;port=3306;dbname=myapp;user=root;charset=utf8mb4";
// Tip: This should be wrapped in a try-catch. We'll learn how, soon.
$pdo = new PDO($dsn);
$statement = $pdo->prepare("select * from posts where id = 1");
$statement->execute();
@JeffreyWay
JeffreyWay / example.html
Created March 3, 2021 17:06
Alpine Modals Using Events example
<x-layout>
<x-button class="bg-gray-400 hover:bg-gray-500" onclick="$modals.show('join-modal')">Join</x-button>
<x-modals.join />
<script>
window.$modals = {
show(name) {
window.dispatchEvent(
new CustomEvent('modal', { detail: name })
@JeffreyWay
JeffreyWay / recaptcha.blade.php
Last active January 31, 2025 11:54
Recaptcha Example using Laravel, Blade Components, and Alpine
<div
x-data="recaptcha()"
x-init="init"
@recaptcha.window="execute"
></div>
@push('scripts')
<script src="https://www.google.com/recaptcha/api.js?render=explicit"></script>
<script>
@JeffreyWay
JeffreyWay / Modal.vue
Last active January 28, 2025 09:45
Learn Vue 3: Step By Step, Episode 28 - Build a Modal Component - https://laracasts.com/series/learn-vue-3-step-by-step/episodes/28
<script setup>
defineProps({
show: Boolean
});
</script>
<template>
<div v-if="show" class="modal-mask">
<div class="modal-container">
<div>
@JeffreyWay
JeffreyWay / TeamFooter.vue
Last active January 6, 2025 13:45
Learn Vue 3: Step By Step, Ep 26 - Code Organization
<template>
<footer class="mt-12 bg-gray-100 py-4 text-center">
<h5 class="font-semibold text-lg">{{ team.name }} - {{ team.spots }} Member Team</h5>
</footer>
</template>
<script setup>
defineProps({
team: Object
});
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Demo</title>
</head>
<body>
<h1>
<?php