Skip to content

Instantly share code, notes, and snippets.

View tnolet's full-sized avatar

Tim Nolet tnolet

View GitHub Profile
@tnolet
tnolet / puppeteer_youtube.js
Created February 23, 2018 18:17
Puppeteer search youtube
const puppeteer = require('puppeteer')
const screenshot = 'youtube_fm_dreams_video.png'
try {
const browser = await puppeteer.launch()
const page = await browser.newPage()
await page.goto('https://youtube.com')
await page.type('#search', 'Fleetwood Mac Dreams')
await page.click('button#search-icon-legacy')
await page.waitForSelector('ytd-thumbnail.ytd-video-renderer')
/**
* @name Etsy shopping cart
* @desc Goes to etsy.com, select the first knick knack and adds it to the shopping cart.
*/
const assert = require('assert')
const puppeteer = require('puppeteer')
let browser
let page
@tnolet
tnolet / Dockerfile
Created January 19, 2018 15:48
A Dockerfile for running Puppeteer. Used for https://trypuppeteer.com. Scraped together from various sources. Works well with Puppeteer 1.0.0
FROM ubuntu:16.04
# Create a user so our program doesn't run as root.
RUN mkdir -p /home/chrome/
RUN groupadd -r chrome &&\
useradd -r -g chrome -d /home/chrome -s /sbin/nologin -G audio,video chrome
ENV HOME=/home/chrome
const AWS = require('aws-sdk')
const s3 = new AWS.S3()
const dynamodb = new AWS.DynamoDB()
exports.handler = (event, context, callback) => {
fetchS3()
.then(data => {
console.log(data)
return putDynamoDB(data.LastModified.toString())
})
package main
import (
"fmt"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/aws/session"
"github.com/aws/aws-sdk-go/service/dynamodb"
"github.com/aws/aws-sdk-go/service/s3"
@tnolet
tnolet / numbers.js
Last active October 6, 2022 14:19
exports.handler = (event, context, callback) => {
const fibo = fib()
for (let i=0; i<30; i++){
console.log(fibo())
}
const result = {
"isBase64Encoded": false,
"statusCode": 200,
"headers": {},
"body": "done"
package main
import (
"fmt"
"github.com/aws/aws-lambda-go/events"
"github.com/aws/aws-lambda-go/lambda"
)
func Handler() (events.APIGatewayProxyResponse, error) {
f := fibonacci()
exports.handler = (event, context, callback) => {
for (let i=0; i<30; i++){
console.log(fib(i))
}
const result = {
"isBase64Encoded": false,
"statusCode": 200,
"headers": {},
"body": "done"
}
@tnolet
tnolet / hook_method.js
Created January 15, 2018 21:00 — forked from iamkvein/hook_method.js
Improved way of temporarily replacing a method on an object
var install_hook_to = function(obj) {
if (obj.hook || obj.unhook) {
throw new Error('Object already has properties hook and/or unhook');
}
obj.hook = function(_meth_name, _fn, _is_async) {
var self = this,
meth_ref;
@tnolet
tnolet / aci.sh
Last active December 4, 2017 13:35
Azure Container Instances getting started
az group create --name timACI --location eastus
az container create --name simpleservice --image magneticio/simpleservice:1.0.0 --resource-group timACI --ip-address public --port 3000
az container show --name simpleservice --resource-group timACI
Name ResourceGroup ProvisioningState Image IP:ports CPU/Memory OsType Location
------------- --------------- ------------------- ------------------------------ ------------------- --------------- -------- ----------
simpleservice timACI Succeeded magneticio/simpleservice:1.0.0 52.191.116.216:3000 1.0 core/1.5 gb Linux eastus