Skip to content

Instantly share code, notes, and snippets.

View elecnix's full-sized avatar

Nicolas Marchildon elecnix

View GitHub Profile
@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 / convert-to-hd.sh
Created April 6, 2011 22:38
Convert video to 720p HD
#!/bin/bash
#
# Scales down (or up) a video to 720p, re-encoding it as MPEG4.
#
# Useful as a Nautilus Script in Gnome.
#
# https://help.ubuntu.com/community/AndroidVideoEncoding#Expert mode: Using ffmpeg (command line)
ffmpeg -strict experimental -i "$1" -s 1280x720 -vcodec mpeg4 -b 3000k -acodec aac -ac 1 -ar 16000 -r 13 -ab 64000 "$1.shrinked.mp4"
"""
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 / scan.awk
Created September 24, 2014 03:15
Parse iw scan output
# iw wlan0 scan | sed -e 's#(on wlan# (on wlan#g' | awk -f scan.awk
$1 == "BSS" {
MAC = $2
print $2
e = wifi[MAC]
e["enc"] = "Open"
}
$1 == "SSID:" {
e = wifi[MAC]
e["SSID"] = $2
@elecnix
elecnix / open_mailto.sh
Created September 22, 2010 03:04
set-gmail-as-default-mail-client-in-ubuntu
#!/bin/bash
# To install:
# mkdir ~bin
# Paste this in ~bin/open_mailto.sh
# chmod a+x ~bin/open_mailto.sh
# Go to System \ Preferences \ Preferred Applications
# Under Mail Reader, select Custom, and then put /home/username/bin/open_mailto.sh into the Command window, changing "username" to your username.
# Voilà! Credits to: http://www.howtogeek.com/howto/ubuntu/set-gmail-as-default-mail-client-in-ubuntu/
google-chrome "https://mail.google.com/mail?view=cm&tf=0&to=`echo $1 | sed 's/mailto://'`"
@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
#
@elecnix
elecnix / convert-video-for-iaudio-u3.sh
Created November 29, 2008 05:37
Convert FLV to AVI with mencoder
mencoder in.flv -quiet -oac pcm -ovc xvid -ofps 15 -vf scale=160:-2 -xvidencopts bitrate=256:vhq=4:me_quality=4:max_bframes=0 -o tmp.avi && transcode -i tmp.avi -P1 -b 0,1 -o out.avi
#!/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