Skip to content

Instantly share code, notes, and snippets.

View V-Gutierrez's full-sized avatar
⚕️
Computer Therapist

Victor Gutierrez V-Gutierrez

⚕️
Computer Therapist
View GitHub Profile
@V-Gutierrez
V-Gutierrez / pubsublocaltesting.txt
Last active April 14, 2023 13:02
PubSub Local testing
docker run --rm -ti -p 8681:8681 -e PUBSUB_PROJECT1=dev,Inhabitant:InhabitantSubscription,User:UserSubscription,Group:GroupSubscription,Role:RoleSubscription,Passion:PassionSubscription,InsertPoints:InsertPointsSubscription,InhabitantVoucher:InhabitantVoucherSubscription messagebird/gcloud-pubsub-emulator:latest
## PUBSUB_PROJECT1=(Project Id),(List of "Topic:Subscription"), <docker-image>
PUBSUB_EMULATOR_HOST=localhost:8681 ./myapp
PUBSUB_PRIVATE_KEY=undefined
PUBSUB_CLIENT_EMAIL=undefined
PUBSUB_PROJECT_ID=dev
PUBSUB_TYPE=service_account
@V-Gutierrez
V-Gutierrez / marketingDataCustomization.ts
Created February 6, 2023 14:59
-- VTEX CUSTOM SOLUTION FOR MARKETING DATA APPLIANCE
import axios from 'axios'
import { OrderformResponse } from './types'
/**
* It takes a URL, parses the URL for UTMs, and then attaches the UTMs to the order form
* @param {string} url - The URL that you want to parse the UTM tags from.
*/
export async function parseUTMTagsFromURL(url: string) {
const parsedUrl = new URLSearchParams(new URL(url).search)
@V-Gutierrez
V-Gutierrez / vtex_runtime_css.ts
Created January 11, 2023 19:26
vtex_runtime_css.ts - Generating CSS clauses on site editor
export function generateStylesheetBasedOnClasses(
classes: string[],
props: Record<string, string>
) {
let stylesheetString = ``
classes.forEach((token) => {
if (!props[token]) return
stylesheetString += `.${token} {
// IS Operator
type Breed = "A" | "B" | "C"
interface Cat {
meow: () => void
breed: Breed
}
function isCat(cat: Cat): cat is Cat {
@V-Gutierrez
V-Gutierrez / xmlinterceptor.js
Last active December 26, 2022 19:31
Interceptor for XML calls on WEB
const oldXHROpen = window.XMLHttpRequest.prototype.open
window.XMLHttpRequest.prototype.open = function (method, url, async) {
console.log(method, url, async)
this.addEventListener('load', function () {
console.log('load: ' + JSON.stringfy(this))
// This as callback function for listener
})
@V-Gutierrez
V-Gutierrez / Dockerfile
Created December 19, 2022 22:49
dockerfile for node:alpine with timezone setting and python setup
FROM node:alpine
WORKDIR /usr/app
COPY ./package*.json ./
RUN apk add g++ make jq py3-configobj py3-pip py3-setuptools python3 python3-dev curl \
&& pip3 install pathlib matplotlib pandas \
&& npm install \
&& rm -rf /var/cache/apk/*
FROM node:alpine
WORKDIR /usr/app
COPY ./package*.json ./
RUN apk add g++ make py3-configobj py3-pip py3-setuptools python3 python3-dev curl \
&& npm install \
&& rm -rf /var/cache/apk/*
grep -o '"fx_rate":[[:digit:]]....' | head -1 | { read -r wumessage; echo $wumessage }
#!/bin/bash
echo "You died!"
echo "Hey do you like coffee? (y/n)"
read coffee_preference
case $coffee_preference in
"y")
#!/bin/bash
#chmod u+x "this"
echo "What is your name?"
read name
echo "What is your age?"
read age
if [ $age -gt 18 ]