This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public fetchABunchOfData (rootObj: RootObj): Observable<Project> { | |
// Returned original RootObj as an Observer when nested resource is fetched | |
let returnedData = new ReplaySubject(1); | |
let firstObservable = Observable.forkJoin( | |
this._cloud.getSomeRestData(rootObj.id), | |
this._cloud.getOtherRestData(rootObj.id) | |
); | |
// Execute first two Rest calls (someData and OtherData) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Example of a deployment script for: | |
- A Django based server running as an Elastic Beanstalk server tier, with Load Balancing | |
(Assumes a pre-configured RDS database - best practice) | |
- A Docker based running as an Elastic Beanstalk worker tier | |
Assumes following directory structure | |
- ./server # With Django based project and appropriate .ebextensions | |
- ./worker # with Docker based project and appropriate .ebextensions, Dockerfile and Dockerrun.aws.json file | |
# (similar to https://github.com/dkarchmer/aws-eb-docker-django) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ViewSets define the view behavior. | |
class FooViewSet(viewsets.ModelViewSet): | |
lookup_field = 'slug' | |
queryset = Foo.objects.all() | |
serializer_class = FooSerializer | |
def get_queryset(self): | |
""" | |
This view should return a list of all records |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'dkarchmer' | |
""" | |
See https://gist.github.com/dkarchmer/d85e55f9ed5450ba58cb | |
This API generically supports DjangoRestFramework based APIs | |
It is based on https://github.com/samgiles/slumber, but customized for | |
Django Rest Frameworks, and the use of TokenAuthentication. | |
Usage: | |
# Assuming | |
# v1_api_router.register(r'some_model', SomeModelViewSet) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get(event, context): | |
response = _get_error_responce('Incorrect URL format: Use /foobar/<a>/<b>/?type=<url/file>') | |
if 'queryStringParameters' in event and 'pathParameters' in event: | |
if event['pathParameters'] and 'a' in event['pathParameters'] and 'b' in event['pathParameters']: | |
a = event['pathParameters']['a'] | |
b = event['pathParameters']['b'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if [ -f ~/.bashrc ]; then | |
source ~/.bashrc | |
fi | |
# pip should only run if there is a virtualenv currently activated | |
export PIP_REQUIRE_VIRTUALENV=true | |
gpip(){ | |
# gpip allows to install on global env | |
PIP_REQUIRE_VIRTUALENV="" pip "$@" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import sys | |
import time | |
import boto3 | |
import botocore | |
import pprint | |
from invoke import run, task | |
DB_CONFIG = { | |
# SecurityGroup='sg-name" with ingress on port 5432 and source from itself |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Based on http://pythonhackers.com/p/fluent-ffmpeg/node-fluent-ffmpeg | |
// and https://trac.ffmpeg.org/wiki/Create%20a%20mosaic%20out%20of%20several%20input%20videos | |
// Usage: | |
// node ffmpeg-mosaic.js file1.mp2 file2.mp4 file3.mp4 file4.mp4 | |
// Generates out.mp4 | |
var ffmpeg = require('fluent-ffmpeg'); | |
var command = ffmpeg() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import time | |
import sys | |
from iotile.core.hw import HardwareManager | |
def build_parser(): | |
parser = argparse.ArgumentParser(description="Print broadcast readings from a specific device") | |
parser.add_argument('-d', '--dev', type=lambda x: int(x, 0), help="Optional, the UUID of the device you want to see broadcasts from (0x21 for example)") | |
parser.add_argument('-i', '--interval', type=float, default=1.0, help="The minimum interval in seconds between two reported readings (only applies when -d is given), defaults to 1s") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Assumes the following directory structure: | |
* ./images # With original images | |
* ./base # With the index.html, css, js to be used to create a base template | |
* # This directory containts its own gulpfile (maybe coming from a yeoman or similar) | |
* ./server # Actual Django project, with a templates subdirectory | |
*/ | |
var gulp = require('gulp'); | |
var chug = require( 'gulp-chug' ); | |
var awspublish = require('gulp-awspublish'); |