Skip to content

Instantly share code, notes, and snippets.

😅

Tim Nolet tnolet

😅
Block or report user

Report or block tnolet

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tnolet
tnolet / puppeteer_youtube.js
Created Feb 23, 2018
Puppeteer search youtube
View puppeteer_youtube.js
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')
View gist:3fe4a740640ea8116183ad8628086cae
/**
* @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 Jan 19, 2018
A Dockerfile for running Puppeteer. Used for https://trypuppeteer.com. Scraped together from various sources. Works well with Puppeteer 1.0.0
View Dockerfile
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
View s3dynamo.js
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())
})
View s3dynamo.go
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"
View numbers.js
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"
View numbers.go
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()
View numbers_recursive.js
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 Jan 15, 2018 — forked from iamkvein/hook_method.js
Improved way of temporarily replacing a method on an object
View hook_method.js
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 Dec 4, 2017
Azure Container Instances getting started
View aci.sh
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
You can’t perform that action at this time.