Skip to content

Instantly share code, notes, and snippets.

View template_maria_diaspora.txt
Dear coworkers,
Earlier this week Puerto Rico was hit by one of the most powerful hurricanes ever recorded in the Atlantic. The life and economic loss are massive. Most of the island's roads are either blocked or washed out, and the electricity and telecoms systems went down broadly.(In a personal note: <ADD SOMETHING ABOUT YOUR FAMILY OR FRIENDS IN THE ISLAND>).
While it's still early to assess all damage, the early reports are incredibly awful. Much like the areas of US that were affected by Harvey and Irma, Maria will leave a painful scar. Electricity, food, & clean water will be scarce for months. Some areas will probably be completely disconnected from the outer world for a while.
I share this with you so you can appreciate the gravity of the situation and ask you for your help.
How to help:
View MMSController
//Reminder this class needs to inherit from TwilioController --> public class MMSController : TwilioController
public ActionResult Index(string from, string mediaurl0)
{
Image blended = CreateBlendedImage(mediaurl0);
//We are using Azure Storage, and loading our credentials from our config file
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["<CONNECTIONKEY>"].ToString());
// Create the blob client
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
// Retrieve a reference to a container.
@abe238
abe238 / CreateBlendedImage
Created Jun 29, 2015
Create Blended Image
View CreateBlendedImage
private static Image CreateBlendedImage(string backgroundimageurl)
{
Image imageBackground;
Image imageOverlay;
var request = WebRequest.Create(backgroundimageurl);
using (var response = request.GetResponse())
using (var stream = response.GetResponseStream())
{
imageBackground = Bitmap.FromStream(stream);
@abe238
abe238 / ScaleImage
Last active Aug 29, 2015
Scale Image
View ScaleImage
public static Image ScaleImage(Image image, int maxWidth, int maxHeight)
{
var ratioX = (double)maxWidth / image.Width;
var ratioY = (double)maxHeight / image.Height;
var ratio = Math.Min(ratioX, ratioY);
var newWidth = (int)(image.Width * ratio);
var newImage = new Bitmap(newWidth, maxHeight);//
Graphics.FromImage(newImage).DrawImage(image, 0, 0, newWidth, maxHeight);//
@abe238
abe238 / ChangeOpacity
Created Jun 29, 2015
Change Image Opacity
View ChangeOpacity
public static Bitmap ChangeOpacity(Image img, float opacityvalue)
{
Bitmap bmp = new Bitmap(img.Width, img.Height);
Graphics graphics = Graphics.FromImage(bmp);
ColorMatrix colormatrix = new ColorMatrix();
colormatrix.Matrix33 = opacityvalue;
ImageAttributes imgAttribute = new ImageAttributes();
imgAttribute.SetColorMatrix(colormatrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap);
graphics.DrawImage(img, new Rectangle(0, 0, bmp.Width, bmp.Height), 0, 0, img.Width, img.Height, GraphicsUnit.Pixel, imgAttribute);
graphics.Dispose();
View gist:abb54c669a54031a9c69
//Example 1
{"2771":["2015/04/21 16:52:53"],
"2794":{"1":"2015-04-21 13:05:06 UTC"},
"2734":{"1":"2015-04-21 13:07:02 UTC"}}
//Example 2
{"26":{"0":"2014/07/30 13:44:40",
"1":"2014/07/30 14:40:12",
"2":"2014/07/30 14:51:41",
"3":"2014/07/31 17:45:26",