Skip to content

Instantly share code, notes, and snippets.

View atmd83's full-sized avatar

Andrew Markham-Davies atmd83

View GitHub Profile
@atmd83
atmd83 / Preferences.sublime-settings
Last active August 29, 2015 14:15
my sublime text 3 settings
{
"color_scheme": "Packages/Theme - Spacegray/base16-eighties.dark.tmTheme",
"fade_fold_buttons": false,
"font_face": "Source Code Pro",
"font_size": 11,
"highlight_modified_tabs": true,
"ignored_packages":
[
"JavaScript",
"Vintage"
@atmd83
atmd83 / background-1.js
Last active October 31, 2022 14:11
Demo for cross-extension messaging in chrome extensions
chrome.runtime.onMessageExternal.addListener(function(request, sender, sendResponse) {
console.log('incomming');
if (request.getTargetData){
console.log('We have target data');
sendResponse({targetData: {}});
} else {
if (request.activateLasers) {
var success = true;
console.log('lazers active');
sendResponse({activateLasers: success});
/* this file is not transpiled through babel and some installs of node are v0.x */
/* eslint-disable no-console, no-var, prefer-template */
// 3rd party modules
var path = require('path');
var webpack = require('webpack');
var HappyPack = require('happypack');
// implementation
var buildMode = process.env.NODE_ENV || 'production';
@atmd83
atmd83 / instructions.bash
Last active June 2, 2017 07:08
Installing Phoenix on mac
# the official instructions and blog posts are out of date and the url they suggest goes to a 404 page no
# so here is something more upto date
# all credit to @likethesky who's gist this was based on.
# update and install deps
brew update && brew doctor
brew install postgresql
brew install elixir
mix local.hex
@atmd83
atmd83 / .vimrc
Last active November 10, 2017 14:45
WIP Vim config
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim'
" look and style
@atmd83
atmd83 / .spacemacs
Created November 10, 2017 15:16
Spacemacs config
;; -*- mode: emacs-lisp -*-
(defun dotspacemacs/layers ()
(setq-default
dotspacemacs-distribution 'spacemacs
dotspacemacs-enable-lazy-installation 'unused
dotspacemacs-ask-for-lazy-installation t
dotspacemacs-configuration-layer-path '()
dotspacemacs-configuration-layers
'(
@atmd83
atmd83 / vs-code-settings.json
Last active February 9, 2018 11:24
Visual Studio Code settings
{
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"editor.fontSize": 14,
"editor.fontLigatures": true,
"editor.fontFamily": "Fira Code, Menlo, Monaco, 'Courier New', monospace",
"editor.tabSize": 2,
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"editor.minimap.enabled": false,
@atmd83
atmd83 / thing.1.js
Last active February 27, 2018 12:16
Medium post
import React from 'react';
import PubSub from 'pubsub-js';
export default class Thing extends React.Component {
constructor(props) {
super(props);
}
componentDidMount() {
PubSub.publish('thing.did.mount');
@atmd83
atmd83 / thing.1.spec.js
Last active February 27, 2018 12:16
medium post 2
import React from 'react';
import PubSub from 'pubsub-js';
import { configure, shallow } from 'enzyme';
import Adapter from 'enzyme-adapter-react-16';
configure({ adapter: new Adapter() });
import Thing from './thing';
describe('thing', () => {
@atmd83
atmd83 / thing.2.spec.js
Created February 27, 2018 12:48
medium post updated describe
describe('when the props change', () => {
it('will publish the correct messages based on the prop', () => {
// lets give the component a 'value' prop
component = shallow(<Thing value={3} />);
// lets update the component with the same prop
component.setProps({ value: 3 });
expect(PubSub.publish).lastCalledWith('thing.will.receive.props');
// shouldComponentUpdate will return false
// so componentWillUpdate() will not call