Skip to content

Instantly share code, notes, and snippets.

View TimothyRHuertas's full-sized avatar

Timothy Huertas TimothyRHuertas

View GitHub Profile
@TimothyRHuertas
TimothyRHuertas / 01Redis.config
Last active August 29, 2015 14:16
Elastic BeanstalkRuby 2.1 (Puma) with Resque
commands:
create_post_dir:
command: "mkdir /opt/elasticbeanstalk/hooks/appdeploy/post"
ignoreErrors: true
create_pid_dir:
command: "mkdir /var/app/current/tmp/pids"
ignoreErrors: true
files:
"/etc/init/resque.conf":
mode: "000755"
@TimothyRHuertas
TimothyRHuertas / Abstract.md
Last active June 8, 2021 19:51
Mocking React components with Sinon and QUnit.

React makes compositing components easy. However testing them can get ugly if you are not careful. Consider this example:

var ChildA = React.createClass({
    displayName: "ChildA",
    render: function(){
        return (<div>A in the house</div>);
    }
});
@TimothyRHuertas
TimothyRHuertas / Abstract.md
Last active September 11, 2015 17:02
Rails + webbrick + redirect_to + itms-services == bug

Problem:

Calling redirect_to "itms-services:\/\/\/\/?action=download-manifest&url=#{some_url}" does not behave as expected. It sets the location header to itms-services:?action=download-manifest&url=#{some_url} it should be itms-services://?action=download-manifest&url=#{some_url} Notice the forward slashes are missing from the location header value.

Solution (a dirty, dirty hack); use four backslashes:

redirect_to "itms-services:\/\/\/\/?action=download-manifest&url=#{some_url}"
@TimothyRHuertas
TimothyRHuertas / Abstract.md
Last active August 24, 2019 08:28
Filter react-treebeard

Alex Curtis created react-treebeard a data driven tree view for React. I needed to enable users to filter the tree's nodes based on input text. To accomplish this I transform the tree's data using 2 functions when the filter changes and rerender the view:

  1. filterTree Given a tree return a new tree keeping only the nodes that meet one of the following conditions:
    1. Has matching text
    2. Has a parent with matching text
    3. Has a child with matching text
  2. expandNodesWithMatchingDescendants - Given a tree mark all the nodes with matching descendants as toggled

Here are the aformentioned functions.

@TimothyRHuertas
TimothyRHuertas / frames.sh
Created June 20, 2017 23:24
Use ffmpeg to center crop and scale an image to 1:1
#Given a video of any aspect ratio this script will extract center cropped thumbnails at 299x299.
#Useful for gathering image training data.
#Assumes ffmpeg 3.3.2
#If you get an error about exact that means you are using an older version of ffmpeg
#Simply remove the :exact=1.
#This will make it work, but may cause the output size to be off by a pixel
#Script assumes you are downsampling.
#!/bin/bash