Skip to content

Instantly share code, notes, and snippets.

View hypeJunction's full-sized avatar

Ismayil Khayredinov hypeJunction

View GitHub Profile
@hypeJunction
hypeJunction / refund.php
Last active June 26, 2023 02:58
Stripe Subscription Cancellation and Prorated Refund
<?php
class StripeSubscriptionHandler {
/**
* Cancel a Stripe subscription, optionally prorating and refunding the unused amount
*
* @param string $id Stripe Subscription ID
* @param bool $at_period_end Type of cancellation
* If set to true, will cancel the subscription at its end
@hypeJunction
hypeJunction / README.md
Last active May 26, 2023 18:16
NOAA NCEI Web Services Taxonomies

NCDC Climate Data Online National Centers for Environmental Information Web Services https://www.ncdc.noaa.gov/cdo-web/webservices

Web services wouldn't let me find locations or look up taxonomies by name, so I created my own mappings.

@hypeJunction
hypeJunction / package.json
Last active June 15, 2022 10:34
Same react app package.json
{
"name": "@me/package-a",
"scripts": {
"build": "concurrently \"yarn build:ts\" \"yarn build:css\" \"yarn build:assets\"",
"build:ts": "tsc --pretty",
"build:css": "postcss ./src/**/*.css --base ./src -d ./dist",
"build:assets": "mkdir -p ./dist/assets && cp -r ./src/assets ./dist",
"watch": "concurrently \"yarn watch:ts\" \"yarn watch:css\" \"yarn watch:assets\"",
"watch:ts": "chokidar \"src/**/*.ts\" \"src/**/*.tsx\" -c \"yarn build:ts\"",
"watch:css": "chokidar \"src/**/*.css\" -c \"yarn build:css\"",
@hypeJunction
hypeJunction / Dockerfile
Last active June 15, 2022 10:18
Dockerfile for monorepo
FROM node:16-alpine as server-builder
WORKDIR /app
COPY . .
RUN --mount=type=cache,target=/app/.yarn/cache \
npx turbo prune --scope=@me/application-a && \
cp -R .yarn .yarnrc.yml tsconfig.json out/ && \
cd out && \
yarn install && \
@hypeJunction
hypeJunction / package.json
Created June 15, 2022 07:01
root package.json
{
"name": "@me/monorepo",
"private": true,
"workspaces": [
"packages/**/*",
"applications/**/*"
],
"scripts": {
"build": "turbo run build",
"dev": "concurrently \"yarn dev:init\" \"yarn watch\"",
@hypeJunction
hypeJunction / turbo.json
Created June 15, 2022 06:48
Turborepo config example
{
"$schema": "https://turborepo.org/schema.json",
"baseBranch": "origin/master",
"pipeline": {
"build": {
"dependsOn": ["^build"],
"inputs": ["src/**/*", "package.json", "tsconfig.json"],
"outputs": ["dist/**"]
},
"test": {
@hypeJunction
hypeJunction / package.json
Created June 15, 2022 06:39
Sameple next.js package.json
{
"name": "@me/application-a",
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"test": "cypress run"
},
"dependencies": {
"@me/package-a": "workspace:^"
import Chainable = Cypress.Chainable;
const getDialog = (name: string | RegExp) => {
return cy.findByRole('dialog', { name });
};
const getForm = (subject: Chainable, name: string | RegExp) => {
const chain = subject ? cy.wrap(subject) : cy;
return chain.findByRole('form', {
cy.getForm('Add To-Do Item').within(() => {
cy.getInput('To-Do Item').type('Buy Milk');
cy.getButton('Add').press();
})
cy.getList('To-Do List').within(() => {
cy.getListItem('Buy Milk').should('exist');
cy.getInput('Buy Milk').check();
});
Cypress.Commands.add('press', { prevSubject: 'element' }, (subject: JQuery) => {
cy.wrap(subject)
.focus();
cy.focused()
.type('{enter}');
return cy.wrap(subject);
});