Skip to content

Instantly share code, notes, and snippets.

@xShirase
xShirase / log.json
Created January 17, 2021 13:58
log
g@desktop:/mnt/c/Node/chrometest$ curl -XPOST "http://localhost:9000/2015-03-31/functions/function/invocations" -d '{}'
{
"result":{
"type":"object",
"className":"Object",
"description":"Object",
"objectId":"{\"injectedScriptId\":2,\"id\":1}"}
}
@xShirase
xShirase / Dockerfile
Last active January 17, 2021 13:43
func
# App setup
RUN mkdir -p ${FUNCTION_DIR}
COPY function/package.json ${FUNCTION_DIR}
WORKDIR ${FUNCTION_DIR}
# Install deps
RUN yarn
# Build app (do last for speed)
COPY function/. ${FUNCTION_DIR}
@xShirase
xShirase / bootstrap.sh
Created January 17, 2021 13:40
bootstrap
#!/bin/sh
# Based on: https://medium.com/dot-debug/running-chrome-in-a-docker-container-a55e7f4da4a8
readonly G_LOG_I='[INFO]'
readonly G_LOG_W='[WARN]'
readonly G_LOG_E='[ERROR]'
main() {
launch_xvfb
ADD https://github.com/aws/aws-lambda-runtime-interface-emulator/releases/latest/download/aws-lambda-rie /usr/local/bin/aws-lambda-rie
RUN chmod 755 /usr/local/bin/aws-lambda-rie
COPY entrypoint.sh /
RUN chmod 755 /entrypoint.sh
ENTRYPOINT [ "/entrypoint.sh" ]
@xShirase
xShirase / Dockerfile
Created January 17, 2021 13:27
Chrome Docker
FROM ubuntu:focal
RUN apt-get update; apt-get clean
# Add a user for running applications.
RUN useradd apps
RUN mkdir -p /home/apps && chown apps:apps /home/apps
# Install xvfb and other stuff.
RUN apt-get install -y xvfb fluxbox wget wmctrl gnupg2
@xShirase
xShirase / Dockerfile
Last active January 17, 2021 13:32
aws-lambda-ric
ARG FUNCTION_DIR="/function"
FROM ubuntu:focal
ARG FUNCTION_DIR
# Install utils for ric
RUN apt install -y curl wget git g++ make cmake unzip libcurl4-openssl-dev autoconf libtool
# install NodeJS
RUN curl -sL https://deb.nodesource.com/setup_12.x | bash -
@xShirase
xShirase / chrome.ts
Last active January 17, 2021 12:56
Headless chrome on Lambda
const remoteInterface = require('chrome-remote-interface')
const chromium = require('chrome-aws-lambda')
const launcher = require('chrome-launcher')
const chromeFlags = [
'--no-xshm',
'--disable-dev-shm-usage',
'--single-process',
'--no-sandbox',
'--no-first-run',
{
"FunctionName": "myFunc",
"LastModified": "2017-11-25T19:37:47.620+0000",
"MemorySize": 1536,
"Environment": {
"Variables": {
//some stuff
}
},
"Version": "$LATEST",
@xShirase
xShirase / gist:bc7b50cf5c4522ed16158fe7b40555f0
Last active December 27, 2016 15:09
reverse box - usable
var f = $('#shoutbox form').detach();
$('#shoutbox').append(f);
var objDiv = document.getElementById("sbf");
objDiv.scrollTop = objDiv.scrollHeight;
ul = $('#sbf');
ul.children().each(function(i,li){ul.prepend(li)})
function handler(e) {
var target = e.target;
$('#sbf').off('DOMNodeInserted', 'div', handler);
$('#sbf').append(target);
{
"flyer_item_id" : 167392889,
"flyer_id" : 969512,
"flyer_type_id" : 3800,
"merchant_id" : 2332,
"brand" : "",
"display_name" : "Blueberries",
"name" : "Blueberries",
"description" : "Product of Chile, no. 1 grade\n6 OZ",
"current_price" : "5.0",