Skip to content

Instantly share code, notes, and snippets.

View roydondsouza's full-sized avatar

Roydon DSouza roydondsouza

View GitHub Profile
@roydondsouza
roydondsouza / gist:6dc666f88e459a40bc4bf04b1ab8d51f
Created June 16, 2016 18:52 — forked from prime31/gist:5675017
Simple PHP script showing how to send an Android push notification. Be sure to replace the API_ACCESS_KEY with a proper one from the Google API's Console page. To use the script, just call scriptName.php?id=THE_DEVICE_REGISTRATION_ID
<?php
// API access key from Google API's Console
define( 'API_ACCESS_KEY', 'YOUR-API-ACCESS-KEY-GOES-HERE' );
$registrationIds = array( $_GET['id'] );
// prep the bundle
$msg = array
@roydondsouza
roydondsouza / gist:75cc65cb57e8982fb742d7e511c5519f
Created July 11, 2016 05:08 — forked from sl4m/gist:5091803
create self-signed certificate for localhost
# SSL self signed localhost for rails start to finish, no red warnings.
# 1) Create your private key (any password will do, we remove it below)
$ openssl genrsa -des3 -out server.orig.key 2048
# 2) Remove the password
$ openssl rsa -in server.orig.key -out server.key
@roydondsouza
roydondsouza / merge.md
Created August 4, 2016 18:13 — forked from jt/merge.md
Merge a forked gist

If someone forks a gist and you'd like to merge their changes. Do this:

  1. clone your repo, I use the name of the gist

     git clone git://gist.github.com/1163142.git gist-1163142
    
  2. add a remote for the forked gist, I'm using the name of my fellow developer

     git remote add aaron git://gist.github.com/1164196.git
    
@roydondsouza
roydondsouza / AWSLambdaSimpleSMS.js
Created February 4, 2017 15:06 — forked from stevebowman/AWSLambdaSimpleSMS.js
AWS Lambda Function to send an SMS message via the Twilio API
console.log('Loading event');
// Twilio Credentials
var accountSid = '';
var authToken = '';
var fromNumber = '';
var https = require('https');
var queryString = require('querystring');
@roydondsouza
roydondsouza / sns-publish
Created February 4, 2017 19:42 — forked from jeremypruitt/sns-publish
AWS Lambda function to publish to SNS topic
console.log('Loading function');
var AWS = require('aws-sdk');
AWS.config.region = 'us-west-2';
exports.handler = function(event, context) {
console.log("\n\nLoading handler\n\n");
var sns = new AWS.SNS();
sns.publish({

How to setup AWS lambda function to talk to the internet and VPC

I'm going to walk you through the steps for setting up a AWS Lambda to talk to the internet and a VPC. Let's dive in.

So it might be really unintuitive at first but lambda functions have three states.

  1. No VPC, where it can talk openly to the web, but can't talk to any of your AWS services.
  2. VPC, the default setting where the lambda function can talk to your AWS services but can't talk to the web.
  3. VPC with NAT, The best of both worlds, AWS services and web.
@roydondsouza
roydondsouza / multer-to-s3.js
Created March 9, 2017 14:29 — forked from adon-at-work/multer-to-s3.js
Sample File Upload From Multer to S3
var AWS = require('aws-sdk'),
fs = require('fs');
// http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html#Credentials_from_Disk
AWS.config.loadFromPath('./aws-config.json');
// assume you already have the S3 Bucket created, and it is called ierg4210-shopxx-photos
var photoBucket = new AWS.S3({params: {Bucket: 'ierg4210-shopxx-photos'}});
function uploadToS3(file, destFileName, callback) {
@roydondsouza
roydondsouza / gist:7a6a5ffd28377aca64468e5d48fe9978
Created March 14, 2017 15:49 — forked from pitch-gist/gist:2999707
HTML: Simple Maintenance Page
<!doctype html>
<title>Site Maintenance</title>
<style>
body { text-align: center; padding: 150px; }
h1 { font-size: 50px; }
body { font: 20px Helvetica, sans-serif; color: #333; }
article { display: block; text-align: left; width: 650px; margin: 0 auto; }
a { color: #dc8100; text-decoration: none; }
a:hover { color: #333; text-decoration: none; }
</style>
@roydondsouza
roydondsouza / gmail.js
Created March 15, 2017 13:17
Gmail JS - Experimental Draft
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="https://github.com/KartikTalwar/gmail.js/raw/master/src/gmail.js">
// {inject gmail.js} by copy pasting gmail.js contents or via url like jquery above
// var Gmail = {.....} // paste gmail.js code here
// start using!
// you can also pass in a reference to jQuery upon init - Gmail(localJQuery)
var gmail = Gmail();
@roydondsouza
roydondsouza / braintree.txt
Last active April 19, 2017 21:21
Braintree Responses (Sandbox)
Customer Create:
(Success):
{
"customer": {
"id": "38656872",
"merchantId": "5xtcjpc4szdqhp8c",
"firstName": "Roy",
"lastName": "Smith",
"company": null,