Skip to content

Instantly share code, notes, and snippets.

View codfish's full-sized avatar

Chris O'Donnell codfish

View GitHub Profile
@codfish
codfish / remove-duplicates.js
Last active November 20, 2018 03:55
Remove duplicate values from an array by converting it to a Set, then back to an array.
[...new Set([].concat(...arrayName))]
@codfish
codfish / Dockerfile
Last active February 20, 2019 18:03
Example json-server module for marketing campaigns. `json-server api.js`
FROM mhart/alpine-node:11.10
RUN mkdir /app
WORKDIR /app
COPY ./package.json ./package-lock.json ./
RUN npm install
EXPOSE 4000
CMD npm run dev
@codfish
codfish / swagger.yml
Created April 3, 2018 13:32
Example swagger 2.0 doc with extensive use of reusable definitions, responses & parameters.
swagger: '2.0'
info:
version: '0.0.1'
title: Marketing Campaign API
host: api.example.com
basePath: /v1
@codfish
codfish / htmlentity.js
Created February 28, 2018 14:24 — forked from CatTail/htmlentity.js
Javascript: encode(decode) html text into html entity
// encode(decode) html text into html entity
var decodeHtmlEntity = function(str) {
return str.replace(/&#(\d+);/g, function(match, dec) {
return String.fromCharCode(dec);
});
};
var encodeHtmlEntity = function(str) {
var buf = [];
for (var i=str.length-1;i>=0;i--) {
@codfish
codfish / xdebug-hack.md
Last active December 23, 2024 15:20
Xdebug Hack

Xdebug tends to slow down a lot of things. Here's a hack to unload the extension by default but load it whenever it's needed (for instance, when generating php code coverage.

Prevent Xdebug from loading by default

If you use brew to install php 7, should be here: /usr/local/etc/php/<version>/conf.d/ext-xdebug.ini. Edit that file (replacing <version> with whatever version of php you're using) and comment out the line that begins with zend_extension. The code examples here assume 7.0.

;zend_extension="/usr/local/opt/php70-xdebug/xdebug.so"
@codfish
codfish / .php_cs.dist
Last active July 6, 2023 19:12
PHP-CS-Fixer configuration file. PSR-2 plus some opinionated options to make code cleaner.
<?php
/**
* Rules we follow are from PSR-2 as well as the rectified PSR-2 guide.
*
* - https://github.com/FriendsOfPHP/PHP-CS-Fixer
* - https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md
* - https://github.com/php-fig-rectified/fig-rectified-standards/blob/master/PSR-2-R-coding-style-guide-additions.md
*
* If something isn't addressed in either of those, some other common community rules are
@codfish
codfish / index.html
Last active November 20, 2017 17:50
AngularJS 1.x Slick Carousel Directive
<div class="slick-slider clearfix"
data-slick-carousel
data-slides="gallery.slides"
data-interstitial="gallery.interstitial"
data-settings="{}"
data-active="gallery.active"
data-onchange="gallery.onAfterChange"
data-count="gallery.slides.length"
data-interstitial-link="gallery.interstitial.link"
data-autoplay="true"
@codfish
codfish / app-controller.js
Created November 20, 2017 17:41
AngularJS 1.X Meta Service
/**
* Application Controller
*
* @ngInject
*/
function AppCtrl($rootScope, $log, $state, MetaService, configuration) {
$rootScope.$on('$stateChangeSuccess', function(event, state, params, from, fromParams) {
// set canonical based on the new state url & param values
MetaService.canonical = configuration.DOMAIN_HOST + $state.href(state, params);
});
@codfish
codfish / no-js-no-styles.scss
Last active September 21, 2017 13:20
Remove site styles when js is not supported
// when using modernizr or similar
.no-js body * {
display: initial !important;
opacity: 1 !important;
visibility: visible !important;
overflow: visible !important;
transform: none !important;
float: none !important;
position: static !important;
height: auto !important;
@codfish
codfish / reference.md
Last active January 3, 2026 17:17
Dev Resources & Reference

Here are some sites with useful developer tools & reference material. Mostly used as a reference for myself to not forget some of the cool tools I've come across but don't actively use.

  • Context7 MCP: Up-to-date Code Docs For Any Prompt. Source
  • Posthog: All your developer tools in one place. PostHog gives engineers everything to build, test, measure, and ship successful products faster. Source
  • pg_textsearch: PostgreSQL extension for BM25 relevance-ranked full-text search. Postgres OSS licensed. Source, Source
  • Unplugin: The Unified Plugin System Supports Vite, Rollup, webpack, esbuild, and every framework built on top of them. -- Source
  • Monorepos: Everything you need to know about monorepos, and the tools to build them. [Sour