Skip to content

Instantly share code, notes, and snippets.

View Raidus's full-sized avatar

Wilhelm R. Raidus

View GitHub Profile
@kallebysantos
kallebysantos / App.tsx
Last active April 22, 2024 11:05
Running Local AI models with FastAPI and Vercel AI SDK
import "./App.css";
import { useEffect, useState } from "react";
import { useCompletion } from "ai/react";
function App() {
const [apiResponse, setApiResponse] = useState("");
useEffect(() => {
fetch("/api/reply?value=Hello from React App!")
.then((response) => response.json())
@blackrez
blackrez / example_thread.py
Created February 6, 2022 19:39
duckdb with thread
from multiprocessing import connection
from time import sleep, perf_counter
from threading import Thread
import duckdb
con = duckdb.connect(database=':memory:')
con.execute("CREATE TABLE items(item VARCHAR, value DECIMAL(10,2), count INTEGER)")
con.execute("INSERT INTO items VALUES ('jeans', 20.0, 42), ('hammer', 42.2, 4242)")
@sdesalas
sdesalas / Async.gs
Last active April 24, 2024 09:21
Asynchronous execution for Google App Scripts (gas)
/*
* Async.gs
*
* Manages asyncronous execution via time-based triggers.
*
* Note that execution normally takes 30-60s due to scheduling of the trigger.
*
* @see https://developers.google.com/apps-script/reference/script/clock-trigger-builder.html
*/
@tolgamorf
tolgamorf / ubuntu-server-setup.sh
Last active January 7, 2022 05:13
Ubuntu server setup: Miniconda + Node.js + npm + PM2
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh
curl -sL https://deb.nodesource.com/setup_8.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
sudo apt-get install -y nodejs
sudo npm install pm2@latest -g
# pm2 startup
sudo env PATH=$PATH:/usr/bin /usr/lib/node_modules/pm2/bin/pm2 startup systemd -u ubuntu --hp /home/ubuntu
sudo chown ubuntu:ubuntu /home/ubuntu/.pm2 /home/ubuntu/.pm2/rpc.sock /home/ubuntu/.pm2/pub.sock
@syntaqx
syntaqx / cloud-init.yaml
Last active March 26, 2024 21:02
cloud init / cloud config to install Docker on Ubuntu
#cloud-config
# Option 1 - Full installation using cURL
package_update: true
package_upgrade: true
groups:
- docker
system_info:
require('dotenv').config()
const cors = require('cors')
const bodyParser = require('body-parser')
const express = require('express')
const expressJwt = require('express-jwt')
const cookieSession = require('cookie-session')
const jwt = require('jsonwebtoken')
const passport = require('passport')
const GoogleStrategy = require('passport-google-oauth20').Strategy
const jwtSecret = Buffer.from('Zn8Q5tyZ/G1MHltc4F/gTkVJMlrbKiZt', 'base64')
@sberryman
sberryman / Dockerfile.yml
Last active July 13, 2020 12:06
DeepMatching GPU version on Ubuntu 16.04 (Docker)
FROM nvidia/cuda:8.0-cudnn5-devel
# PYTHON 2, DO NOT USE PYTHON 3!
LABEL maintainer "Shaun Berryman <shaun@shaunberryman.com>"
# Supress warnings about missing front-end. As recommended at:
# http://stackoverflow.com/questions/22466255/is-it-possibe-to-answer-dialog-questions-when-installing-under-docker
ARG DEBIAN_FRONTEND=noninteractive
@tegansnyder
tegansnyder / Preventing-Puppeteer-Detection.md
Created February 23, 2018 02:41
Preventing Puppeteer Detection

I’m looking for any tips or tricks for making chrome headless mode less detectable. Here is what I’ve done so far:

Set my args as follows:

const run = (async () => {

    const args = [
        '--no-sandbox',
        '--disable-setuid-sandbox',
        '--disable-infobars',
const Page = require('puppeteer/lib/Page');
// the following 2 methods are originally from: https://github.com/GoogleChrome/puppeteer/issues/85#issuecomment-341743259, with some modification to fit puppeteerv1.0.0
async function newPageWithNewContext(browser) {
const { browserContextId } = await browser._connection.send('Target.createBrowserContext');
const { targetId } = await browser._connection.send('Target.createTarget', { url: 'about:blank', browserContextId });
const target = await browser._targets.get(targetId);
const client = await browser._connection.createSession(targetId);
const page = await Page.create(client, target, browser._ignoreHTTPSErrors, browser._appMode, browser._screenshotTaskQueue);
page.browserContextId = browserContextId;
@GuilloOme
GuilloOme / background.js
Last active March 24, 2023 20:05
Puppeteer (v.0.12.0) navigation blocking workaround
(function() {
'use strict';
// keep track of all the opened tab
let tabs = {};
// Get all existing tabs
chrome.tabs.query({}, function(results) {
results.forEach(function(tab) {
tabs[tab.id] = tab;