Skip to content

Instantly share code, notes, and snippets.

Avatar
💻
building withcabin.com

Nic Mulvaney mulhoon

💻
building withcabin.com
View GitHub Profile
@mulhoon
mulhoon / global-component-loader.js
Created Jul 23, 2019
Global component loading in Vue
View global-component-loader.js
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]
@mulhoon
mulhoon / s3proxy.js
Last active Jul 15, 2018
Serve S3 files through express proxy
View s3proxy.js
// 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 / PUSH_Notifications.md
Created Nov 14, 2016
How to add push notification to a Cordova project - the easy and reliable way.
View PUSH_Notifications.md

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 / $.js
Last active Aug 15, 2016
jQuery selection in One Line
View $.js
$ = function(s){return s.charAt(0)==='#' ? document.getElementById(s.slice(1)) : document.querySelectorAll(s);};
@mulhoon
mulhoon / onesignal-node.js
Last active May 19, 2021
Send a push notification in node with OneSignal
View onesignal-node.js
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 / App.push.js
Created Feb 11, 2016
JS for One Signal
View App.push.js
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 / Highcharts Cheat Sheet
Last active Mar 25, 2021
Highcharts Cheat Sheet
View 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.
View gist:701ddfe6531837717018
var levelup = new LevelUp(
{
persistant:true // uses localStorage - default: true
callback:function(){...} // callback when levelling up
levels: // custom levels
[
{
"checkmark": 0,
"status": "noob",
"quote": "You're just a little newbie"
@mulhoon
mulhoon / validate.js
Last active Aug 29, 2015
Validate email address
View validate.js
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 / animation.js
Last active Aug 29, 2015
Timeline a VelocityJS animation
View animation.js
// 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});
});