Skip to content

Instantly share code, notes, and snippets.

View Kikketer's full-sized avatar
🦋

Chris Weed Kikketer

🦋
View GitHub Profile
@Kikketer
Kikketer / environmentService.js
Created January 27, 2015 16:58
Synchronous Environment Injection
'use strict';
angular.module('yourModule')
.factory('environmentService', function() {
var environment;
return {
getEnvironment: function() {
// We need this to be synchronous since everything depends on it.
@Kikketer
Kikketer / app.js
Created January 27, 2015 18:39
Inject environment variables when returning the index file
var environment = {
env: process.env.NODE_ENV || 'local'
};
var envRegex = /\/\/node::environment\s/;
var envString = 'environment = ' + JSON.stringify(environment) + '; //';
var injectEnvironment = function injectEnvironment(req, res) {
fs.readFile(path.join(__dirname, '/app/index.html'), function(err, file) {
res.send(file.toString().replace(envRegex, envString));
@Kikketer
Kikketer / app.js
Created December 7, 2015 14:28
Deployd database wiped on startup
// Set default node environment to development
process.env.NODE_ENV = process.env.NODE_ENV || 'development';
var express = require('express');
var mongoose = require('mongoose');
// Returns some config objects, but I'm not using most for the Deployd test
var config = require('./config/environment');
// Setup server
var app = express();
@Kikketer
Kikketer / karma.conf.js
Created February 19, 2016 17:44
Babel + Angular 1 + Promises not resolving
// Reference: http://karma-runner.github.io/0.12/config/configuration-file.html
module.exports = function karmaConfig (config) {
config.set({
frameworks : [
// Reference: https://github.com/karma-runner/karma-jasmine
// Set framework to jasmine
'jasmine'
],
reporters : [
@Kikketer
Kikketer / canvas-linewrap.js
Created November 4, 2016 03:54
Canvas Line Wrap + Manual Newlines
var canvas = document.getElementById('cvs'),
ctx = canvas.getContext('2d'),
input = document.getElementById('input'),
width = +(canvas.width = 400),
height = +(canvas.height = 250),
fontFamily = "Arial",
fontSize = "24px",
fontColour = "blue";
function fragmentText(text, maxWidth) {
@Kikketer
Kikketer / .xbindkeysrc
Created July 19, 2019 00:01
Mac bindings for Linux on an ThinkPad
# For the benefit of emacs users: -*- shell-script -*-
###########################
# xbindkeys configuration #
###########################
#
# Version: 1.8.6
#
# If you edit this file, do not forget to uncomment any lines
# that you change.
# The pound(#) symbol may be used anywhere for comments.
@Kikketer
Kikketer / menu-button.js
Created November 15, 2019 14:37
Allowing the ReachUI Menu Button to work properly in an iFrame and IE11
import React, { Children, cloneElement, createContext, forwardRef, useContext, useEffect, useRef } from 'react'
import Portal from '@reach/portal'
import Rect, { useRect } from '@reach/rect'
import Component from '@reach/component-component'
import { node, func, object, string, number, oneOfType, any } from 'prop-types'
import { wrapEvent, checkStyles, assignRef, useForkedRef } from '@reach/utils'
import styled from 'styled-components'
const StyledMenuWrap = styled.div`
display: block;