Skip to content

Instantly share code, notes, and snippets.

@gebeer
gebeer / README.md
Last active May 22, 2024 14:16
Simple Terminal Menu using ratatui for total Rust noob with the help of GPT-4o in Cursor editor

This is inspired by Chris Titus' video on setting up a terminal menu with Rust using the Cursor editor's AI features.

As a programmer who regularly uses the Cursor editor and its AI capabilities, I found the video somewhat challenging to watch. This is not meant as a critique of Chris Titus but rather a suggestion for a more efficient approach. Familiarizing oneself with Cursor's features and improving prompting skills can significantly enhance the experience.

My goal is not to criticize but to provide a more efficient strategy for achieving the same goal, hoping it will be beneficial to others.

I am primarily a PHP-focused web developer and have never worked with Rust before. I wanted to see if I could leverage the AI features in Cursor to set up the entire project quickly. Below are the steps I followed, along with the conversations I had until the basic menu was operational. I didn't need to read any documentation myself.

Steps I took:

@gebeer
gebeer / readme.md
Last active March 29, 2017 06:38
landingpages that live off root ProcessWire
@gebeer
gebeer / summarize-method-hook.php
Last active December 20, 2016 07:41
Text Limiter Hook for ProcessWire - adds a new method summarize() to $page - add this code to site/ready.php
<?
// usage: $page->summaroze($fieldName, $maxLength)
$wire->addHook('Page::summarize', function($event) {
$fieldName = $event->arguments(0);
if(!$fieldName) throw new WireException("No field provided");
// get max length or use 300 as default if none provided
$maxLength = (int) $event->arguments(1);
if(!$maxLength) $maxLength = 300;
// Alerts
@include alert-variant($background, $border, $text-color);
// Background Variant
@include bg-variant($parent, $color);
// Border Radius
@include border-top-radius($radius);
@include border-right-radius($radius);
@include border-bottom-radius($radius);
@gebeer
gebeer / InputfieldLeafletMapMarker.js
Created August 1, 2016 15:59
modified /site/modules/MarkupLeafletMap/InputfieldLeafletMapMarker.js for Processwire. Takes values from custom fields to do the geocoding
/**
* Display a Leaflet Map and pinpoint a location for InputfieldLeafletMapMarker
*
*/
var InputfieldLeafletMapMarker = {
options: {
zoom: 9,
draggable: true,
@gebeer
gebeer / date-is-in-month.php
Created January 26, 2016 13:45
check if a given date lies within a given month
// example code
// convert the saved date of the page to a timestamp
// $date = strtotime($page->date);
$date = strtotime("12-January-2016");
// convert the $searchdate to a timestamp
$searchdate = strtotime("January-2016") + 1000;
// get first and last timestamp of the given month and year
$getdate = getdate($searchdate);
// get the month number (e.g. 1 for January)
$month = $getdate["mon"];
@gebeer
gebeer / swap-languages.php
Last active November 14, 2015 07:31
PHP function for swapping languages when changing the default language in ProcessWire
<?php
function swapLanguages($pages, $lang) {
$startTime = microtime(true);
$langDefault = "default";
$log = ["languages" => "Swap field values for language {$langDefault} with {$lang}", "pages" =>[]];
$languages = wire("languages");
// get languages
$l1 = $languages->get($langDefault);
@gebeer
gebeer / _sticky_footer.scss
Created April 10, 2015 08:15
SASS sticky footer mixin
@gebeer
gebeer / bs3AccordionMarkup.php
Created April 6, 2015 04:35
Function to render Bootstrap 3 Accordion markup from a ProcessWire PageArray
/*render a Bootstrap 3 accordion from a PW PageArray
variables passed to this function
$pages: PageArray the children of which will be rendered into an accordion
$title: string, name of the field to be used as panel title, eg "title"
$content: string, name of the field to be used as panel content, eg "bodycopy"
$accordion = "<div class='panel-group' id='accordion' role='tablist' aria-multiselectable='true'>";
*/
function bs3AccordionMarkup($pages, $titlefield, $contentfield) {
$accordion = "<div class='panel-group' id='accordion' role='tablist' aria-multiselectable='true'>";
<?php
/*
* 401 Response
*
* Sends a 401 Response Unauthorized
*
* @author Camilo Castro
*
* @date 29/07/2014