Skip to content

Instantly share code, notes, and snippets.

View mikeclagg's full-sized avatar

Mike Clagg mikeclagg

View GitHub Profile
@mikeclagg
mikeclagg / loader.js
Created March 16, 2022 17:18
Vanilla Javascript to swap urls for Styles and Scripts
// local vs remote hostred url (needed for static storage usually)
const prefix = isLocal() ? '.' : 'http://example.com';
// Stylesheet path
const cssPath = '/assets/styles/css/app.css';
// Script path
const scriptPath = '/assets/scripts/js/app.js';
// HTML tag attributes
const cnfgs = [
{ link: { rel: 'stylesheet', type: 'text/css', href: prefix + cssPath } },
{ script: { src: prefix + scriptPath } }
#! /bin/bash
#############################################
# TASK 1
#############################################
# HOME directory can be accessed through 2 environment variables on most systems
# $HOME and ~
cd ~
@mikeclagg
mikeclagg / unCamelCase.js
Created October 7, 2015 03:27 — forked from mattwiebe/unCamelCase.js
unCamelCase.js
/**
* Turns someCrazyName into Some Crazy Name
* Decent job of acroynyms:
* ABCAcryonym => ABC Acryoynm
* xmlHTTPRequest => Xml HTTP Request
*/
String.prototype.unCamelCase = function(){
return this
// insert a space between lower & upper
.replace(/([a-z])([A-Z])/g, '$1 $2')
@mikeclagg
mikeclagg / Dockerfile
Created September 24, 2015 16:18 — forked from kvzhuang/Dockerfile
My Dockerfile, initial shell script and run shell script.
# DOCKER-VERSION 0.3.4
FROM ubuntu
MAINTAINER Kevin Zhuang <[email protected]>
#RUN echo "This is a ubuntu Dockerfile."
#replace source.list with http://repogen.simplylinux.ch/
RUN echo "deb http://02.archive.ubuntu.com/ubuntu/ precise main restricted universe multiverse" > /etc/apt/sources.list
RUN apt-get update
grunt.registerMultiTask('s3deploy', 'deploy to S3 using awssum', function () {
// dependencies
var awssum = require('awssum'),
fs = require('fs'),
path = require('path'),
aws = require('./settings').aws;
var amz = awssum.load('amazon/amazon'),
AmazonS3 = awssum.load('amazon/s3'),
s3 = new AmazonS3(aws.accessKey, aws.secretKey, aws.accountId , amz.US_EAST_1),
@mikeclagg
mikeclagg / getCssFiles.py
Created November 21, 2012 00:22
Read a css file that contains @import directives, follows those to build a list of files to concatenate for web optimization
def getCssFiles(baseCssFile, css_files):
import os, re
"""
Checks for css files that are just @import containers,
traverses the files and builds a list in the order they
appear in the files. This prepares a list to use for
bundling n webassets
"""
with open(baseCssFile, 'r') as f:
# Check to see if baseCssFile contains an @import statement at the top