Skip to content

Instantly share code, notes, and snippets.

View aaronranard's full-sized avatar

Aaron Ranard aaronranard

View GitHub Profile
@aaronranard
aaronranard / acf-gallery-lightbox.php
Created April 8, 2014 17:03
WordPress: ACF - Lightbox Gallery
@aaronranard
aaronranard / input-max-length.js
Last active April 24, 2019 13:03
Angular: directive to limit an input field to a max number of characters
app.directive('inputMaxlength', function() {
return {
require: 'ngModel',
link: function (scope, element, attrs, ngModelCtrl) {
var maxlength = Number(attrs.inputMaxlength);
function fromUser(text) {
if (text.length > maxlength) {
var transformedInput = text.substring(0, maxlength);
ngModelCtrl.$setViewValue(transformedInput);
ngModelCtrl.$render();
@aaronranard
aaronranard / key-value-transform.js
Last active February 15, 2018 23:26
Key Value object to Key Value Pair Array
const keyValueObj = { "api_url": "https://hawaii.usa.gov", "message": "BALLISTIC MISSILE INBOUND.", "is_drill": true };
const keyValueArray = Object.entries(keyValueObj).map(([key, value]) => ({ key, value }));
/**
* keyValueArray:
* [
* { key: "api_url", value: "https://hawaii.usa.gov" },
* { key: "message", value: "BALLISTIC MISSILE INBOUND." },
* { key: "is_drill", value: true },
* ],
@aaronranard
aaronranard / PULL_REQUEST_TEMPLATE.md
Last active November 29, 2017 22:57
Baseline PR Template

Description

A few sentences describing the overall goals of the pull request's commits.

Todos

  • Tested and working locally
  • New API endpoints documented
  • Unit tests (if appropriate)
  • Integration tests (if appropriate)

QA

@aaronranard
aaronranard / ast.md
Last active September 1, 2017 02:50
abstract syntax tree

Syntax

BNF grammar is in: examples/lang.bnf Lex grammar is in: examples/lang.lex

To see what is all possible view examples/test.lang

Run

import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import debounce from 'throttle-debounce/debounce'
import axios from 'axios';
import SubmitButton from './SubmitButton'
export default class RegisterCompany extends Component {
constructor(props) {
@aaronranard
aaronranard / _icons-material-design.scss
Created June 16, 2015 16:03
SCSS: Materialize icons gulp build fix
$font-mdi : 'Material-Design-Icons';
$mdi-prefix : 'mdi-';
@font-face {
font-family: "#{$font-mdi}";
src:url("#{$icons-font-path}#{$font-mdi}.eot?#iefix") format("embedded-opentype"),
url("#{$icons-font-path}#{$font-mdi}.woff2") format("woff2"),
url("#{$icons-font-path}#{$font-mdi}.woff") format("woff"),
url("#{$icons-font-path}#{$font-mdi}.ttf") format("truetype"),
url("#{$icons-font-path}#{$font-mdi}.svg##{$font-mdi}") format("svg");
@aaronranard
aaronranard / ValidateAuthyMiddleware.php
Created March 31, 2017 19:22
Laravel Middleware for Authy OneTouch callback
<?php
namespace App\Http\Middleware;
use Closure;
class ValidateAuthyRequest {
/**
* Handle an incoming request.
*
@aaronranard
aaronranard / currency-validator.js
Last active October 27, 2016 14:45 — forked from chrisvfritz/currency-validator.js
Currency Validator to account for commas in input
var currencyValidator = {
format: function (number) {
return (Math.trunc(number * 100) / 100).toFixed(2)
},
parse: function (newString, oldNumber) {
var CleanParse = function (value) {
return { value: value }
}
var StringParse = function (string) {
return parseFloat(string.replace(/,/g, ''))
@aaronranard
aaronranard / phpecc.php
Created January 28, 2016 22:55
PHP: PHPECC
<?php
$loader = new PemLoader();
$math = EccFactory::getAdapter();
$this->messages = new MessageFactory($math);
$privKeySerializer = new PemPrivateKeySerializer(new DerPrivateKeySerializer());
$pubKeySerializer = new PemPublicKeySerializer(new DerPublicKeySerializer());
$PrivateKeyPath = env('KEY_LOCATION').'my.priv';
$PublicKeyPath = storage_path().'/app/'.uniqid().'.pub';