Skip to content

Instantly share code, notes, and snippets.

View markshust's full-sized avatar
🤓
Working on educational & training material for Magento 2

Mark Shust markshust

🤓
Working on educational & training material for Magento 2
View GitHub Profile
@markshust
markshust / gist:2561990
Last active March 27, 2024 16:52
Reset permissions on .ssh directory
chmod 700 ~/.ssh
&& chmod 600 ~/.ssh/id_*
&& chmod 644 ~/.ssh/id_rsa.pub
&& chmod 644 ~/.ssh/known_hosts
&& chmod 600 ~/.ssh/authorized_keys
&& chmod 600 ~/.ssh/authorized_keys2
@markshust
markshust / Collection.php
Created February 24, 2024 18:43
Create a custom admin grid collection class to add a custom field to the grid
<?php
// 3. Create a custom collection class that extends SearchResult.
declare(strict_types=1);
namespace Macademy\Minerva\Model\ResourceModel\Faq\Grid;
use Magento\Framework\View\Element\UiComponent\DataProvider\SearchResult;
@markshust
markshust / personal-business-coach.txt
Created January 2, 2024 20:24
ChatGPT Prompt: Personal & business coach
Please act as both a personal and business coach.
## Who am I?
My name is... (continue with extreme detail)
## Given my personal mission statement
As a _your job goes here_, ...
@markshust
markshust / captions.py
Last active December 17, 2023 09:49
Python script to use Whisper to create srt's for all mp4's that don't currently have one in the current directory.
import os
import whisper
from whisper.utils import get_writer
# Get the current directory path
directory = os.getcwd()
# Loop through all the files in the directory
for file in sorted(os.listdir(directory)):
@markshust
markshust / modifyWhereCondition.php
Created December 7, 2023 16:11
Modify a Magento SQL database where condition with an alternate condition
<?php
...
/**
* Modify a WHERE condition in a collection's select statement.
*
* @param \Magento\Framework\Data\Collection\AbstractDb $collection The collection to modify.
* @param string $searchCondition The condition part to search for in the WHERE clause.
* @param string $replaceCondition The condition part to replace with in the WHERE clause.
* @return void
@markshust
markshust / debounce.vue
Created December 3, 2023 13:20
Nuxt Content VueJS v2 Debounce Input
<template>
<div>
<input
type="text"
placeholder="Search"
@input="debounceSearch()"
v-model="search"
/>
</div>
</template>
<template>
<div>
<input
type="text"
placeholder="Search Your Interest"
@input="debounceSearch()"
v-model="searchInput"
/>
</div>
</template>
@markshust
markshust / gist:3204646
Created July 30, 2012 04:35
install apache mod_wsgi on mountain lion
# create symlink to solve missing directory on mountain lion
sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain
# install mod with brew
brew install mod_wsgi
# add this line to httpd.conf and restart apache
LoadModule wsgi_module /usr/local/Cellar/mod_wsgi/3.3/libexec/mod_wsgi.so
sudo apachectl restart
@markshust
markshust / translate.sh
Created March 20, 2023 20:30
Translate SRT file into another language using Google Translate
#!/bin/bash
# Requires translate-shell to be installed.
# Get it on GitHub at: https://github.com/soimort/translate-shell
# Parse command-line arguments
while [[ "$#" -gt 0 ]]; do
case $1 in
--file|-f ) file="$2"; shift ;;
--language|-l ) language="$2"; shift ;;
@markshust
markshust / gpt4_text_compression.md
Created August 2, 2023 17:12 — forked from jimsrc/gpt4_text_compression.md
Minimizing the number of tokens usage to interact with GPT-4.

Overview

I just read this trick for text compression, in order to save tokens in subbsequent interactions during a long conversation, or in a subsequent long text to summarize.

SHORT VERSION:

It's useful to give a mapping between common words (or phrases) in a given long text that one intends to pass later. Then pass that long text to gpt-4 but encoded with such mapping. The idea is that the encoded version contains less tokens than the original text. There are several algorithms to identify frequent words or phrases inside a given text, such as NER, TF-IDF, part-of-speech (POS) tagging, etc.