Skip to content

Instantly share code, notes, and snippets.

View gcavanunez's full-sized avatar

Guillermo Antony Cava Nuñez gcavanunez

View GitHub Profile
#!/usr/bin/osascript
# Required parameters:
# @raycast.schemaVersion 1
# @raycast.title All to main
# @raycast.mode compact
# Optional parameters:
# @raycast.icon �ü§ñ
@gcavanunez
gcavanunez / pickKeys.ts
Last active December 30, 2022 14:15
Typescript patterns
const extractFromObj = <T, K extends keyof T>(
obj: T,
keys: K[]
): Pick<T, K> => {
return keys.reduce((newObj, curr) => {
newObj[curr] = obj[curr];
return newObj;
}, {} as Pick<T, K>);
};
@gcavanunez
gcavanunez / some_controller.ex
Created December 18, 2022 03:59
Streaming a file from elixir
def sup(conn, _params) do
conn = conn
|> put_resp_header("content-type", "audio/mp3")
|> send_chunked(200)
File.stream!("priv/static/assets/sample4.mp3", [], @chunk_size)
|> Enum.into(conn)
end
# https://stackoverflow.com/questions/37544655/elixir-stream-audio-to-users
@gcavanunez
gcavanunez / kohls.js
Created July 9, 2021 19:33
RickJames+Kohls
/**
* 3 simple details
*
* 1. wraping it in a module to not leak variables to the global scope.
* 2. using reduce, map or forEach instead of for in loops
* 3. right away checking if the cart is accesible o stopping and throwing an error
*/
// Wrapping it in a module to keep global scope clean
let challengeModule = (() => {
@gcavanunez
gcavanunez / tw-skeleton.css
Created December 28, 2020 13:37 — forked from acidjazz/tw-skeleton.css
tailwind skeleton css
.skeleton {
--text-opacity: 0;
background-image: linear-gradient(100deg, #edf2f7 0%, #f4f7fa 20%, #edf2f7 40%);
background-position: 50%;
background-size: 200%;
animation: skeleton 1.25s infinite linear;
}
.skeleton-teal {
background-image: linear-gradient(100deg, #b4c5f8 0%, #cad8f9 20%, #b4c5f8 40%);
@gcavanunez
gcavanunez / .cpanel.yml
Created June 9, 2020 02:57
Simple Cpanel YML
---
deployment:
tasks:
- export DEPLOYPATH=/home/cpanel_account_name/sub.domain.com/
- /bin/cp -r * $DEPLOYPATH

MySQL Cheat Sheet

Help with SQL commands to interact with a MySQL database

MySQL Locations

  • Mac /usr/local/mysql/bin
  • Windows /Program Files/MySQL/MySQL version/bin
  • Xampp /xampp/mysql/bin

Add mysql to your PATH

version: '3'
services:
#Database
db:
image: mysql:5.7
volumes:
- db_data:/var/lib/mysql
restart: always
environment:
add_filter( 'woocommerce_loop_add_to_cart_link', 'replacing_add_to_cart_button', 10, 2 );
function replacing_add_to_cart_button( $button, $product ) {
$button_text = __("View Product", "woocommerce");
$button = '<a class="button" href="' . $product->get_permalink() . '">' . $button_text . '</a>';
return $button;
}
<?php
class SessionManager {
public static function sessionStart($name, $limit = 0, $path = '/', $domain = null, $secure = null){
// Set the cookie name
session_name($name . '_Session');
// Set SSL level
$https = isset($secure) ? $secure : isset($_SERVER['HTTPS']);