Skip to content

Instantly share code, notes, and snippets.

View mcansh's full-sized avatar
🤠

Logan McAnsh mcansh

🤠
View GitHub Profile

Keybase proof

I hereby claim:

  • I am mcansh on github.
  • I am loganmcansh (https://keybase.io/loganmcansh) on keybase.
  • I have a public key whose fingerprint is ADE4 9096 BA29 0737 ED87 D1FC 29FD FABF F3C4 3C79

To claim this, I am signing this object:

@mcansh
mcansh / slackmoji
Last active April 7, 2017 20:36
resize image for slack emojis
alias slackmoji="sips -Z 128 $1"
@mcansh
mcansh / toTitleCase.js
Last active May 31, 2017 20:09
Converts a String to Titlecase.
function toTitleCase(string) {
if (!string) {
return 'no string was found';
}
let newString = string;
const lowers = ['A', 'An', 'The', 'And', 'But', 'Or', 'For', 'Nor', 'As', 'At', 'By', 'For', 'From', 'In', 'Into', 'Near', 'Of', 'On', 'Onto', 'To', 'With'];
const uppers = ['TV'];
newString = newString.replace(/([^\W_]+[^\s-]*) */g, (txt) => {
return `${txt.charAt(0).toUpperCase()}${txt.substr(1).toLowerCase()}`;
});
@mcansh
mcansh / iNoBounce.js
Last active May 26, 2017 19:10
iNoBounce as an es6 module
function iNoBounce() {
let startY = 0;
const enabled = false;
const handleTouchMove = (e) => {
let el = e.target;
while (el !== document.body) {
const style = window.getComputedStyle(el);
if (!style) {
@mcansh
mcansh / Swipe.js
Last active June 20, 2017 19:05
swipe detection
let xDown = null;
let yDown = null;
function handleTouchStart(e) {
xDown = e.touches[0].clientX;
yDown = e.touches[0].clientY;
}
function handleTouchMove(e) {
if (!xDown || !yDown) {
@mcansh
mcansh / cloneOpen.sh
Last active May 31, 2017 20:11
clone repo, cd into it, fork it on github, and open it in atom
# add this to your `~/.bashrc` or `.zshrc` file
# clone repo, cd into it, fork it on github (if its a github repo), and open it in atom
# requires https://hub.github.com for forking and cloning (user/repos)
alias cloneOpen='f() {
urls=('github.com' 'bitbucket.org' 'gitlab.com')
url=$1
for i in "${urls[@]}"
do
if [[ $url =~ $i ]]
@mcansh
mcansh / console.image.js
Last active June 21, 2017 21:36
Lightweight console.image
console.image = (url, scale = 1) => {
if (!url) return;
const img = new Image();
img.onload = function () {
// way easier to see whats going on when its an array of styles
const styles = [
`background: url("${url}")`,
`background-size: ${(this.width * this.scale)}px ${(this.height * this.scale)}px`,
@mcansh
mcansh / copy.js
Last active September 8, 2017 00:32
copy to clipboard
// copy a string
function copyToClipboard(string) {
const input = document.createElement('input')
input.type = 'text';
input.value = string;
document.body.appendChild(input);
input.select();
document.execCommand('copy');
input.remove();
}
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import styled from 'styled-components';
const Image = styled.img`
height: 100%;
width: 100%;
${props => (props.loading ? 'filter: blur(10px)' : '')};
${props => (props.loading ? 'transform: scale(1.03);' : '')};
${props => (props.loading ? 'overflow: hidden' : '')};