Skip to content

Instantly share code, notes, and snippets.

Avatar

Aaron Ranard aaronranard

View GitHub Profile
@aaronranard
aaronranard / input-max-length.js
Last active Apr 24, 2019
Angular: directive to limit an input field to a max number of characters
View input-max-length.js
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 Feb 15, 2018
Key Value object to Key Value Pair Array
View key-value-transform.js
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 / acf-gallery-lightbox.php
Created Apr 8, 2014
WordPress: ACF - Lightbox Gallery
View acf-gallery-lightbox.php
View PULL_REQUEST_TEMPLATE.md

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 Sep 1, 2017
abstract syntax tree
View ast.md

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

View RegisterCompany.js
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 Jun 16, 2015
SCSS: Materialize icons gulp build fix
View _icons-material-design.scss
$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 Mar 31, 2017
Laravel Middleware for Authy OneTouch callback
View ValidateAuthyMiddleware.php
<?php
namespace App\Http\Middleware;
use Closure;
class ValidateAuthyRequest {
/**
* Handle an incoming request.
*
@aaronranard
aaronranard / currency-validator.js
Last active Oct 27, 2016 — forked from chrisvfritz/currency-validator.js
Currency Validator to account for commas in input
View currency-validator.js
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, ''))
View phpecc.php
<?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';
You can’t perform that action at this time.