Skip to content

Instantly share code, notes, and snippets.

@atlantis0
atlantis0 / nginxproxy.md
Created August 16, 2017 13:50 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

/*
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
private void showNotification(boolean playing) {
NotificationCompat.Builder builder = from(getApplicationContext(), ...);
builder.setSmallIcon(R.drawable.ic_radio_black_24dp); // set small icon
builder.setColor(getResources().getColor(R.color.colorPrimary)); // set accent color
builder.setContentTitle(this.mMediaMetaData.getRadioStation() + " - " +
this.mMediaMetaData.getProgramName());
builder.setSubText(this.mMediaMetaData.getProgramHost());
private void updateMediaMetaData(MediaMetaData shegerMediaData) {
MediaMetadataCompat.Builder mediaMetaDataBuilder = new MediaMetadataCompat.Builder();
mediaMetaDataBuilder.putBitmap(MediaMetadataCompat.METADATA_KEY_ART, shegerMediaData.getProgramImage());
mediaMetaDataBuilder.putText(MediaMetadataCompat.METADATA_KEY_TITLE, shegerMediaData.getProgramName());
mediaMetaDataBuilder.putText(MediaMetadataCompat.METADATA_KEY_ARTIST, shegerMediaData.getProgramHost());
//mediaMetaDataBuilder.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, shegerMediaData.getDuration());
// TODO - put other parameters here
// TODO - setDescription()
// TODO - maybe year, track number ... other relevant information
@Override
public void onAudioFocusChange(int focusChange) {
switch (focusChange) {
case AudioManager.AUDIOFOCUS_GAIN:
// resume playback,
// it is now safe to continue playing
break;
case AudioManager.AUDIOFOCUS_LOSS:
{"Message":"An error has occurred.","ExceptionMessage":"An error occurred while executing the command definition. See the inner exception for details.","ExceptionType":"System.Data.Entity.Core.EntityCommandExecutionException","StackTrace":" at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition.ExecuteStoreCommands(EntityCommand entityCommand, CommandBehavior behavior)\r\n at System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlan.Execute[TResultType](ObjectContext context, ObjectParameterCollection parameterValues)\r\n at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)\r\n at System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClassb.<GetResults>b__9()\r\n at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)\r\n at System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1
@atlantis0
atlantis0 / sqs_demo.py
Created March 31, 2015 07:05
SQS Demo
import boto
import ast
from boto.sqs.message import RawMessage
from boto.sqs.connection import SQSConnection
sqs_conn = SQSConnection('', '')
queue = sqs_conn.create_queue('SirackQueueTest')
queue.set_message_class(boto.sqs.message.RawMessage)