Skip to content

Instantly share code, notes, and snippets.

View aaronromeo's full-sized avatar
:shipit:

Aaron Romeo aaronromeo

:shipit:
View GitHub Profile
@aaronromeo
aaronromeo / medusa.sh
Last active March 5, 2022 00:44
Digital Ocean Scripts
#!/bin/sh
# Use this as the command for the user script
# curl https://gist.githubusercontent.com/aaronromeo/a683c9810aad108fab2ae6b3bc583372/raw/medusa.sh | sh
# add docker
sudo apt update
sudo apt install apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"
@aaronromeo
aaronromeo / cypress.Dockerfile
Created May 28, 2019 16:47
Getting Cypress to wait for the server to start
FROM cypress/included:3.3.0
RUN apt-get update && apt-get install -y wget
ENV DOCKERIZE_VERSION v0.6.1
RUN wget https://github.com/jwilder/dockerize/releases/download/$DOCKERIZE_VERSION/dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& tar -C /usr/local/bin -xzvf dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz \
&& rm dockerize-linux-amd64-$DOCKERIZE_VERSION.tar.gz
RUN npm install cypress-image-snapshot@3.0.2
@aaronromeo
aaronromeo / audio_fragment.json
Created December 6, 2016 02:28
Messenger Bot message fragments
{
"attachment":{
"type":"audio",
"payload":{
"url":"https://petersapparel.com/bin/clip.mp3"
}
}
}

Understanding the problem and assumptions

  • CAP Theorem problem
    • Partition tolerance will fail as a result of network connections
    • This solution maximises for availability of data
    • The assumption here is that the consistency of data is less important
  • Users need to be logged in to make changes
  • Sync server is responsible for reducing events
  • Two solutions proposed
    • If no newsfeed or watching other users is required, a movie's favourites are only retrieved when a movie is read
  • If watching other users is required, the solution is more fragile, and should probably result in a push from the server to the device to ensure a proper success response code (which isn't possible in the case of the server getting the results)
@aaronromeo
aaronromeo / rails-init.md
Last active January 7, 2019 16:42
My Rails init setup

The Non API version...

Generate a new app

  • Setup the app using postgres
  • Skip bundle install
  • Skip test files
rails _4.2.7.1_ new myapp -T -d postgresql --skip-turbolinks -B

Create a new PG DB role

@aaronromeo
aaronromeo / 0_reuse_code.js
Created January 22, 2016 14:32
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@aaronromeo
aaronromeo / setup.md
Last active March 29, 2017 22:00
Setting up Protractor tests for Ionic on CodeShip

Under Test Settings

'Select your technology to prepopulate basic commands' as Node.js

Setup Commands

# By default we use the Node.js version set in your package.json or the latest
# version from the 0.10 release
#
# You can use nvm to install any Node.js (or io.js) version you require.
@aaronromeo
aaronromeo / gist:23e133a6689d7c1a47b1
Created November 22, 2014 17:32
Django Rest Framework notes

Django Rest Framework notes

Field conversion using the django rest framework has not been overly intuitive. This might help

  • to_native - Object -> End User (json)
    • This is used to convert a complex object to a primitive Python types
  • from_native - End User (json) -> Object
    • This is used to convert primitive Python types to a complex object

Also see this example from the documentation.

@aaronromeo
aaronromeo / gist:cf0f613248cd38b3a4ed
Last active August 29, 2015 14:09
Using Mandrill headers with Django's email framework
from django.core.mail import EmailMessage
email = EmailMessage(
# subject='',
# body='',
from_email='from@example.com',
to=['to+1@example.com', 'to+2@example.com'],
bcc=['bcc@example.com'],
headers={
'X-MC-Template': 'template-slug',

Working though some stuff with shell plus I had a multi-line function that I needed to debug. I came across %cpaste which is a handy magic function exposing the capability to be able to drop a block of code into ipython or shellPlus.