Skip to content

Instantly share code, notes, and snippets.

View elecnix's full-sized avatar

Nicolas Marchildon elecnix

View GitHub Profile
"""
This module contains functions for estimating the cost of OpenAI's image recognition API.
https://platform.openai.com/docs/guides/vision
Usage:
import openai_vision_cost
cost = openai_vision_cost.estimate_image_cost(image_width, image_height, detail_level)
Generated with the help of ChatGPT:
@elecnix
elecnix / chatgpt-ocr.py
Created November 6, 2023 01:39
OCR with ChatGPT Plus
"""
OCR with ChatGPT Plus
Convert a bunch of image files into text, using Playwright to control your Chrome browser.
Prerequisites:
- Run `chrome --remote-debugging-port=9222`
- Log in to ChatGPT
- Select GPT-4
"""
@elecnix
elecnix / Vagrantfile
Created October 31, 2017 02:22
Beersmith Vagrant
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.ssh.forward_x11 = true
config.vm.provision "shell", path: "https://gist.githubusercontent.com/elecnix/dd31ee274c5e721ce42acd27412ad3f0/raw/dbf9c3fff720c2e8aa768bf8cb264ede37cedfe2/gistfile1.txt"
end
@elecnix
elecnix / gist:dd31ee274c5e721ce42acd27412ad3f0
Last active October 31, 2017 01:42
beersmith-on-ubuntu16.04.sh
wget -q https://s3.amazonaws.com/beersmith2-3/BeerSmith-2.3.12_amd64.deb
apt-get update
apt-get download libwebkitgtk-1.0-0 libwebkitgtk-1.0-common libjavascriptcoregtk-1.0-0
dpkg -i *.deb
@elecnix
elecnix / docker-compose.yml
Last active March 27, 2017 00:26
ErabliCompose
# Ce fichier sert à exécuter un collecteur, un dashboard, et une base de données InfluxDB.
#
# 1. git clone https://gist.github.com/51637af8e7bea6d4faf8471397e4b0e5.git erabliere
# 2. cd erabliere
# 3. git clone https://github.com/elecnix/ErabliCollecteur.git
# 4. git clone https://github.com/elecnix/ErabliDash.git
# 5. docker-compose up -d
# 6. Ouvrir http://localhost:3000/ pour ErabliDash
# 7. Ouvrir http://localhost:3001/ pour Grafana
#
#!/bin/bash
repos=$(ls ~/repos)
for repo in $repos ; do
if [ -d ~/repos/$repo/.hg ] ; then
echo -e "\e[93m$repo\e[0m"
hg --cwd ~/repos/$repo qseries -v -s
if [ -d ~/repos/$repo/intelebase/.hg ] ; then
hg --cwd ~/repos/$repo/intelebase qseries -v -s
fi
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<head>
<script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="jquery.sparkline.js"></script>
<script type="text/javascript">
$(function() {
for (row = 0; row < 80; row++) {
var myvalues = [];
for (i = 0; i < 500; i++) {
#include "SparkIntervalTimer/SparkIntervalTimer.h"
//SYSTEM_MODE (MANUAL);
volatile int i = 0; // Variable to use as a counter volatile as it is in an interrupt
volatile boolean zero_cross = 0; // Boolean to store a "switch" to tell us if we have crossed zero
int AC_pin = D7; // Output to Opto Triac
int dim = 0; // Dimming level (0-128) 0 = on, 128 = 0ff
int inc = 1; // counting up or down, 1=up, -1=down
cat top-1m.csv | sed -e 's_.*,\(.*\)_echo | openssl s\_client -connect \1:443 > certs/\1.pem\&_' > certs.sh
bash certs.sh
ls certs | xargs -L1 -I DOMAIN echo 'openssl x509 -in certs/DOMAIN -text -noout > checks/DOMAIN.check' > checks.sh
bash checks.sh
cat top-1m.csv | sed -e 's#.*,\(.*\)#\1#'| xargs -n1 -P20 -I DOM grep -H 'Not After' checks/DOM.pem.check 2>/dev/null | cut -d ':' -f 1,3-|sed -e 's_checks/\(.*\).pem.check: \(.*\)_\1,\2_' > top-1m-expiry.csv
@elecnix
elecnix / setup-openwrt-usb.sh
Last active August 29, 2015 14:13
Setup USB storage for vfat USB key on OpenWrt (without OpenWrt internet acccess)
BASE_URL=https://downloads.openwrt.org/barrier_breaker/14.07/ar71xx/generic/packages/base/
TARGET_IP=192.168.1.1
TARGET_USER=root
KERNEL_VERSION=3.10.49-1
HARDWARE=ar71xx
MODULES="kmod-fs-vfat kmod-nls-base kmod-nls-cp437 kmod-nls-iso8859 kmod-scsi-core kmod-usb2 kmod-usb-storage"
for MOD in MODULES do
wget $MOD_$KERNEL_$VERSION_$HARDWARE.ipk
done
wget $BASE_URL/block-mount_2014-06-22-e0430f5c62f367e5a8e02755412977b02c3fc45e_ar71xx.ipk