Skip to content

Instantly share code, notes, and snippets.

@aray12
aray12 / README.md
Last active September 8, 2021 18:58
Using the `amp-twitter` component instead of a custom `amp-iframe` component eliminates the need to manage the dynamic height of embedded Tweets.

There are 2 possible options for embedding Tweets into an AMP article. First, is to use the amp-iframe component which references a isolated HTML page that renders an embedded Tweet. The second is to use the amp-twitter component. The use of amp-twitter is recommended because it elliminates some complexity from implementation. Tweets have dynamic heights based on content, width, configuration, etc., and the 3rd party JavaScript managing the injections of these Tweets handles these dynamic heights. The problem with using amp-iframe is that the 3rd party JavaScript no longer has access to the top-level window and therefore can't properly resize elements based on these heights. So this requires that the consumer of the amp-iframe component follow some steps in order to handle the dynamic height:

  1. Use the `resizable
@aray12
aray12 / queryMiddleware.js
Created January 24, 2017 02:59
With redux-api-middelware takes a property called query and appends a query string to the endpoint
import qs from 'querystring';
import { CALL_API } from 'redux-api-middleware';
export default function queryMiddleware() {
return next => action => {
if (action.hasOwnProperty(CALL_API) && action[CALL_API].hasOwnProperty('query')) {
const request = action[CALL_API];
request.endpoint = [
request.endpoint.replace(/\?*/, ''),
qs.stringify(request.query),
@aray12
aray12 / codedeploy-github.sh
Created January 22, 2017 23:56
Deploy using github as the source of your revision
#!/usr/bin/env bash
APPLICATION_NAME="YOUR_APP_NAME"
DEPLOYMENT_GROUP="YOUR_DEPLOY_GROUP_NAME"
REGION="us-west-2"
REPOSITORY="your/github-repo"
# Install jq if not already installed
# We use jq to parse the json return by the AWS API's
# If you don't know about jq, it is dope. Learn more here: https://stedolan.github.io/jq/
#!/usr/bin/env bash
# This kills all connections to a database a resets it based
# on a backup file. The first argument passed should be the
# name of the database. The second should be the complete
# filepath for the backup. The backup should have already been
# compressed using the gzip utility. If you are working on a
# remote database set the environment variables recognized by
# psql
#
@aray12
aray12 / App.js
Last active January 20, 2016 18:07
import React, { Component, PropTypes } from 'react';
import { connect } from 'react-redux';
import NavBar from './Navbar';
import Login from './Login';
export default class App extends Component {
constructor(props, context) {
super(props, context);
const someArray = [4,3,3,2,5,6,63,1,43,34,46,46,2,35,35,64,75];
function reduction(list, callback) {
if (typeof callback !== 'function') {
throw new Error('callback not function');
}
let count = 1;
function reducting(current) {
if (++count > list.length - 1) {
const someArray = [4,3,3,2,5,6,63,1,43,34,46,46,2,35,35,64,75];
function sum(list) {
let count = 1;
function add(x,y) {
const sum = x + y;
if(++count > list.length - 1) {
return sum;
# /etc/rc.d/rc.local
HOMEDIR = /home/ec2-user
GITREPO = git@github.com:org/project.git
GITDIR = $HOMEDIR/project
cd $HOMEDIR
# Clone the latest version
git clone $GITREPO
@aray12
aray12 / promise-with-arrows.js
Last active October 22, 2015 17:50
Promise.join with arrow function
/**
* This does not work on node v4.2.0
*
* Reason has been determined. The first example of arrow functions is a function
* definition, not a function call. The second is a function call that passes the
* return value to Promise.join
*/
'use strict';
const Promise = require('bluebird');
'use strict';
var _ = require('lodash'),
Promise = require('bluebird'),
models = require('../database'),
pipeline = require('../utils/pipeline'),
utils = require('./utils'),
errors = require('../errors');
var listing = {