Skip to content

Instantly share code, notes, and snippets.

View jpalala's full-sized avatar
🔭
Lets build something useful

Joe Palala jpalala

🔭
Lets build something useful
View GitHub Profile
@jpalala
jpalala / enough.scss
Created December 24, 2024 09:39
Sassy Enough.CSS
body {
font: 22px/1.6 system-ui,sans-serif;
margin: auto;
max-width: 35em;
padding: 0 1em;
}
img, video {
max-width: 100%;
height: auto;
@jpalala
jpalala / add_tags.md
Created November 17, 2024 09:52
add tags to post

Yes, you can add tags to blog posts by creating a many-to-many relationship between posts and tags. This requires three tables:

  1. posts: Table to store blog posts.
  2. tags: Table to store tags.
  3. post_tag: Pivot table to associate posts with tags.

Migration Code

@jpalala
jpalala / how-to-track-unique-clicks-using-jquery.md
Created October 1, 2024 01:27
how to track unique clicks using jquery

Note: From ChatGPT. Thank you ChatGPT!

To implement click tracking with jQuery and store it in a backend API, we can outline the following steps:

1. Database Schema

You can use a database table to store unique clicks, capturing the necessary details like the browser, IP address, and clicked_at timestamp.

SQL for the table:

@jpalala
jpalala / meetups.json
Created September 11, 2024 06:38
JSON example meetups api from friendsofphp.org
{
"generated_at": "2024-09-11 00:27:52",
"meetups": [
{
"name": "Why you should consider Drupal for your next project",
"user_group_name": "#pugMi: PHP User Group Milano",
"local_date": "2024-09-11",
"local_time": "17:00",
"utc_start_date_time": "1726074000",
"city": "Milano",
@jpalala
jpalala / README.md
Created August 26, 2024 01:47
Docker run jekyll

Setting up a Jekyll environment with Docker can streamline your development process, especially if you're looking to maintain consistency across different environments. Below, I'll guide you through creating a working Jekyll Docker environment using the official Jekyll Docker image.

Step-by-Step Guide

1. Create a Dockerfile

First, create a Dockerfile to define your Jekyll environment. Create a file named Dockerfile in your project directory with the following content:

# Use the official Jekyll image
@jpalala
jpalala / ducks.md
Created August 26, 2024 01:37
du -cks
du -cks * | sort -rn | head -11
alias ducks='while read -r line;do du -sh "$line";done < <(ls -1A) | sort -rh | head -n11'
@jpalala
jpalala / artisan_stuff.sh
Created August 14, 2024 06:21
artisan shortened command
# Add this function to your ~/.zshrc file
art() {
# Define a function with a case statement
case $1 in
"cc")
php artisan config:clear && php artisan config:cache
# Add your code for option 1 here
;;
"oc")
php artisan optimize:clear
@jpalala
jpalala / laravel-api-resources.md
Created August 12, 2024 23:51 — forked from deepak-cotocus/laravel-api-resources.md
How to Create Laravel Eloquent API Resources to convert model collections into JSON(Part 1).

Introduction:

What is API Resources in Laravel

LARAVEL's resource classes allow you to expressively and easily transform your models and model collections into JSON.Basically you can generate a nice json formatted data right from Eloquent. Laravel's resource classes allow you to expressively and easily transform your models and model collections into JSON. Let’s learn how to generate api resources.Consider you have a user table in your database and you want to generate api resources for your User model.Run following command on your terminal window while being on laravel project root directory:

STEP 1: Generating Resources

  • Run this Command to generate a resource class.
  • By default, resources will be placed in the app/Http/Resources directory of your application. Resources extend the Illuminate\Http\Resources\Json\JsonResource class:
@jpalala
jpalala / get_monotonic_time.php
Created June 29, 2024 00:18
clock monotonic time
<?php # idea from https://www.netmeister.org/blog/epoch.html
// so Mac apparently set their origin of time using to 2001-01-01 00:00:00 (clock monotonic) which is unix epoch (1971-01-01) aka -30 years ago.
# ((31556926) * 30) = (number of seconds per year according to epochconverter) * 30 years = 946707780
# per article, it is -978307200 (2001-01-01 00:00:00) so I wonder what explains the diff??
functions get_monotonic($timestamp) {
return time() - strtotime('2001-01-01 00:00:00'));
}
return get_monotonic();
@jpalala
jpalala / cron-every-minute.sh
Created June 23, 2024 23:30
starting a artisan cron scheduler
```sh
# Your cron
* * * * * root /usr/bin/php /var/app/current/artisan schedule:run >> /dev/null 2>&1 | logger
```