Skip to content

Instantly share code, notes, and snippets.

View miceno's full-sized avatar

Orestes Sanchez miceno

  • Barcelona, Spain
View GitHub Profile
@miceno
miceno / debug_queries.py
Created May 15, 2024 08:39
Debug queries in Django
import csv
import functools
import logging
import time
from django.db import reset_queries, connection
from django.conf import settings
logger = logging.getLogger(__name__)
@miceno
miceno / indi-snapcap-wifi.ino
Last active November 30, 2023 17:09
Firmware for a SnapCap controller using ESP8266 and WiFi
/*
What: LEDLightBoxAlnitak - PC controlled lightbox implmented using the
Alnitak (Flip-Flat/Flat-Man) command set found here:
https://optec.us/resources/catalog/alnitak/pdf/Alnitak_GenericCommandsR4.pdf
Responses don't include the deviceId, since the implementation of the
INDI::SnapCap driver requires that responses do not use it.
Who:
Created By: Jared Wellman - jared@mainsequencesoftware.com
@miceno
miceno / socket-client.py
Last active November 6, 2023 22:55
TCP persistent socket client to send text messages from terminal
#!/usr/bin/env python3
#
# Python script to send text messages over a TCP socket.
# Copyright 2023
# by Orestes Sanchez Benavente is licensed under CC BY-NC-SA 4.0.
#
#
# Script to send text messages over a TCP socket.
# It creates a connection to the server and it keeps it
# for the whole session.
@miceno
miceno / esp8266wifi-async-tcp.ino
Created November 5, 2023 00:31
Example of a persistent TCP server using ESP8266Wifi and ESPAsyncTCP
#include <ESP8266WiFi.h>
#include <ESPAsyncTCP.h>
#define SERVER_HOST_NAME "esp_server"
#define SSID "YOUR_SSID"
#define PASSWORD "YOUR_SSID_PASSWORD"
#define SERVER_HOST_NAME "esp_server"
#define TCP_PORT 8888
@miceno
miceno / esp8266-wifimanager-tcp.ino
Created November 5, 2023 00:25
Example of a persistent TCP server using WiFiManager and ESP8266Wifi
/*
SocketServer.ino
Created on: 4.11.2023
Author: miceno.atreides@gmail.com
*/
#include <ESP8266WiFi.h>
#include <WiFiManager.h>
@miceno
miceno / async-persistent-tcp-server.py
Created November 5, 2023 00:10
Persistent TCP server using ESPAsyncTCP and ESP8266Wifi libraries
#include <ESP8266WiFi.h>
#include <ESPAsyncTCP.h>
#define MAX_BAUD_RATE 115200
#define SERVER_HOST_NAME "esp-example"
AsyncServer* server = NULL;
/* clients events */
static void handleError(void* arg, AsyncClient* client, int8_t error) {
@miceno
miceno / flag-icons.json
Last active February 12, 2023 11:16
mini flags encoded in base64
[
{
"language": "cat",
"flag": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAALCAMAAABBPP0LAAAAVFBMVEX8zzT2yi7wxCjswCTmuh72+2z0+V/y+FHw9kPu9DnoWxr+eVr8bkz5YED4VzPpHAnr8SvdsRX6Y031SSbyPhX67j/46zP15yPWqQ7mWRjm7RvRpAmYdm2TAAAAUElEQVR4AQXBMQ6CUABAsT7gg5K4Oej9r8gGEduAkCQDItLZHkRCtYLERsvzAacMuq96AwlaPgfIIPfVtCIbO/z6HsggOJuGxMaOmokXG2b+fnIKy04WJyIAAAAASUVORK5CYII="
},
{
"language": "es",
"flag": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAALCAMAAABBPP0LAAAAflBMVEX/AAD9AAD3AADxAADrAAD/eXn9bGz8YWH8WVn6UVH5SEj5Pz/3NDT0Kir9/QD+/nL+/lT18lDt4Uf6+j/39zD39yf19R3n5wDxflXsZ1Pt4Y3x8zr0wbLs1NXz8xPj4wD37t3jmkvsUU/Bz6nrykm3vJ72IiL0FBTyDAvhAABEt4UZAAAAX0lEQVR4AQXBQUrFQBBAwXqTDkYE94Jb73+qfwVRcYxVQRBRToiUfoaVpGTrtdS9SO0Z9FR9lVy/g5c99+dKl30N5uxPuviexXEc9/msC7TOkd4kHu/Dlh4itCJ8AP4B0w4Qwmm7CFQAAAAASUVORK5CYII="
},
{
@miceno
miceno / read xml from url.groovy
Created January 2, 2011 12:03
Read an XML from an URL
import groovy.xml.DOMBuilder
import javax.xml.parsers.*
// URL to read
def url= "http://stackoverflow.com/feeds/tag?tagnames=groovy&sort=newest"
// Parse the text
def doc
// Reading with XmlSlurper
doc = new XmlSlurper().parse( url)
@miceno
miceno / whatsapp-web-emoji-keywords.txt
Last active February 25, 2021 19:17 — forked from hkan/whatsapp-web-emoji-keywords.txt
Emoji shortcut keywords for Whatsapp Web
0⃣ 0, keycap, zero
1⃣ 1, number, one
🕜 1, 30, clock, time, one, thirty, 1:30, one-thirty
🕐 1, clock, time, one, 00, o’clock, 1:00, one o’clock
2⃣ 2, number, two
🕝 2, 30, clock, time, two, thirty, 2:30, two-thirty
🕑 2, clock, time, two, 00, o’clock, 2:00, two o’clock
3⃣ 3, keycap, three
🕞 3, 30, three, clock, time, thirty, 3:30, three-thirty
🕒 3, three, clock, time, 00, o’clock, 3:00, three o’clock
@miceno
miceno / import.py
Last active January 2, 2020 18:30 — forked from bmihelac/import.py
Import management command for django-import-export
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import mimetypes
import argparse
from django.utils.encoding import force_text
from django.utils.translation import ugettext as _
from django.core.management.base import BaseCommand
from django.db import transaction