Skip to content

Instantly share code, notes, and snippets.

View tristansokol's full-sized avatar

Tristan Sokol tristansokol

View GitHub Profile
@tristansokol
tristansokol / index.js
Created October 21, 2017 18:41
mongodb - google cloud functions write example
exports.helloWorld = function helloWorld(req, res) {
//Connect to MongoDB Atlas
var MongoClient = require('mongodb').MongoClient;
var uri = "mongodb://user:pass@cluster0-shard-00-00-6chsu.mongodb.net:27017,cluster-shard-00-01-6chsu.mongodb.net:27017,cluster-shard-00-02-6chsu.mongodb.net:27017/test?ssl=true&replicaSet=Cluster-shard-0&authSource=admin";
MongoClient.connect(uri, function(err, db) {
//check for connection errors
if (err) res.status(400).send(err);
//Read the data from the incoming request & add it to an object to insert
var message = req.body.message;
#!/bin/bash
# a script to make great time lapses from the narrative clip.
# copy files to safe place, iterate through with ls-v, use spinners
# find a .mp4, rename the files, make a timelapse with the files (use spinners and headless ffmpeg)
# And then turn into ts files? delete videos in progress? Less ram/storage better!
#convert videos to better files with ffmpeg
# concatenate all the ts files, be sure to specify codec
# clean up.
@tristansokol
tristansokol / callback.php
Created November 22, 2017 18:57
callback for php oauth example
<?php
$client_id = '';
$client_secret = '';
$redirect_uri= "http://localhost:8080/callback.php";
$authorization_code = $_GET['code'];
if(!$authorization_code){
die('something went wrong!');
}
await page.goto('https://www.wikihow.com/Tie-Your-Shoes');
await page.waitForSelector('#article_shell');
await page.screenshot({
path: './production.png',
fullPage: false,
})
await page.goto('https://www.wikihow.com/Tie-Your-Shoes');
await page.waitForSelector('#article_shell');
await page.screenshot({
path: './local.png',
@tristansokol
tristansokol / linear-regression-tensorflow.html
Created June 30, 2018 03:53
linear regression with tensorflow
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@0.11.7"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.7.2/Chart.bundle.min.js"></script>
<div style="width:400px;">
<canvas id="myChart" width="400" height="400"></canvas>
</div>
<button onclick="train()">Train the model 1 step</button>
<script>
const trainX = [
3.3,
await Promise.all([
page.waitForNavigation({}),
page.click('#tickets > div.container > div > div > div > h2:nth-child(5) > button > i', {
button: 'left',
delay: 200
})
]);
const puppeteer = require('puppeteer');
browser = await puppeteer.launch({
headless: true,
slowMo: 80,
});
page = await browser.newPage();
await page.goto('http://example.com');
$ chrome --headless --screenshot=local.png \
--window-size=1280,1000 localhost:8080
$ chrome --headless --screenshot=production.png \
--window-size=1280,1000 https://example.com/
$ pixelmatch local.png production.png output.png 0.1
page.type('#name','Sammy',{
delay: 50//how long to wait between keystrokes
})
page.keyboard.type('Hello World!');
page.keyboard.press('ArrowLeft');
await page.keyboard.down('Shift');
await page.keyboard.up('Shift');
let mouse = page.mouse();
// same as page.click(), but uses a page x,y coordinate
mouse.click(300, 287,{
button: 'middle',//left, right, middle
clickCount: 2,
delay: 20 //how long to hold down the mouse button
})
mouse.down();
mouse.up();
mouse.move(x,y);