Skip to content

Instantly share code, notes, and snippets.

{
"game": {
"1": {
"players": {
"a": true,
"b": true
}
}
},
@danielmahal
danielmahal / removeduplicateframes.sh
Created March 6, 2017 21:43
Remove duplicate frames from video with ffmpeg and mpdecimate
ffmpeg -i input.mov -vf mpdecimate,setpts=N/FRAME_RATE/TB output.mov
@danielmahal
danielmahal / download images bookmarklet
Last active February 27, 2017 11:41
Download all images (<img>) from webpage
javascript:(function(){ document.querySelectorAll('img').forEach(function(image) { var link = document.createElement('a'); link.setAttribute('download', true); link.setAttribute('href', image.src); link.click(); }) })();
class Card extends React.Component {
static defaultProps = {
width: 500,
height: 500,
colors: [
'#113A1C', '#2C6135', '#C88A1C', '#071946',
'#fff', '#253454', '#CBAFA0', '#771D06'
]
}
// Table copied from
// http://docs.aws.amazon.com/AmazonS3/latest/dev/WebsiteEndpoints.html
export default (region, bucket) => ({
'us-east-1': `${bucket}.s3-website-us-east-1.amazonaws.com`,
'us-west-1': `${bucket}.s3-website-us-west-1.amazonaws.com`,
'us-west-2': `${bucket}.s3-website-us-west-2.amazonaws.com`,
'ap-south-1': `${bucket}.s3-website.ap-south-1.amazonaws.com`,
'ap-northeast-2': `${bucket}.s3-website.ap-northeast-2.amazonaws.com`,
'ap-southeast-1': `${bucket}.s3-website-ap-southeast-1.amazonaws.com`,

Keybase proof

I hereby claim:

  • I am danielmahal on github.
  • I am danielmahal (https://keybase.io/danielmahal) on keybase.
  • I have a public key whose fingerprint is 8560 5B08 BC70 B76D 9768 FE25 6442 8A76 2E6C D6AA

To claim this, I am signing this object:

@danielmahal
danielmahal / firebase-decorator-api.jsx
Last active June 7, 2017 19:47
Firebase decorator api
// Alternative 1
// One function at top-level that returns whatever it needs.
// Can be run multiple times, and return different things
@firebase(props => {
if (!props.projectIndex) {
return {
projectIndex: `users/${props.authId}/projects`,
};
}
@danielmahal
danielmahal / Component.jsx
Last active June 7, 2017 19:47
Firebase/React decorator
import React, {PropTypes} from 'react';
import firebase from 'decorators/firebase';
@firebase({
items: '/items',
// or
// items: (props) => `/${props.id}/items`,
// items: (props) => ref.child('items'),
})
@danielmahal
danielmahal / all.js
Created August 6, 2015 10:26
Composing components?
import React from 'react';
import reduce from 'lodash/collection/reduce';
function compose(Component, containers) {
return reduce(containers, (ComposedComponent, containerCreator) => {
return containerCreator(ComposedComponent);
}, Component);
}
function createContainer(containerCreator) {
@danielmahal
danielmahal / TabBar.js
Last active August 29, 2015 14:05
Simpler components
var EventEmitter = require('events').EventEmitter
var TabBar = function(el, data) {
$(el).on('click', 'a', function() {
this.changeTab($(this).index())
}.bind(this))
}
inherits(TabBar, EventEmitter)