Skip to content

Instantly share code, notes, and snippets.

View ianwcarlson's full-sized avatar

Ian Carlson ianwcarlson

  • Albuquerque, NM
View GitHub Profile
@ianwcarlson
ianwcarlson / remove_docker_images_by_name.sh
Created May 9, 2016 16:53
Remove Docker Images by Name
docker rmi -f $(docker images --format "{{.ID}} {{.Repository}}" | grep <name to search> | awk ' {print $1} ')
@ianwcarlson
ianwcarlson / test.js
Created April 14, 2017 18:20
Reference Comparison Immutable vs. Native
const { Map, List } = require('immutable');
const mapBeforeI = Map({ a: 1, b: List([1, 2]) });
// First let's experiment with an Immutable structure
// Perform set operation, but make the values the same
const mapAfterI = mapBeforeI.set('a', 1);
console.log(mapBeforeI === mapAfterI); // true
// Perform set operation, but make the values different
@ianwcarlson
ianwcarlson / immutable_v4.x.x.js
Last active March 12, 2018 15:38
Stop-gap Immutable Flow Definitions with Working Records
/**
* This file provides type definitions for use with the Flow type checker.
*
* An important caveat when using these definitions is that the types for
* `Collection.Keyed`, `Collection.Indexed`, `Seq.Keyed`, and so on are stubs.
* When referring to those types, you can get the proper definitions by
* importing the types `KeyedCollection`, `IndexedCollection`, `KeyedSeq`, etc.
* For example,
*
* import { Seq } from 'immutable'
@ianwcarlson
ianwcarlson / OpacityAnimation.jsx
Last active June 25, 2017 23:20
Goto React Opacity Animation
import React from 'react';
import css from './OpacityAnimation.css';
import ReactCSSTransitionGroup from 'react-addons-css-transition-group';
const OpacityAnimation = ({ children }) => (
<ReactCSSTransitionGroup
transitionName={css.opacityTransition}
transitionAppear
transitionEnter
transitionLeave
@ianwcarlson
ianwcarlson / OpacityAnimation.css
Last active June 25, 2017 23:26
Goto React Opacity Animation CSS
/* placeholder for named import */
.opacityTransition {};
.opacityTransition-appear {
opacity: 0;
}
.opacityTransition-appear.opacityTransition-appear-active {
opacity: 1;
/* autoprefix transition as needed */
@ianwcarlson
ianwcarlson / Example.jsx
Last active June 25, 2017 23:00
OpacityAnimation Example Usage
import OpacityAnimation from './OpacityAnimation.jsx';
const Example = ({ showBox }) => (
<OpacityAnimation>
{showBox
? <div
key="Example"
style={{
backgroundColor: 'red',
height: '30px',
@ianwcarlson
ianwcarlson / quick_sort.py
Created July 29, 2018 16:56
Quick sort implementation in Python
"""Implement quick sort in Python.
Input a list.
Output a sorted list."""
def sort_slice(list_slice):
# pivot location always starts on the right
end_idx = len(list_slice) - 1
pivot_idx = end_idx
# compare location always starts on the left
compare_idx = 0
while(True):
@ianwcarlson
ianwcarlson / fibonacci_locator_with_recursion.py
Last active July 29, 2018 16:59
Implement a function recursively to get the desired Fibonacci sequence value
"""Implement a function recursively to get the desired
Fibonacci sequence value.
Your code should have the same input/output as the
iterative code in the instructions."""
prev1 = 0
prev2 = 1
count = 0
def recursive(prev1, prev2, count, terminal):
@ianwcarlson
ianwcarlson / substring.py
Last active July 29, 2018 19:10
Find a string within a string without using a library method
# Find a string within a string and return the found index
# Found index will be -1 if string not found
def substring(strToSearch, strToFind):
totalLength = len(strToSearch)
findLength = len(strToFind)
for idx in range(0, totalLength):
if (strToSearch[idx:idx + findLength] == strToFind):
return idx
// This file doesn't go through babel or webpack transformation.
// Make sure the syntax and sources this file requires are compatible with the current node version you are running
// See https://github.com/zeit/next.js/issues/1245 for discussions on Universal Webpack or universal Babel
const { createServer } = require('http')
const express = require('express')
const { parse } = require('url')
const next = require('next')
const path = require('path');
const dev = process.env.NODE_ENV !== 'production'