Skip to content

Instantly share code, notes, and snippets.

Avatar

Kevin Firko firxworx

View GitHub Profile
@firxworx
firxworx / .editorconfig
Created Feb 27, 2021
Generic editorconfig for web projects
View .editorconfig
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 / app.e2e-spec.ts
Created Jun 29, 2020
NestJS Integration/E2E Testing Example with TypeORM, Postgres, JWT
View app.e2e-spec.ts
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) {}
@firxworx
firxworx / deploy-wordpress.sh
Created Feb 5, 2019
Bash script to deploy a development WordPress to a local path on MacOS
View deploy-wordpress.sh
#!/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 / .htaccess-snippet
Created Oct 31, 2018
Restrict access to files in the WordPress uploads folder so they can only be accessed by logged-in users
View .htaccess-snippet
# 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 / zendesk-api-create-ticket-with-multiple-custom-fields-demo.php
Created Jun 27, 2018
Zendesk PHP API v2: Creating a Ticket with Multiple Custom Fields (Ticket Fields)
View zendesk-api-create-ticket-with-multiple-custom-fields-demo.php
<?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 / scrape-images.py
Created Feb 20, 2018
Web scraping with python: download all files linked to from a given web page with BeautifulSoup, urllib, and shutil
View scrape-images.py
import urllib
import shutil
import re
from pathlib import Path
from bs4 import BeautifulSoup
# target page containing links to the image files
target_page = 'http://example.ca/image_links.php'
# local path
@firxworx
firxworx / vagrant-provision.sh
Created Jan 5, 2018
Vagrant shell provisioner (bash) - spin up tomcat7 + mysql, and deploy a java webapp (war file) on a fresh Ubuntu/Debian box
View vagrant-provision.sh
#!/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