Skip to content

Instantly share code, notes, and snippets.

View tonyjcamp's full-sized avatar

Tony Camp tonyjcamp

View GitHub Profile
@tonyjcamp
tonyjcamp / duplicateItems.js
Created February 12, 2019 17:37
Return duplicate values in an Array
const names = ['Mike', 'Matt', 'Nancy', 'Adam', 'Jenny', 'Nancy', 'Carl', 'Nancy', 'Carl']
const uniq = names
.map((name) => {
return {count: 1, name: name}
})
.reduce((a, b) => {
a[b.name] = (a[b.name] || 0) + b.count
return a
}, {})
@tonyjcamp
tonyjcamp / .eslintrc.json
Last active May 25, 2016 00:11
.eslint, so far ;)
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"extends": [
"eslint:recommended",
"plugin:react/recommended"
],
@tonyjcamp
tonyjcamp / crappy-crap.js
Created March 10, 2012 06:22
OMG I NEED TO HURRY!
var doc = document,
snapshot = doc.getElementById('snapshot'),
photo = snapshot.getContext('2d'),
video = doc.querySelector('video'),
VIDEO_WIDTH, VIDEO_HEIGHT,
computeSize = function(supportsObjectFit){
// user agents that don't support object-fit
// will display the video with a different
// aspect ratio.
if (supportsObjectFit === true){
@tonyjcamp
tonyjcamp / iSeeYou.html
Created March 10, 2012 06:20
getUserMedia example DOM
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=0.5">
<title>Oh hai.</title>
</head>
<body>
<video id="video" width="640" height="480" autoplay>
<!-- Here you can set some default video up if the camera API no worky -->
<source src="default.webm" type="video/webm;" codecs="vp8, vorbis">
@tonyjcamp
tonyjcamp / zsh
Created February 27, 2012 05:56
zsh Theme
# https://github.com/blinks zsh theme
function _prompt_char() {
if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
echo "%{%F{blue}%}±%{%f%k%b%}"
else
echo ' '
fi
}
// 1: how could you rewrite the following to make it shorter?
if (foo) {
bar.doSomething(el);
} else {
bar.doSomethingElse(el);
}