Skip to content

Instantly share code, notes, and snippets.

View mulhoon's full-sized avatar
💻
building withcabin.com

Nic Mulvaney mulhoon

💻
building withcabin.com
View GitHub Profile
@mulhoon
mulhoon / templateEngine.php
Last active February 18, 2018 22:18
Simple PHP Template engine
<?php
/*
Original by Rasmus Larsson
http://www.rasmuslarsson.se/2013/05/a-template-engine-in-php/
*/
class Template
{
protected $template;
@mulhoon
mulhoon / animation.js
Last active August 29, 2015 14:02
Timeline a VelocityJS animation
// requires underscore or lodash + velocity + jquery
var animation = {
play:function(sequence, complete){
_.each(sequence, function(o){
var el = $(o.el);
el.attr('style','');
_.each(o.timeline, function(a, i){
el.velocity(a, {delay:a.delay, complete:a.end ? complete : null});
});
@mulhoon
mulhoon / validate.js
Last active August 29, 2015 14:05
Validate email address
var validateEmail = function(email) {
var re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
};
@mulhoon
mulhoon / Highcharts Cheat Sheet
Last active March 22, 2023 18:43
Highcharts Cheat Sheet
$('#container').highcharts({
chart: {
alignTicks: true, // When using multiple axis, the ticks of two or more opposite axes will automatically be aligned by adding ticks to the axis or axes with the least ticks.
animation: true, // Set the overall animation for all chart updating. Animation can be disabled throughout the chart by setting it to false here.
backgroundColor: '#FFF', // The background color or gradient for the outer chart area.
borderColor: '#4572A7', // The color of the outer chart border.
borderRadius: 5, // The corner radius of the outer chart border. In export, the radius defaults to 0. Defaults to 5.
borderWidth: 0, // The pixel width of the outer chart border.
className: null, // A CSS class name to apply to the charts container div, allowing unique CSS styling for each chart.
defaultSeriesType: 'line', // Alias of type.
@mulhoon
mulhoon / App.push.js
Created February 11, 2016 15:31
JS for One Signal
App.push = (function(){
var id = '[---App ID---]';
var notificationOpenedCallback = function(jsonData) {
console.log('didReceiveRemoteNotificationCallBack: ' + JSON.stringify(jsonData));
};
var init = function(customid, callback){
id = customid ? customid : id;
@mulhoon
mulhoon / onesignal-node.js
Last active November 9, 2021 07:28
Send a push notification in node with OneSignal
var request = require('request');
var sendMessage = function(device, message){
var restKey = '****';
var appID = '****';
request(
{
method:'POST',
uri:'https://onesignal.com/api/v1/notifications',
headers: {
@mulhoon
mulhoon / $.js
Last active August 15, 2016 16:35
jQuery selection in One Line
$ = function(s){return s.charAt(0)==='#' ? document.getElementById(s.slice(1)) : document.querySelectorAll(s);};
@mulhoon
mulhoon / PUSH_Notifications.md
Created November 14, 2016 16:29
How to add push notification to a Cordova project - the easy and reliable way.

Push Notifications for cordova.

Use One Signal to add push notifications. There's no need to do anything on the Apple Member Center.

Set up One Signal

  1. Use this to download a .p12 file
  2. Add a new app using the same .p12 for developer and production
  3. Note your App ID and REST API Key from App Settings > Keys & IDs

In your app

@mulhoon
mulhoon / s3proxy.js
Last active March 20, 2023 22:42
Serve S3 files through express proxy
// Example of using express to proxy files from s3.
// Works with streaming media like mp4
const AWS = require('aws-sdk')
const mime = require('mime-types')
const express = require('express')
AWS.config.update({
secretAccessKey: '...',
accessKeyId: '...',
@mulhoon
mulhoon / global-component-loader.js
Created July 23, 2019 14:47
Global component loading in Vue
import Vue from 'vue'
const components = require.context('@/components', true, /[A-Z]\w+\.(vue)$/)
let keys = components.keys()
keys.forEach(fileName => {
const componentConfig = components(fileName)
const componentName = fileName
.split('/')
.pop()
.split('.')[0]