Skip to content

Instantly share code, notes, and snippets.

View questsin's full-sized avatar

Nicholas Manolakos questsin

View GitHub Profile
async in lambda
var async = require('async');
var AWS = require('aws-sdk');
var fs = require('fs');
//Read config values from a JSON file.
var config = fs.readFileSync('./app_config.json', 'utf8');
config = JSON.parse(config);
var AWS = require('aws-sdk');
AWS.config.update({accessKeyId: "ACCESS_KEY",secretAccessKey: 'SECRET_KEY'});
var bucket = "arn:aws:s3:::nm3sys-tmp"
//put for small objects
function putObjectToS3(bucket, key, data){
var s3 = new AWS.S3();
var params = {
Bucket : bucket,
Key : key,
var AWS = require('aws-sdk');
//Policies
//AWSLambdaFullAccess
//CloudWatchFullAccess
//CloudWatchLogsFullAccess
//AWSIoTDataAccess
var iotdata = new AWS.IotData({endpoint: '?????.iot.us-west-2.amazonaws.com'});
exports.handler = (event, context, callback) => {
var fs = require('fs');
//Read config values from a JSON file.
var config = fs.readFileSync('./app_config.json', 'utf8');
config = JSON.parse(config);
//make sure doc loads before we try to manipuate it
$(document).ready(function(){
//all Jquery code
document.write("hello");
});
//manipuate objects
$("div").addClass("myClass"); //select all div tags
$("#myDiv").css("color","red"); //with the id, set the colr
// Load the http module to create an http server.
var http = require('http');
// Configure our HTTP server to respond with Hello World to all requests.
var server = http.createServer(function (request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.end("Hello World\n");
});
// Listen on port 8000, IP defaults to 127.0.0.1
// Call the console.log function.
console.log("Hello World");
//http://www.mojavelinux.com/articles/javascript_hashes.html
//examples
//var h = new HashTable({one: 1, two: 2, three: 3, "i'm no 4": 4});
//alert('original length: ' + h.length);
//alert('value of key "one": ' + h.getItem('one'));
//alert('has key "foo"? ' + h.hasItem('foo'));
//alert('previous value of key "foo": ' + h.setItem('foo', 'bar'));
//alert('length after setItem: ' + h.length);
//alert('value of key "foo": ' + h.getItem('foo'));
<!DOCTYPE html>
<html>
<head><title>blank</title></head>
<body>
<script>
var x = document.getElementById("demo");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {
<!DOCTYPE html>
<html>
<head><title>blank</title></head>
<body>
<script>
var x = document.getElementById("demo");
function getLocation() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(showPosition);
} else {