Skip to content

Instantly share code, notes, and snippets.

Avatar

Chris O'Donnell codfish

View GitHub Profile
@codfish
codfish / Dockerfile
Last active Feb 20, 2019
Example json-server module for marketing campaigns. `json-server api.js`
View Dockerfile
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 Apr 3, 2018
Example swagger 2.0 doc with extensive use of reusable definitions, responses & parameters.
View swagger.yml
swagger: '2.0'
info:
version: '0.0.1'
title: Marketing Campaign API
host: api.example.com
basePath: /v1
@codfish
codfish / htmlentity.js
Created Feb 28, 2018 — forked from CatTail/htmlentity.js
Javascript: encode(decode) html text into html entity
View htmlentity.js
// 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--) {
View xdebug-hack.md

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 Apr 5, 2020
PHP-CS-Fixer configuration file. PSR-2 plus some opinionated options to make code cleaner.
View .php_cs.dist
<?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 Nov 20, 2017
AngularJS 1.x Slick Carousel Directive
View index.html
<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 Nov 20, 2017
AngularJS 1.X Meta Service
View app-controller.js
/**
* 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 Sep 21, 2017
Remove site styles when js is not supported
View no-js-no-styles.scss
// 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 Oct 18, 2020
Dev Resources & Reference
View reference.md

Here are some sites with useful developer tools & reference material. Some of them are simple links to the original source, while some are also elaborated on below for quick & helpful reference.

  • Fauna: The database built for serverless, featuring native GraphQL -- Source
  • Cloudinary: Store, transform, optimize, and deliver all your media assets with easy-to-use APIs, widgets, or user interface. -- Source
  • Spectacle: A React.js based library for creating sleek presentations using JSX syntax that gives you the ability to live demo your code. -- Source
  • Cheat Sheets -- Source
  • HEAD: A list of everything that could go in the head of your document -- Source
  • Shields.io: We serve fast and scalable informational images as badges for GitHub, Travis CI, Jenkins, WordPress and man
@codfish
codfish / find_string_in_repo.sh
Created May 24, 2016
Get an alphabetical list of files that a specific string is found within your repo
View find_string_in_repo.sh
git grep '<string to search for>' | awk '{print $1}' | sed 's/:$//' | sort -u
You can’t perform that action at this time.