Skip to content

Instantly share code, notes, and snippets.

View firxworx's full-sized avatar

Kevin Firko firxworx

View GitHub Profile
@firxworx
firxworx / vagrant-provision.sh
Created January 5, 2018 18:23
Vagrant shell provisioner (bash) - spin up tomcat7 + mysql, and deploy a java webapp (war file) on a fresh Ubuntu/Debian box
#!/bin/bash -e
# Author: Kevin Firko @firxworx (https://firxworx.com) from Bitcurve Systems (https://bitcurve.com) - 2017
# overview:
# installs and configures tomcat+mysql and then deploys a java webapp (war file) to a bare
# ubuntu 16.04+ (and similar Ubuntu/Debian distros) vagrant box when specified as a shell provisioner
# in a Vagrantfile. loading mysql timezone tables and basic postfix smtp config included.
# this script should also work on other ubuntu versions and debian boxes with minimal modification
@firxworx
firxworx / zendesk-api-create-ticket-with-multiple-custom-fields-demo.php
Created June 27, 2018 20:54
Zendesk PHP API v2: Creating a Ticket with Multiple Custom Fields (Ticket Fields)
<?php
// the zendesk php api (https://github.com/zendesk/zendesk_api_client_php) docs do not include
// examples for setting custom fields or multiple custom fields when creating a ticket.
// so here are a couple that work
// NOTE: to create fields in Zendesk UI:
// Admin (gear icon) -> "Ticket Fields" link in nav under 'Manage' heading -> Add Field
// the Custom Field ID (required for API call) is displayed at at the top of the field's edit page.
@firxworx
firxworx / .htaccess-snippet
Created October 31, 2018 03:58
Restrict access to files in the WordPress uploads folder so they can only be accessed by logged-in users
# The following Apache .htaccess snippet should be included at the top of the .htaccess file in WordPress' root directory.
#
# Use this option only if you wish to manually modify the .htaccess file. To fully contain file restriction functionality
# inside a plugin you can use the mod_rewrite_rules filter as demonstrated in a commented-out block in plugin-snippet.php
#
# Note <IfModule mod_rewrite.c></IfModule> test is intentionally omitted to trigger an error if mod_rewrite is not available.
# BEGIN RestrictFileExample
# it is ok if WordPress also calls these two directives later on in the file
@firxworx
firxworx / .editorconfig
Created February 27, 2021 19:17
Generic editorconfig for web projects
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
[*.{js,jsx,ts,tsx,json,yml,yaml,xml,html,css,sass,scss,less}]
indent_size = 2
@firxworx
firxworx / deploy-wordpress.sh
Created February 5, 2019 01:26
Bash script to deploy a development WordPress to a local path on MacOS
#!/bin/bash
# Create a new local WordPress development site on MacOS
# This script is intended for users who have configured MacOS Apache + a DNS server such as dnsmasq to automatically
# serve up folders created in a special directory with the URL pattern: "http://FOLDER_NAME.test"
#
# See my blog for how to set that up:
# https://firxworx.com/blog/it-devops/sysadmin/setting-up-a-local-development-environment-on-macos-for-lamp-wordpress-projects/
@firxworx
firxworx / tailwind.config.js
Created May 30, 2021 21:32
tailwind config starter - comments detail reminders + common project options w/ urls to relevant tailwind docs
// this gist is meant to serve as a reminder for common tailwindcss configuration options.
// it features comments that are applicable to a range of projects from react to wordpress themes
// the palette and specific settings are for example purposes -- this file is not meant to be production-ready :)
// importing the default theme is useful for referencing it and building on it
const defaultTheme = require('tailwindcss/defaultTheme')
// the `plugin()` function is useful for a variety of purposes @see https://tailwindcss.com/docs/plugins
// for example, new styles can be added to one of tailwind's layers with project-specific class names
@firxworx
firxworx / index.js
Created June 9, 2022 02:40
AWS Lambda@Edge for rewriting request URI - reverse proxy for static sites and apps hosted with S3 + CloudFront CDN
'use strict'
/**
* Minimal implementation of an AWS 'Lambda@Edge' solution for rewriting a request URI.
*
* This Edge Lambda can support static sites + front-end apps hosted on AWS via S3 + CloudFront CDN,
* including those built by popular frameworks such as NextJS (e.g. via NextJS' `next export` static HTML export feature).
*
* An Edge Lambda provides control and can help meet real-world requirements that arise in the development of non-trivial
* front-end web applications, e.g. involving headers, with query strings, etc. that may not be supported (or at least
@firxworx
firxworx / node-spawn.md
Created August 5, 2022 03:22
nodejs child processes

from: prisma/prisma#2917

The reason Prisma is cleaning up its child processes, is we'll end up with a dangling child process. So unfortunately Node.js does not make sure, that the child process is killed properly. That's why Prisma Client is cleaning this up, for now, to not introduce a foot gun for Prisma users.

index.js

@firxworx
firxworx / nx-monorepo-nextjs-nestjs.md
Last active September 20, 2022 18:56
create nx monorepo with nextjs + nestjs

set up an nx monorepo with nextjs front-end and nestjs back-end

yarn global add nx

# start with an empty monorepo and use nx as the cli (vs angular)
yarn create nx-workspace [monorepo_name] --preset=empty --cli=nx

# start with empty monorepo using yarn package manager and js/ts plugin installed
yarn create nx-workspace --package-manager=yarn --preset=ts
@firxworx
firxworx / app.e2e-spec.ts
Created June 29, 2020 16:24
NestJS Integration/E2E Testing Example with TypeORM, Postgres, JWT
import { Test, TestingModule } from '@nestjs/testing'
import { INestApplication, LoggerService } from '@nestjs/common'
import * as request from 'supertest'
import { AppModule } from './../src/app.module'
class TestLogger implements LoggerService {
log(message: string) {}
error(message: string, trace: string) {}
warn(message: string) {}
debug(message: string) {}